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:
parent
cafe58aecf
commit
111d73273a
@ -1,17 +1,76 @@
|
||||
#!/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
|
||||
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
|
||||
echo "warte 1 sec."
|
||||
sleep 1
|
||||
# Wartezeit nach dem Wake-on-LAN (z.B. 10 Sekunden)
|
||||
echo "Warte 10 Sekunden, damit das System vollständig hochfährt..."
|
||||
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
|
||||
|
||||
# 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
|
||||
scp /root/handshakes/*.22000 root@192.168.178.80:/root/handshakes/
|
||||
|
||||
# start crack_handshakes.sh
|
||||
ssh root@192.168.178.80 "tmux new-session -d -s crack_handshakes '/root/crack_handshakes.sh'"
|
||||
|
||||
# Starte crack_handshakes.sh in einer tmux-Sitzung
|
||||
/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
|
||||
echo "autoboot_win.sh konnte nicht beendet werden. Übertragung der Handshakes und Starten des cracking-Skripts wird übersprungen."
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user