ZoomEye 钟馗之眼 搜索工具 基于API

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: f0rsaken
import getopt
import requests
import sys
import time
USER = ""
PASS = ""
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "hu:p:m:q:l:", ["help", "user=", "pass=", "mode=", "query=", "limit="])
except getopt.GetoptError as e:
print("[-] %s" % e)
usage()
sys.exit(2)
username = USER
password = PASS
mode = "host"
query = ""
limit = 2048
for o, a in opts:
if o in ("-h", "--help"):
usage()
sys.exit()
elif o in ("-u", "--user"):
username = a
elif o in ("-p", "--pass"):
password = a
elif o in ("-m", "--mode"):
if a in ("host", "web"):
mode = a
else:
print("[-] Unknown Mode!")
usage()
sys.exit(2)
elif o in ("-q", "--query"):
query = a
elif o in ("-l", "--limit"):
try:
limit = int(a)
except ValueError as e:
print("[-] %s" % e)
usage()
sys.exit(2)
else:
pass
if not query:
print("[-] Query Keyword Not Found!")
usage()
sys.exit(2)
print("[!] Mode: %s" % mode)
print("[!] Query: %s" % query)
print("[!] Limit: %s" % limit)
try:
choice = raw_input("Start Query? [Y/n] ")
except NameError as e:
choice = input("Start Query? [Y/n] ")
if choice.lower() == "n":
sys.exit()
authorization = get_authorization(username, password)
if not authorization:
sys.exit(1)
resources_info = get_resources_info(authorization)
if not resources_info:
sys.exit(1)
else:
print("[*] Plan: %s" % resources_info["plan"])
print("[*] Resources: Host %s Web %s" % (resources_info["resources"]["host-search"], resources_info["resources"]["web-search"]))
result = list()
page = 1
while page <= limit:
temp = search(authorization, mode, query, str(page))
if not temp:
break
result.extend(extract(mode, temp))
print("Download Page: %s" % page)
page += 1
result = set(result)
log = "ZoomEye_" + str(time.time()) + ".txt"
with open(log, "w") as f:
f.writelines(result)
print("Please Check The %s" % log)
def usage():
print("Usage: python %s [options]" % sys.argv[0])
print("")
print("Options:")
print(" -h, --help Show Help Message And Exit")
print(" -u USER, --user=USER ZoomEye E-Mail")
print(" -p PASS, --pass=PASS ZoomEye Password")
print(" -m MODE, --mode=MODE host || web (Default: host)")
print(" -q QUERY, --query=QUERY Query Keyword")
print(" -l LIMIT, --limit=LIMIT Page Limit (Default: 2048)")
def get_authorization(username, password):
authorization = dict()
access_token = get_access_token(username, password)
if access_token:
authorization["Authorization"] = "JWT " + access_token["access_token"]
else:
pass
return authorization
def get_access_token(username, password):
try:
r = requests.post("https://api.zoomeye.org/user/login", json={"username": username, "password": password})
except requests.RequestException as e:
print("[-] %s" % e)
print("[-] Get Access Token Failed!")
else:
if r.status_code == requests.codes.ok:
return r.json()
else:
print("[-] %s %s \n[-] %s" % (r.status_code, r.json()["error"], r.json()["message"]))
print("[-] Get Access Token Failed!")
def get_resources_info(authorization):
try:
r = requests.get("https://api.zoomeye.org/resources-info", headers=authorization)
except requests.RequestException as e:
print("[-] %s" % e)
print("[-] Get Resources Info Failed!")
else:
if r.status_code == requests.codes.ok:
return r.json()
else:
print("[-] %s %s \n[-] %s" % (r.status_code, r.json()["error"], r.json()["message"]))
print("[-] Get Resources Info Failed!")
"):
try:
url = "https://api.zoomeye.org/" + mode + "/search?query=" + query + "&page=" + page
print("GET %s" % url)
r = requests.get(url, headers=authorization)
except requests.RequestException as e:
print("[-] %s" % e)
print("[-] %s Search Failed!" % mode.capitalize())
else:
if r.status_code == requests.codes.ok:
return r.json()
else:
print("[-] %s %s \n[-] %s" % (r.status_code, r.json()["error"], r.json()["message"]))
print("[-] %s Search Failed!" % mode.capitalize())
def extract(mode, temp):
result = list()
if mode == "host":
for line in temp["matches"]:
result.append(line["ip"] + ":" + str(line["portinfo"]["port"]) + "\n")
else:
for line in temp["matches"]:
result.append(line["site"] + "\n")
return result
if __name__ == "__main__":
main()
ZoomEye 钟馗之眼 搜索工具 基于API的更多相关文章
- ZoomEye(钟馗之眼)搜索技巧记录:
做个记录方便查看 钟馗之眼: 指定搜索的组件: app:组件名称 ver:组件版本 例:搜索 apache组件版本2.4:app:apache var:2.4指定搜素的端口: ...
- 基于文本图形(ncurses)的文本搜索工具 ncgrep
背景 作为一个VIM党,日常工作开发中,会经常利用grep进行关键词搜索,以快速定位到文件.如图: 利用grep进行文本搜索 但是,这一过程会有两个效率问题: 展示的结果无法进行直接交互,需要手动粘贴 ...
- 揭开Faiss的面纱 探究Facebook相似性搜索工具的原理
https://www.leiphone.com/news/201703/84gDbSOgJcxiC3DW.html 本月初雷锋网报道,Facebook 开源了 AI 相似性搜索工具 Faiss.而在 ...
- 文件快速搜索工具-Everything的使用(转)
首先它是一款基于名称实时定位文件和目录的搜索工具,有以下几个优点: 快速文件索引 快速文件搜索 较低资源占用 轻松分享文件索引 实时跟踪文件更新 通过使用everything小工具,可以提高我们的工作 ...
- Everything:速度最快的文件名搜索工具(Linux版本) 转
Everything是windows的一个快速搜索工具. 基本上转移到Linux上来后,没有怎么用过. 一直在用Gnome-Do,感觉还可以. 这个程序只是用来练习wxPython用的,目前还只是一个 ...
- 文件搜索工具everything
Everything是voidtools开发的一款文件搜索工具,官网描述为“基于名称实时定位文件和目录(Locate files and folders by name instantly) (“Ev ...
- Python开发环境Wing IDE搜索工具介绍
Wing IDE编辑器的搜索工具提供了一个基于友好GUI的搜索和替换工具. 某些情况下搜索可能会跨越整个文件,也有可能被限制到当前所选择的区域:可以区分大小写,也可以设置为不区分:可以被限制为只匹配整 ...
- [转帖]推荐一款比 Find 快 10 倍的搜索工具 FD
推荐一款比 Find 快 10 倍的搜索工具 FD https://www.hi-linux.com/posts/15017.html 试了下 很好用呢. Posted by Mike on 2018 ...
- centos locate搜索工具
locate搜索工具 [root@localhost ~]# yum install mlocate [root@localhost ~]# locate passwd locate: can not ...
随机推荐
- HDU 2087 字符串
#include <stdio.h> #include <string.h> void main() { ) { ] = {'\0'}; ] = {'\0'}; ; scanf ...
- The current identity (NT AUTHORITY/NETWORK SERVICE)
IIS错误提示: The current identity (NT AUTHORITY/NETWORK SERVICE) does not have write access to 'C:/WINDO ...
- nginx tomcat session丢失的问题
nginx反向代理tomcat,出现seesion获取不到的问题. 网上搜索到的解决方案大多是集群tomcat共享session共享的问题,但我这个只有一台tomcat服务器,不涉及到服务器集群问题. ...
- Linux下Python 文件内容替换脚本
Linux下Python 文件替换脚本 import sys,os if len(sys.argv)<=4: old_text,new_text = sys.argv[1],sys.argv[2 ...
- 关于Spring的核心组件以及概念
1.什么是企业级应用 大型企业级应用的结构是非常复杂的,涉及外部资源非常多,事务密集,数据规模大,用户数量多,有较强的安全性考虑和较高的性能要求. 2.Spring概念理解 Spring是一个轻量 ...
- Autoit3 获取WinForm下的ToolTip
相比Autohotkey,在我看来,Autoit最实用的就是对于WinForm Application的良好支持 然而,要想将鼠标放在WinForm的ToolTip上,简直无异于自己把自己举起来,故而 ...
- spring data jpa分页
controller层 @RequestMapping(value="/search") @ResponseBody public String search(HttpServle ...
- 完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法
完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法 HTML5的语义化标签以及属性,可以让开发者非常方便地实现清晰的web页面布局,加上CSS3的效果渲染,快速建立丰富灵活的web页 ...
- 适配ios9出现的问题:-canOpenURL: failed for URL
-canOpenURL: failed for URL: "wtloginmqq2://qzapp" - error: "(null)" 2015-09-13 ...
- dell md3200i mdss (企业管理) 安装的那点事儿
首先获取安装包,解压后如图: 我是在windows 机上安装,所以执行windows 文件夹下的可执行程序: 双击红箭头文件,进行安装,步骤截图如下: 出现最后这个界面,就说明安装成功,直接重启系统就 ...