欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python調(diào)用Zoomeye搜索接口的實(shí)現(xiàn)

 更新時(shí)間:2023年01月06日 09:35:49   作者:lyshark  
本文主要介紹了Python調(diào)用Zoomeye搜索接口的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

鐘馗之眼是一個(gè)強(qiáng)大的搜索引擎,不同于百度谷歌,它主要收集網(wǎng)絡(luò)中的主機(jī),服務(wù)等信息,國內(nèi)互聯(lián)網(wǎng)安全廠商知道創(chuàng)宇開放了他們的海量數(shù)據(jù)庫,對(duì)之前沉淀的數(shù)據(jù)進(jìn)行了整合、整理,打造了一個(gè)名符其實(shí)的網(wǎng)絡(luò)空間搜索引擎ZoomEye,運(yùn)用Python接口可以靈活的實(shí)現(xiàn)數(shù)據(jù)采集。

鐘馗之眼的常用搜索關(guān)鍵字如下所示。

app:組件名稱
ver:組件版本
搜索 apache組件    版本2.4  --> app:apache ver:2.4
port:端口號(hào) ---> 例如:搜索開放了SSH端口的主機(jī) port:22
指定搜索的操作系統(tǒng) OS:操作系統(tǒng)名稱 ---> OS:Linux
指定搜索的服務(wù) service:服務(wù)名稱 --->  例如,搜素SSH服務(wù)  Service:SSH
指定搜索的地理位置范 --> country:國家   city:城市名    country:China --> city:Beijing
搜索指定的CIDR網(wǎng)段 例如: CIDR:192.168.158.12/24
搜索指定的網(wǎng)站域名 ---> site:www.baidu.com
搜索指定的主機(jī)名 ---> hostname:zwl.cuit.edu.cn
搜索指定的設(shè)備名  --> device:router
搜索具有特定首頁關(guān)鍵詞的主機(jī) ---> keyword:technology

提供的搜索腳本如下。

import os,json,requests
import argparse

def login():
    url_login="https://api.zoomeye.org/user/login"
    data={
        "username": "1098395580@qq.com",
        "password": "xiaohua@1998"
    }
    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("剩余搜索次數(shù): {}".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("地區(qū): %1s %3s "%(json_data[item]['geoinfo']['continent']['names']['zh-CN'],
                json_data[item]['geoinfo']['subdivisions']['names']['zh-CN']))
    except Exception:
        pass

def Banner():
    print("  _          ____  _                _    ")
    print(" | |   _   _/ ___|| |__   __ _ _ __| | __")
    print(" | |  | | | \___ \| '_ \ / _` | '__| |/ /")
    print(" | |__| |_| |___) | | | | (_| | |  |   < ")
    print(" |_____\__, |____/|_| |_|\__,_|_|  |_|\_\\")
    print("       |___/                             \n")
    print("E-Mail: me@lyshark.com")

if __name__== "__main__":
    Banner()
    parser = argparse.ArgumentParser()
    parser.add_argument("-s","--search",dest="search",help="根據(jù)傳入語法搜索指定內(nèi)容")
    parser.add_argument("-f","--file",dest="file",help="保存文件的名字 *.json")
    parser.add_argument("-p","--page",dest="page",help="需要檢索第幾頁的數(shù)據(jù)")
    parser.add_argument("-q","--query" ,dest="query",help="單獨(dú)使用,可用于查詢剩余次數(shù)")
    parser.add_argument("-g","--get" ,dest="get",help="提取本地json文件并解析出關(guān)鍵數(shù)據(jù)")
    args = parser.parse_args()
    if args.search and args.file and args.page:
        token = login()
        Search(token,args.search,args.file,args.page)
    elif args.query and args.search == None:
        token = login()
        GetResidual(token)
    elif args.get:
        Get_System(args.get)
    else:
        parser.print_help()

查詢使用次數(shù): 默認(rèn)情況下,鐘馗之眼每月給與10000條左右的查詢次數(shù),可以使用 -q 參數(shù)實(shí)現(xiàn)次數(shù)的查詢。

**搜索功能的使用:**通過-s選項(xiàng)指定你需要搜索的關(guān)鍵字,可以結(jié)合鐘馗之眼搜索語法使用-p就是搜索的頁碼數(shù)-f保存為json文件。

在JSON中解析IP地址: 在本地JSON文件中解析IP地址,提取出關(guān)鍵數(shù)據(jù)。

 到此這篇關(guān)于Python調(diào)用Zoomeye搜索接口的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Python調(diào)用Zoomeye搜索接口內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論