Zoomeye 脚本收集并数据


钟馗之眼,是一个强大的搜索引擎,不同于百度谷歌,它主要收集网络中的主机,服务等信息,类似于Shodan 这里通过Python实现了对钟馗之眼API的解析。

Zoomeye 自己实现解析

常用搜索关键字

app:组件名称    ver:组件版本

例如:搜索 apache组件    版本2.4  --> app:apache ver:2.4
 
指定搜索的端口
port:端口号 ---> 例如:搜索开放了SSH端口的主机 port:22
     
指定搜索的操作系统 OS:操作系统名称 ---> OS:Linux
 
指定搜索的服务 service:服务名称 --->  例如,搜素SSH服务  Service:SSH
 
指定搜索的地理位置范 --> country:国家   city:城市名    country:China --> city:Beijing
 
搜索指定的CIDR网段 例如: CIDR:192.168.158.12/24
 
搜索指定的网站域名 ---> site:www.baidu.com
 
搜索指定的主机名 ---> hostname:zwl.cuit.edu.cn
 
搜索指定的设备名  --> device:router
 
搜索具有特定首页关键词的主机 ---> keyword:technology

搜索脚本

#coding=utf-8
import os,json,requests
from optparse import OptionParser

def login():
    url_login="https://api.zoomeye.org/user/login"
    data={
        "username": "xxx@qq.com",
        "password": "xxxxxx"
    }
    data=json.dumps(data)
    r=requests.post(url=url_login,data=data)
    return json.loads(r.content)['access_token']

def GetResidual(token):
    url="https://api.zoomeye.org/resources-info"
    headers={'Authorization':'JWT ' + token}
    r=requests.get(url=url,headers=headers)
    datas=json.loads(r.content)
    print("剩余搜索次数: {}".format(datas['resources']['search']))

def Search(token,search,files,page):
    url="https://api.zoomeye.org/web/search?query={}&page={}".format(search,page)
    headers={'Authorization':'JWT ' + token}
    r=requests.get(url=url,headers=headers)
    data = json.loads(r.content)['matches']
    with open(files,'w',encoding='utf-8') as f:
         json.dump(data,f,ensure_ascii=False)
    print("[+] 保存文件: {} 长度: {} 页码: {} 查询语法: {}".format(files,len(data),page,search))

def Get_System(files):
    try:
        with open(files,'r',encoding='utf8') as fp:
            json_data = json.load(fp)
            json_len = len(json_data)
            for item in range(0,json_len):
                print("IP地址: %15s   |" %(json_data[item]['ip'][0]),end="")
                print("地区: %1s %3s "%(json_data[item]['geoinfo']['continent']['names']['zh-CN'],
                json_data[item]['geoinfo']['subdivisions']['names']['zh-CN']))
    except Exception:
        pass

if __name__== "__main__":
    #使用方式: main.py -s windows -p 3 -f windows.json
    parser = OptionParser()
    parser.add_option("-s","--search",dest="search",help="根据传入语法搜索指定内容")
    parser.add_option("-f","--file",dest="file",help="保存文件的名字 *.json")
    parser.add_option("-p","--page",dest="page",help="需要检索第几页的数据")
    parser.add_option("-q","--query" ,dest="query",help="单独使用,可用于查询剩余次数")
    parser.add_option("-g","--get" ,dest="get",help="提取本地json文件并解析出关键数据")
    (options,args) = parser.parse_args()
    if options.search and options.file and options.page:
        token = login()
        Search(token,options.search,options.file,options.page)
    elif options.query and options.search == None:
        token = login()
        GetResidual(token)
    elif options.get:
        Get_System(options.get)
    else:
        parser.print_help()

查询使用次数: 默认情况下,钟馗之眼每月给与10000条左右的查询次数,可以使用 -q 参数实现次数的查询。

搜索功能的使用: 通过 -s 选项指定你需要搜索的关键字,可以结合钟馗之眼搜索语法使用,-p 就是搜索的页码数,-f 保存为json文件。

解析IP地址 在本地JSON文件中解析IP地址,提取出关键数据。

shodan 工具的使用

常用语法:

hostname:"主机或域名"   ---> 如 hostname:"google''

port:"端口或服务"  ---> 如 port:"21"
     
ip : "ip地址"  ---> 如 ip : "168.205.71.64"
     
net:"IP地址或子网" ---> 如 net:"210.45.240.0/24"
     
vuln :指定漏洞的cve ---> 如 vuln:CVE-2015-8869   ---> 如 country:CN vuln:CVE-2014-0160
     
os :"操作系统" ---> 如 os:"centOS"
     
isp:"ISP供应商" ---> 如 isp:"China Telecom"
     
product:"操作系统/软件/平台" ---> 如 product:"Apache httpd"
     
version:"软件版本" ---> 如 version:"3.1.6"
     
geo:"经纬度" ---> 如 geo:"39.8779,116.4550"
     
country`:"国家" ---> 如 country:"China" country:"UN"
     
city:"城市" ---> 如 city:"Hefei"
     
org:"组织或公司"  ---> 如 org:"google"
     
before/after:"日/月/年"  ---> 如 before:"25/09/2017"  --> after:"25/09/2017"
     
asn : "自治系统号码" ---> 如 asn:"AS2233"

直接使用 pip install shodan 安装好,登录https://account.shodan.io/找到shodan APIKEY

项目地址:https://github.com/achillean/shodan-python

初始化,将你的KEY导入,然后可以直接搜索了。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM