FOFA-強大的網絡空間資產搜索引擎


昨天回去想想,感覺還不滿意,回去學習,改好了,哈哈,就是數據處理問題

數據處理在這里

 

哈哈,上優化代碼

 1 # #lanxing
 2 import os #獲取路徑
 3 
 4 import pyfofa   #fofa登錄庫
 5 import pandas as pd    #讀取csv表格庫
 6 import time   #時間庫
 7 import csv    #獲取到的list數據保存到csv處理庫
 8 start=time.time()
 9 def chax():
10     email = ''  #y郵箱
11     key = ''  #fofa個人key
12     search_fofa = input("請輸入你要搜索的特征 :")
13 # print(type(search_fofa))
14 # print(search_fofa)
15 # search_fofa = 'domain="baidu.com"'
16 
17     search = pyfofa.FofaAPI(email, key)
18     re_date = search.get_data(search_fofa, 1, "host,title,country_name,city,ip,port,server,protocol")['results']  #搜索請求,等到想要的數據
19 # print(re_date)
20     print(type(re_date))
21     print("*************************開始爬取url***************************")
22 # for host,title,city in search.get_data('app="TP_LINK-路由器"',1,"host,title,city")['results']:
23 #     print('標題:' + title, '城市:'+city, 'url :'+host)
24 
25     name = ['網站', 'Title','國家', '城市', 'ip地址', 'port','Server','協議']  #csv表格列
26     #test = pd.DataFrame(columns=name, data=re_date)
27     # print(test)
28     # test.to_csv('C:/Users/lanxing/Desktop/fofa_url.csv', encoding='utf-8')
29     print("*************************請稍等,正在爬取中**********************")
30     with open('fofa1_url.csv','w',encoding='utf-8',newline='') as f:   #寫入
31         writer = csv.writer(f)
32         writer.writerow(name)
33         writer.writerows(re_date)
34 
35 
36 
37 
38 
39     print("*************************爬取完成***************************")
40 
41 chax()
42 end=time.time()
43 sd=end-start   #end-start,程序運行所需時間
44 print("******************大佬,fofa信息查詢完畢!*************************")
45 lj = os.path.dirname(__file__) #獲取當前目錄
46 print('獲取到的數據保存在:'+lj + '目錄下面')
47 print('查詢耗時:',str(sd)+'s')   #Python 不允許直接把數字和字符拼接在一起(如果拼在一起就會報標題顯示的錯誤),把數字型的字符串,轉化為字符型就可以了,即str()就可以

 

運行狀態

 

 

 

效果圖

 

 

還不錯,有待優化,等我去學習一下,再優化,做一個簡易的GUI版本


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM