1. 程式人生 > 其它 >利用撒旦搜尋引擎查詢ip個數,批量下載ip

利用撒旦搜尋引擎查詢ip個數,批量下載ip

 

     利用撒旦搜尋引擎查詢ip個數,批量下載ip,使用語言python3.x

  批量測試時,為了方便直接擼下ip,所以用python寫了個GUI撒旦利用工具,寫的不是很好,但能用,最下面有下載。

    

 

 

from tkinter import *
import threading
import shodan
root=Tk()

screenwidth = root.winfo_screenwidth()
screenheight = root.winfo_screenheight()
size = '%dx%d+%d+%d' % (300, 400, (screenwidth-300)/ 2, (screenheight-400) / 2)
root.geometry(size)
root.title('撒旦GUI')
root.resizable(width=False, height=False)

title=Label(root,text='python3 撒旦利用GUI',font="16")
title.pack()
api=Label(root,text='輸入API',width=12)
api_input=Entry(root,width=20)
api.place(x=30,y=40)
api_input.place(x=140,y=40)
search=Label(root,text='請輸入查詢語句',width=12)
search_input=Entry(root,width=20)
search.place(x=30,y=80)
search_input.place(x=140,y=80)
#檔名輸入
txt_name_input=Entry(root)
txt_name_input.place(x=180,y=120,width=60,height = 30)
txt_txt = Label(root,text='.txt',font="10")
txt_txt.place(x=240,y=125)
#輸出框
show_1 = Entry(root)
show_1.place(x=20, y=160, width=250, height=200)



def false():
    show_1.insert("1","請檢查API、網路狀態、關鍵字")
def ip_number():
    show_1.delete(0, END)
    show_1.insert("1", "正在查詢")
    try:
        api_s = shodan.Shodan(api_input.get())
        results = api_s.search(search_input.get()) #如果修改搜尋的內容請注意符號
        ips = results['total']  #ip個數
        ips_str = "ip個數為   "+str(ips)
        show_1.delete(0, END)
        show_1.insert(1,ips_str)
    except shodan.APIError as e:
        false()

def ip_download():
    show_1.delete(0,END)
    show_1.insert("1", "正在下載")

    txt_name =txt_name_input.get()+".txt"
    f = open(txt_name, 'a+')
    try:
        api_s = shodan.Shodan(api_input.get())
        results = api_s.search(search_input.get())
        show_1.insert(1, "正在下載ip:埠. . . . . . ")
        for result in results['matches']:
            url = result['ip_str'] + ":" + str(result['port'])
            f.write(url)    #f.write("http://" + url)
            f.write("\n")
        f.close()
        show_1.delete(0, END)
        show_1.insert(1,"ip收集完畢      T0.0T")
    except shodan.APIError as e:
        false()

def T_ip_number():
    T = threading.Thread(target=ip_number)
    T.start()

def T_ip_download():
    T = threading.Thread(target=ip_download)
    T.start()

B_ip=Button(root,text="獲取ip個數",width=10,relief=GROOVE,command=T_ip_number)
B_ip.place(x=20,y=120)
B_txt=Button(root,text="下載到txt",width=10,relief=GROOVE,command=T_ip_download)
B_txt.place(x=100,y=120)

root.mainloop()

  

py下載  https://wwn.lanzout.com/iRkPs02f2jkj

exe下載  https://wwn.lanzout.com/iaktF02f2i9c  密碼    6vdu