九零登录

[【通过】] 【已转正】PY小脚本:Zoomeye+Exploit

[复制链接]
发表于 2016-7-24 02:13:28 | 显示全部楼层 |阅读模式
简介:通过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
单选投票, 共有 11 人参与投票

投票已经结束

54.55% (6)
45.45% (5)
您所在的用户组没有投票权限

评分

参与人数 1酒票 +5 收起 理由
管理05 + 5 欢迎加入90!

查看全部评分

发表于 2016-7-24 11:04:09 | 显示全部楼层
Zoomeye这个轮子已经被玩烂了,真的没必要再重复了
 楼主| 发表于 2016-7-24 14:46:12 | 显示全部楼层
寒风不冷 发表于 2016-7-24 11:04
Zoomeye这个轮子已经被玩烂了,真的没必要再重复了

怂得斯内~╯▂╰
发表于 2016-7-24 19:33:23 | 显示全部楼层
看轮子。。
 楼主| 发表于 2016-7-25 20:16:52 | 显示全部楼层

可惜自己长的不猥琐想不出新轮子

九零

GMT+8, 2026-10-22 13:25

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表