Skip to content

Commit

Permalink
更新v1.2.1(支持linux)
Browse files Browse the repository at this point in the history
  • Loading branch information
baihengaead committed Aug 28, 2024
1 parent 5f3175d commit 95fb98a
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 76 deletions.
73 changes: 69 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## 项目介绍

wifi_crack_tool是一款基于Python开发的拥有图形界面的WiFi密码暴力破解工具,使用本项目应遵循[MIT许可](https://github.com/baihengaead/wifi-crack-tool/blob/main/LICENSE),可使用自定义密码本,且拥有自动保存破解成功后的WiFi SSID与密码到本地密码字典、在有多个无线网卡的情况下可以多开工具并行破解同一个或不同的WiFi。
wifi_crack_tool是一款基于Python开发的拥有图形界面的WiFi密码暴力破解工具,支持多平台,使用本项目应遵循[MIT许可](https://github.com/baihengaead/wifi-crack-tool/blob/main/LICENSE),可使用自定义密码本,且拥有自动保存破解成功后的WiFi SSID与密码到本地密码字典、在有多个无线网卡的情况下可以多开工具并行破解同一个或不同的WiFi。

支持 WPA、WPAPSK、WPA2、WPA2PSK 安全协议

Expand Down Expand Up @@ -131,9 +131,11 @@ pywifi、pyside6

## 系统要求

Windows 10
- Windows 10 及以上
- Ubuntu 22.04 及以上版本
- 其它支持 Python 3.11.x 以上的Linux系统

Tips:理论支持Win10、Win11、Linux、MacOS(Linux 与 macOS 暂未测试,可自行尝试构建)
Tips:理论支持Win10、Win11、Linux、MacOS(MacOS 暂未测试,可自行尝试构建)

## 如何修改GUI

Expand All @@ -153,6 +155,8 @@ Tips:理论支持Win10、Win11、Linux、MacOS(Linux 与 macOS 暂未测试

## 如何运行以及打包

### Windows

1. [下载 Python 3.11.9](https://www.python.org/downloads/release/python-3119/) 并安装
2. 安装所需模块

Expand All @@ -172,11 +176,72 @@ Tips:理论支持Win10、Win11、Linux、MacOS(Linux 与 macOS 暂未测试
5. 打包 wifi_crack_tool.py

```cmd
pyinstaller -F -w WifiCrackTool.py
pyinstaller -F -w wifi_crack_tool.py
```

### Linux(以 Ubuntu 24.04 为例)

1. 更新软件包

```shell
sudo apt update
sudo apt upgrade
```

2. 安装QT GUI依赖库

```shell
sudo apt install libxcb-cursor0
```

3. 安装python3虚拟环境库

```shell
sudo apt install python3-venv
```

4. 创建python3虚拟环境

```shell
python3 -m venv wifi-crack-tool-venv
```

5. 激活python3虚拟环境

```shell
source wifi-crack-tool-venv/bin/activate
```

6. 安装所需模块(Linux需要将 requirements.txt 中的 `pywin32>=306` 删除)

```shell
pip3 install -r requirements.txt
```

7. 编译 wifi_crack_tool_gui.ui

```shell
pyside6-uic wifi_crack_tool_gui.ui -o wifi_crack_tool_gui.py
```

8. 编译运行 wifi_crack_tool.py

```shell
python3 -u wifi_crack_tool.py
```

9. 打包 wifi_crack_tool.py

```shell
pyinstaller -F -w wifi_crack_tool.py
```

## 更新日志

### v1.2.1

- **[优化]** 对Linux平台支持。

### v1.2.0

- **[新增]** 对扫描到的所有WiFi进行**自动破解**。([#10](https://github.com/baihengaead/wifi-crack-tool/issues/10))
Expand Down
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pywin32>=306
pywifi>=1.1.12
pyperclip>=1.9.0
PySide6>=6.7.2
pyinstaller>=6.9.0
pyperclip>=1.9.0
comtypes>=1.4.4
typing
pyinstaller>=6.9.0
pywin32>=306
92 changes: 64 additions & 28 deletions wifi_crack_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
Version: 1.2.0
"""
import os,sys,datetime,time,threading,ctypes,json
from typing import Any
import win32api,win32security,win32event # type: ignore
import platform

import pywifi
from pywifi import const
Expand All @@ -32,7 +31,7 @@ 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.2.0', message='应用程序的另一个实例已经在运行。')
self.showinfo(title='WiFi\u5bc6\u7801\u66b4\u529b\u7834\u89e3\u5de5\u5177v1.2.1', message='应用程序的另一个实例已经在运行。')
sys.exit()

icon = QIcon()
Expand Down Expand Up @@ -201,7 +200,7 @@ def __init__(self,win:MainWindow):
os.mkdir(self.dict_dir_path)

self.config_file_path = self.config_dir_path+'/settings.json'
self.config_settings_data:dict[str,Any] = {
self.config_settings_data = {
'scan_time':8,
'connect_time':3,
'pwd_txt_path':'passwords.txt'
Expand Down Expand Up @@ -584,29 +583,63 @@ def connect(self,ssid,pwd,filetype,count):
return False

if __name__ == "__main__":

#------------------- 互斥锁 -----------------------#
MUTEX_NAME = "Global/wifi_crack_tool_mutex"

def acquire_mutex():
sa = win32security.SECURITY_ATTRIBUTES()
sa.bInheritHandle = False # 确保互斥量句柄不会被继承
mutex = win32event.CreateMutex(sa, False, MUTEX_NAME)
last_error = win32api.GetLastError()
if last_error == 183:
return None
elif last_error != 0:
raise ctypes.WinError(last_error)
return mutex
#==================================================#

try:
mutex = None
if pywifi.PyWiFi().interfaces().__len__() <= 1:
mutex = acquire_mutex()

app = QApplication(sys.argv)
window = MainWindow(mutex)

system = platform.system()
if system == 'Windows':
print('当前系统是 Windows')
import win32api,win32security,win32event # type: ignore
#------------------- 互斥锁 -----------------------#
MUTEX_NAME = "Global/wifi_crack_tool_mutex"
def acquire_mutex():
sa = win32security.SECURITY_ATTRIBUTES()
sa.bInheritHandle = False # 确保互斥量句柄不会被继承
mutex = win32event.CreateMutex(sa, False, MUTEX_NAME)
last_error = win32api.GetLastError()
if last_error == 183:
return None
elif last_error != 0:
raise ctypes.WinError(last_error)
return mutex
#==================================================#

__mutex = None
if pywifi.PyWiFi().interfaces().__len__() <= 1:
__mutex = acquire_mutex()

window = MainWindow(__mutex)

elif system == 'Linux':
print('当前系统是 Linux')
import fcntl
#------------------- 互斥锁 -----------------------#
LOCKFILE = "/tmp/wifi_crack_tool.lock"
def acquire_lock():
lock = os.open(LOCKFILE, os.O_RDWR | os.O_CREAT)
try:
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) # type: ignore
return lock
except IOError:
return None

def release_lock(lock):
fcntl.flock(lock, fcntl.LOCK_UN) # type: ignore
os.close(lock)
os.remove(LOCKFILE)
#==================================================#

__lock = None
if pywifi.PyWiFi().interfaces().__len__() <= 1:
__lock = acquire_lock()

window = MainWindow(__lock)

elif system == 'Darwin': # macOS
print('当前系统是 macOS')
else:
print(f'当前系统是 {system}')

window.show()
app.exec()

Expand All @@ -617,6 +650,9 @@ def acquire_mutex():

sys.exit()
finally:
if 'mutex' in vars():
if mutex is not None:
win32api.CloseHandle(mutex)
if '__mutex' in vars():
if __mutex is not None:
win32api.CloseHandle(__mutex)
elif '__lock' in vars():
if __lock is not None:
release_lock(__lock)
36 changes: 18 additions & 18 deletions wifi_crack_tool_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.setWindowModality(Qt.WindowModality.WindowModal)
MainWindow.resize(500, 500)
MainWindow.resize(529, 500)
sizePolicy = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
MainWindow.setSizePolicy(sizePolicy)
MainWindow.setMinimumSize(QSize(500, 500))
MainWindow.setMaximumSize(QSize(500, 500))
MainWindow.setMaximumSize(QSize(529, 600))
icon = QIcon()
icon.addFile(u"images/wificrack.ico", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
MainWindow.setWindowIcon(icon)
Expand All @@ -40,13 +40,13 @@ def setupUi(self, MainWindow):
sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
self.centralwidget.setSizePolicy(sizePolicy)
self.centralwidget.setMinimumSize(QSize(0, 0))
self.centralwidget.setMaximumSize(QSize(500, 500))
self.centralwidget.setMaximumSize(QSize(529, 500))
self.lbl_wifi_name = QLabel(self.centralwidget)
self.lbl_wifi_name.setObjectName(u"lbl_wifi_name")
self.lbl_wifi_name.setGeometry(QRect(50, 10, 54, 20))
self.lbl_wifi_name.setGeometry(QRect(50, 10, 71, 20))
self.cbo_wifi_name = QComboBox(self.centralwidget)
self.cbo_wifi_name.setObjectName(u"cbo_wifi_name")
self.cbo_wifi_name.setGeometry(QRect(110, 10, 201, 22))
self.cbo_wifi_name.setGeometry(QRect(120, 10, 201, 22))
sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
sizePolicy1.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(0)
Expand All @@ -57,34 +57,34 @@ def setupUi(self, MainWindow):
self.cbo_wifi_name.setEditable(True)
self.lbl_security_type = QLabel(self.centralwidget)
self.lbl_security_type.setObjectName(u"lbl_security_type")
self.lbl_security_type.setGeometry(QRect(50, 40, 54, 20))
self.lbl_security_type.setGeometry(QRect(50, 40, 71, 20))
self.cbo_security_type = QComboBox(self.centralwidget)
self.cbo_security_type.setObjectName(u"cbo_security_type")
self.cbo_security_type.setGeometry(QRect(110, 40, 201, 22))
self.cbo_security_type.setGeometry(QRect(120, 40, 201, 22))
sizePolicy1.setHeightForWidth(self.cbo_security_type.sizePolicy().hasHeightForWidth())
self.cbo_security_type.setSizePolicy(sizePolicy1)
self.cbo_security_type.setMinimumSize(QSize(201, 22))
self.cbo_security_type.setMaximumSize(QSize(201, 22))
self.lbl_wnic = QLabel(self.centralwidget)
self.lbl_wnic.setObjectName(u"lbl_wnic")
self.lbl_wnic.setGeometry(QRect(50, 70, 54, 20))
self.lbl_wnic.setGeometry(QRect(50, 70, 71, 20))
self.cbo_wnic = QComboBox(self.centralwidget)
self.cbo_wnic.setObjectName(u"cbo_wnic")
self.cbo_wnic.setGeometry(QRect(110, 70, 343, 22))
self.cbo_wnic.setGeometry(QRect(120, 70, 352, 22))
sizePolicy1.setHeightForWidth(self.cbo_wnic.sizePolicy().hasHeightForWidth())
self.cbo_wnic.setSizePolicy(sizePolicy1)
self.cbo_wnic.setMinimumSize(QSize(201, 22))
self.cbo_wnic.setMaximumSize(QSize(343, 22))
self.cbo_wnic.setMaximumSize(QSize(352, 22))
self.lbl_using_pwd_file = QLabel(self.centralwidget)
self.lbl_using_pwd_file.setObjectName(u"lbl_using_pwd_file")
self.lbl_using_pwd_file.setGeometry(QRect(5, 100, 491, 16))
self.lbl_using_pwd_file.setGeometry(QRect(5, 100, 521, 16))
self.lbl_using_pwd_file.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.txt_log_msg_info = QTextEdit(self.centralwidget)
self.txt_log_msg_info.setObjectName(u"txt_log_msg_info")
self.txt_log_msg_info.setGeometry(QRect(0, 150, 499, 350))
self.txt_log_msg_info.setGeometry(QRect(0, 150, 529, 350))
self.splitter = QSplitter(self.centralwidget)
self.splitter.setObjectName(u"splitter")
self.splitter.setGeometry(QRect(80, 120, 331, 24))
self.splitter.setGeometry(QRect(100, 120, 331, 24))
self.splitter.setOrientation(Qt.Orientation.Horizontal)
self.btn_change_pwd_file = QPushButton(self.splitter)
self.btn_change_pwd_file.setObjectName(u"btn_change_pwd_file")
Expand All @@ -100,20 +100,20 @@ def setupUi(self, MainWindow):
self.splitter.addWidget(self.btn_stop)
self.lbl_scan_time = QLabel(self.centralwidget)
self.lbl_scan_time.setObjectName(u"lbl_scan_time")
self.lbl_scan_time.setGeometry(QRect(320, 10, 71, 20))
self.lbl_scan_time.setGeometry(QRect(330, 10, 81, 20))
self.dbl_scan_time = QDoubleSpinBox(self.centralwidget)
self.dbl_scan_time.setObjectName(u"dbl_scan_time")
self.dbl_scan_time.setGeometry(QRect(390, 10, 62, 22))
self.dbl_scan_time.setGeometry(QRect(410, 10, 62, 22))
self.dbl_scan_time.setDecimals(1)
self.dbl_scan_time.setMinimum(0.100000000000000)
self.dbl_scan_time.setSingleStep(0.100000000000000)
self.dbl_scan_time.setValue(8.000000000000000)
self.lbl_connect_time = QLabel(self.centralwidget)
self.lbl_connect_time.setObjectName(u"lbl_connect_time")
self.lbl_connect_time.setGeometry(QRect(320, 40, 71, 20))
self.lbl_connect_time.setGeometry(QRect(330, 40, 81, 20))
self.dbl_connect_time = QDoubleSpinBox(self.centralwidget)
self.dbl_connect_time.setObjectName(u"dbl_connect_time")
self.dbl_connect_time.setGeometry(QRect(390, 40, 62, 22))
self.dbl_connect_time.setGeometry(QRect(410, 40, 62, 22))
self.dbl_connect_time.setDecimals(1)
self.dbl_connect_time.setMinimum(0.100000000000000)
self.dbl_connect_time.setSingleStep(0.100000000000000)
Expand All @@ -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.2.0 by \u767d\u6052aead", None))
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"WiFi\u5bc6\u7801\u66b4\u529b\u7834\u89e3\u5de5\u5177v1.2.1 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
Loading

0 comments on commit 95fb98a

Please sign in to comment.