Enhanced long_press.sh script for better control and monitoring

- Added debug mode activation to assist in troubleshooting.
- Set the PATH variable explicitly for script robustness.
- Adjusted wake-on-LAN delay to 10 seconds for system stability.
- Implemented function to check and terminate autoboot_win.sh process on the remote device.
- Introduced loop with a 2-minute duration to monitor the status of autoboot_win.sh and handle its termination.
- Included logic to transfer handshakes and initiate crack_handshakes.sh upon successful termination of autoboot_win.sh.
- Provided error handling for cases where autoboot_win.sh cannot be terminated successfully.
This commit is contained in:
Ratatoskr 2024-06-14 20:34:36 +02:00
parent cafe58aecf
commit 111d73273a

View File

@ -1,17 +1,76 @@
#!/bin/bash #!/bin/bash
# Aktiviert das Debugging
set -x
# Pfadvariable setzen
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# # Reboot to Linux
# if ping -c 3 192.168.178.80 > /dev/null; then
# /usr/bin/ssh -i /root/.ssh/windows -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null Ratatoskr@192.168.178.80 "shutdown /r /t 0"
# fi
# Boot Linux # Boot Linux
etherwake 70:85:c2:d1:40:ef etherwake 70:85:c2:d1:40:ef
while ! ssh root@192.168.178.80 "pkill autoboot_win.sh"; do # kill autoboot_win script, to stay at Linux # Wartezeit nach dem Wake-on-LAN (z.B. 10 Sekunden)
echo "warte 1 sec." echo "Warte 10 Sekunden, damit das System vollständig hochfährt..."
sleep 1 sleep 10
# Startzeit der Schleife speichern
start_time=$(date +%s)
# Zeitdauer in Sekunden, für die die Schleife laufen soll (2 Minuten)
duration=120
# Funktion, um Prozess auf dem Remote-Gerät zu überprüfen
check_autoboot_status() {
/usr/bin/ssh -i /root/.ssh/id_rsa root@192.168.178.80 '
if pgrep -a autoboot_win.sh >/dev/null; then
echo "running"
pkill -f autoboot_win.sh
else
echo "not_running"
fi
'
}
# Variable, um den Status des Beendens zu speichern
terminated_successfully=false
while true; do
# Prozessstatus auf dem Remote-Gerät überprüfen
status=$(check_autoboot_status)
if [ "$status" = "not_running" ]; then
echo "autoboot_win.sh ist nicht mehr aktiv."
terminated_successfully=true
break
else
echo "autoboot_win.sh läuft noch."
fi
# Aktuelle Zeit in Sekunden seit dem Epoch berechnen
current_time=$(date +%s)
# Überprüfen, ob die Zeitdauer überschritten wurde
if (( current_time - start_time >= duration )); then
echo "Zeitlimit von 2 Minuten erreicht. Beende die Schleife."
break
fi
echo "Warte 5 Sekunden..."
sleep 5
done done
# Wenn das Skript erfolgreich beendet wurde, Handshakes übertragen und cracking-Skript starten
if [ "$terminated_successfully" = true ]; then
echo "Übertrage Handshakes und starte crack_handshakes.sh"
scp -i /root/.ssh/id_rsa /root/handshakes/*.22000 root@192.168.178.80:/root/handshakes/
# transfer handshakes # Starte crack_handshakes.sh in einer tmux-Sitzung
scp /root/handshakes/*.22000 root@192.168.178.80:/root/handshakes/ /usr/bin/ssh -i /root/.ssh/id_rsa root@192.168.178.80 "tmux new-session -d -s crack_handshakes '/root/crack_handshakes.sh'"
else
# start crack_handshakes.sh echo "autoboot_win.sh konnte nicht beendet werden. Übertragung der Handshakes und Starten des cracking-Skripts wird übersprungen."
ssh root@192.168.178.80 "tmux new-session -d -s crack_handshakes '/root/crack_handshakes.sh'" fi