
These scripts start one another, as a workaround for systemd , corestarter and Termux boot go hand in hand to make script run all the time in background scrips works by spawning one another sequentially corestarter -> initProcess -> goLive ->initRVP
53 lines
1.6 KiB
Bash
53 lines
1.6 KiB
Bash
|
|
# Set the target host and port
|
|
TARGET_HOST="androidnasserver1"
|
|
TARGET_PORT="22"
|
|
LOCAL_PORT="8022"
|
|
SERVEO_DOMAIN="serveo.net"
|
|
|
|
# Counter to track the number of times the code block is executed
|
|
counter=0
|
|
|
|
# Maximum number of allowed executions
|
|
max_executions=6
|
|
|
|
# Define your code block here
|
|
initReversePortForwarding() {
|
|
echo "Executing code block..."
|
|
# Check if reverse port forwarding is already active, then kill the active reverse port forwarding
|
|
EXISTING_SSH_PID=$(pgrep -f "ssh -R $TARGET_HOST:$TARGET_PORT:127.0.0.1:$LOCAL_PORT $SERVEO_DOMAIN")
|
|
echo $EXISTING_SSH_PID
|
|
|
|
if [ $counter -lt $max_executions ]; then
|
|
|
|
kill "$EXISTING_SSH_PID"
|
|
|
|
fi
|
|
|
|
if ! [ -n "$EXISTING_SSH_PID" ]; then
|
|
# Start reverse port forwarding in the background
|
|
ssh -R $TARGET_HOST:$TARGET_PORT:127.0.0.1:$LOCAL_PORT $SERVEO_DOMAIN > /data/data/com.termux/files/home/.cronlog/cronlog.txt 2>&1 &
|
|
echo "[+] Reverse port forwarding started."
|
|
fi
|
|
}
|
|
|
|
# Run the code block inside an if statement
|
|
while [ $counter -lt $max_executions ]; do
|
|
# Increment the counter before each execution
|
|
((counter++))
|
|
|
|
# Run the code block
|
|
if initReversePortForwarding; then
|
|
echo "[*] Reverse Port Forwarding process started and killed: $counter times"
|
|
|
|
else
|
|
echo "[-] Encountered error while running initReversePortForwarding() code block."
|
|
fi
|
|
|
|
# Add a delay or other logic if needed
|
|
sleep 2
|
|
done
|
|
|
|
echo -e "[+] Reverse Port Forwarding started successfully at $max_executionsth time.,\n[+] Android NAS server Gone Live to world!"
|
|
|