add hostssave
This commit is contained in:
@@ -6,6 +6,7 @@ import requests
|
||||
|
||||
from Config.config_decorators import Save_Csv
|
||||
from Config.config_api import FOFA_EAMIL, FOFA_API_KEY
|
||||
from Tools.SaveHosts import gethosts
|
||||
|
||||
|
||||
def fofaapi(keyword,num):
|
||||
@@ -15,7 +16,7 @@ def fofaapi(keyword,num):
|
||||
bs64 = bs64.decode()
|
||||
res = requests.get('https://fofa.info/api/v1/search/all?email={}&key={}&qbase64={}&fields=host,ip,port,country,city,server,title&size={}'.format(FOFA_EAMIL,FOFA_API_KEY,bs64,str(num)))
|
||||
result = res.json()['results']
|
||||
# print(result)
|
||||
hosts=[]
|
||||
for i in result:
|
||||
dic={}
|
||||
dic['host'] = i[0]
|
||||
@@ -27,6 +28,7 @@ def fofaapi(keyword,num):
|
||||
dic['title'] = i[6]
|
||||
reslist.append(dic)
|
||||
print(dic)
|
||||
gethosts(hosts)
|
||||
return reslist
|
||||
|
||||
@Save_Csv
|
||||
|
||||
27
Tools/SaveHosts.py
Normal file
27
Tools/SaveHosts.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
# _*_ coding:utf-8 _*_
|
||||
'''
|
||||
____ _ _ _ _ __ __ _
|
||||
| _ \ __ _| |__ | |__ (_) |_| \/ | __ _ ___| | __
|
||||
| |_) / _` | '_ \| '_ \| | __| |\/| |/ _` / __| |/ /
|
||||
| _ < (_| | |_) | |_) | | |_| | | | (_| \__ \ <
|
||||
|_| \_\__,_|_.__/|_.__/|_|\__|_| |_|\__,_|___/_|\_\
|
||||
|
||||
'''
|
||||
import datetime
|
||||
|
||||
from Config.config_print import status_print
|
||||
|
||||
|
||||
def gethosts(result):
|
||||
if result:
|
||||
timetoken = datetime.datetime.now().strftime('%Y%m%d%H%M%S');
|
||||
filename = 'Output/{}_result_{}.txt'.format('run', timetoken)
|
||||
for i in result:
|
||||
try:
|
||||
fw = open(filename, 'a')
|
||||
fw.write(i.replace('\n', '') + '\n')
|
||||
fw.close()
|
||||
except:
|
||||
pass
|
||||
status_print('HOST结果已保存至:' + filename, 1)
|
||||
Reference in New Issue
Block a user