Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
新增用法提示,增加对ctrl+c退出输入的处理,改善输入为空时的处理,新增对quake.py变量“查询数量”值的检测
  • Loading branch information
shadowabi authored Dec 8, 2021
1 parent 2871247 commit 3d026d0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
17 changes: 14 additions & 3 deletions api/fofa.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from urllib.parse import quote
from config.data import logging,Urls,Ips
from config.config import Fofa_key,Fofa_email,Fofa_Size,user_agents
import readline


class Fofa:
def __init__(self):
Expand All @@ -23,8 +25,18 @@ def __init__(self):
ip = "ip={}".format(ip)
self.run(ip)
else:
keyword = input("请输入查询关键词:").strip()
self.run(keyword)
try:
logging.info("[FOFA Example]domain=example.com\n")
while 1:
keyword = input("请输入查询关键词:").strip()
if keyword == "":
logging.error("\n关键字不能为空!")
else:
break
self.run(keyword)
except KeyboardInterrupt:
logging.error("\n用户取消输入!直接退出。")
exit(0)
else:
logging.error("fofa api不可用,请检查配置是否正确!")

Expand All @@ -49,7 +61,6 @@ def run(self,keyword):
if _url:
logging.info(_url)
Urls.url.append(_url)

except requests.exceptions.ReadTimeout:
logging.error("请求超时")
except requests.exceptions.ConnectionError:
Expand Down
32 changes: 23 additions & 9 deletions api/quake.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import requests
from config.data import Urls, logging
from config.config import QuakeKey, user_agents
import readline



class Quake:
Expand All @@ -17,21 +19,32 @@ def __init__(self):
if QuakeKey == "":
logging.warning("请先在config/config.py文件中配置quake的api")
exit(0)
self.keywords = input("请输入查询关键词:").strip()
self.size = input("请输入查询数量:").strip()
if self.keywords == "" or self.size == "":
logging.warning("查询关键词或者查询数量不能为空")

try:
logging.info("[QUAKE Example]domain:example.com\n")
while 1:
self.keywords = input("请输入查询关键词:").strip()
self.size = input("请输入查询数量:").strip()
if self.keywords == "" or self.size == "":
logging.error("\n关键字或查询数量不能为空!")
elif self.size.isdigit() != True:
logging.error("\n查询数量非整数!")
else:
break
self.run()
except KeyboardInterrupt:
logging.error("\n用户取消输入!直接退出。")
exit(0)


def run(self):
logging.info("正在使用使用360 Quake进行资产收集。。。")
logging.info("查询关键词为:{0},查询数量为:{1}".format(self.keywords, self.size))
self.data = {
"query": self.keywords,
"start": 0,
"size": self.size
}
logging.info("正在使用使用360 Quake进行资产收集。。。")
logging.info("查询关键词为:{0},查询数量为:{1}".format(self.keywords, self.size))
self.run()

def run(self):
try:
response = requests.post(url="https://quake.360.cn/api/v3/search/quake_service", headers=self.headers,
json=self.data, timeout=10)
Expand All @@ -48,4 +61,5 @@ def run(self):
logging.info(url)
Urls.url.append(url)
except Exception as e:
logging.error("获取失败")
pass

0 comments on commit 3d026d0

Please sign in to comment.