简介:通过zoomeye搜索符合条件的目标后存入数据库。或者指定特定的exp从数据库选取合适的结果进行检测(有种重复造轮子的感觉。。。)。
脚本自带的poc比较少(鸡肋鸡肋鸡肋鸡肋),添加新的也很容易。记得安装 requests和bs4依赖哦
废话不多说,扔上部分代码:
[Python] 纯文本查看 复制代码 #!/usr/bin/env python
# -*- coding: utf-8 -*-
import optparse
import sqlite3
from my_ze import *
import requests
import sys
import ssl
import json
import warnings
import requests
from bs4 import BeautifulSoup
warnings.filterwarnings("ignore")
#把搜索结果放入数据库
def sql_o(miaoshu,urls):
conn = sqlite3.connect('R.db')
conn.execute('create table if not exists test( MIAOSHU CHAR(50),URL CHAR(50))')
for i in urls :
conn.execute('insert into test values(?,?)',(miaoshu,i))
conn.commit()
conn.close()
#从数据库搜索指定的url
def sql_s(miaoshu):
sqls=[]
conn = sqlite3.connect('R.db')
conn.execute('create table if not exists test( MIAOSHU CHAR(50),URL CHAR(50))')
cursor=conn.execute("SELECT URL from test WHERE MIAOSHU = ?",(miaoshu,))
#print cursor
for row in cursor:
sqls.append(row[0])
return sqls
conn.close()
#把可以利用的url放入数据库
def res_insert(miaoshu,url):
conn = sqlite3.connect('Res.db')
conn.execute('create table if not exists test(MIAOSHU CHAR(50),URL CHAR(50))')
conn.execute('insert into test values(?,?)',(miaoshu,url))
conn.commit()
conn.close()
#查找特定exp检测
def exploit(exp,miaoshu):
exps=['zabbix']#exps=['zabbix','test']
# print ';chooing'
if exp == exps[0]:
import zabbix as ex
#elif exp ==exps[1]:
#import test as ex
else:
print 'NO exp'
sqlss=sql_s(miaoshu)
if sqlss==[]:
print 'No target to exploit'
for i in sqlss :
#print 'h'
y=ifhttp(i)
if ex.poc(i):
res_insert(miaoshu,i)
print '[+]'+y+' OK!'
else:
print '[-]'+y+' Failed!'
def ifhttp(url):
if 'http://' in url:
return url
else:
return 'http://'+url
if __name__=='__main__':
parser=optparse.OptionParser('''Example: Main.py -e test -m joomla \nOr Main.py -u [url=mailto:[email protected]][email protected][/url] -p 123456 -s port:3389 -t host -m 3389''')
parser.add_option('-u',dest='username',type='string')
parser.add_option('-p',dest='password',type='string')
parser.add_option('-s',dest='search',type='string')
parser.add_option('-e',dest='exploit',type='string')
parser.add_option('-m',dest='miaoshu',type='string')
parser.add_option('-t',dest='type',type='string')
(opt,args)=parser.parse_args()
s=opt.search
e=opt.exploit
m=opt.miaoshu
t=opt.type
#登录
if opt.username != None and opt.password != None:#write to config
if s != None :
if m !=None:
if t == 'host' or t== 'web':
zoom=my_zoom(opt.username,opt.password,s,t)
res=zoom.run()
#sys.exit()
else:
print '[-]Type:web or host'
sys.exit()
print '[+]saving the result'
#print res
sql_o(m,res)
print '[+] Done'
sys.exit()#找到特定结果后退出(为了不与-e参数一起使用)
else:
print "you need to give a name about this search for eploting"
exit(0)
#if e !=None :
#if m !=None:
# exploit(e,m)
# else:
#print "you need to give a name about this search for eploting"
#exit(0)
elif e !=None :
if m !=None:
exploit(e,m)
else:
print "you need to give a name about this search for eploting"
exit(0)
完整地址:https://github.com/la5la/zoom
代码写的比较粗糙,恳请各位老司机前辈多多指教。
====================================
管理给予通过,已经转正。
管理05
|