Upload files to "/"

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
This commit is contained in:
arul 2024-06-02 20:43:30 +00:00
commit 3d2fbeb725
4 changed files with 109 additions and 0 deletions

12
coreStarter.sh Normal file
View File

@ -0,0 +1,12 @@
# Your script logic goes here
bash /data/data/com.termux/files/home/.custmScrpt/initProcess.sh
# Save the script path
script_path=$(readlink -f "$0")
# Sleep for 5 seconds and then execute the script again
(sleep 300 && exec "$script_path") &

19
goLive.sh Normal file
View File

@ -0,0 +1,19 @@
if termux-wifi-connectioninfo | grep -q '"network_id": -1,'; then
echo "[-] NAS Server is OFFLINE...waiting for Internet Source"
pkill sshd
else
echo "[+] NAS Server is Online and Active :)"
#start SSH server Daemon
sshd
sleep 5
echo "[+] ssh server initiated, ssh server is up at Local Network"
bash /data/data/com.termux/files/home/.custmScrpt/initRVP.sh
bash /data/data/com.termux/files/home/.custmScrpt/initMySpace.sh
fi

26
initProcess.sh Normal file
View File

@ -0,0 +1,26 @@
# Count the number of devices connected via ssh on port 8022
netstatcount=$(netstat | grep ':8022' | grep 'ESTABLISHED' | wc -l)
tempcount=$((netstatcount - netstatcount / 2))
actualcount=$((tempcount - 1))
# Use that count to decide the process flow
if [ $tempcount -eq 0 ]; then
#starts Reverse Port Forwarding when 0 devices where connected every 10 min once
if [ $actualcount -eq -1 ]; then
bash /data/data/com.termux/files/home/.custmScrpt/goLive.sh
fi
fi
# Create logs
log1=$(netstat | grep ':8022')
log2=$(date)
log3=$(date +"%Y%m%d_%H%M%S")
concatenatedLog="$log1 and $log2"
# Save the logs to a file
mkdir -p ~/.ssh_logs # Create the directory if it doesn't exist
echo "$concatenatedLog" > ~/.ssh_logs/"$log3".txt

52
initRVP.sh Normal file
View File

@ -0,0 +1,52 @@
# 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!"