#!/usr/bin/env python3
import paramiko

HOST = "135.125.102.180"
USER = "ubuntu"
PASS = "BotPascal2026!"

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(HOST, username=USER, password=PASS)

print("🛑 Stopping all scan processes...")

# Kill scan.php processes
stdin, stdout, stderr = ssh.exec_command("pkill -f 'php.*scan.php' || true")
out = stdout.read().decode()
print("Stopped scan.php processes")

# Kill scan_loop.php processes
stdin2, stdout2, stderr2 = ssh.exec_command("pkill -f 'php.*scan_loop.php' || true")
out2 = stdout2.read().decode()
print("Stopped scan_loop.php processes")

# Check remaining processes
print("\n📊 Checking remaining PHP processes...")
stdin3, stdout3, stderr3 = ssh.exec_command("ps aux | grep php | grep -v grep")
processes = stdout3.read().decode()
if processes.strip():
    print(processes)
else:
    print("✅ No PHP processes running")

ssh.close()
print("\n✅ All scan processes stopped!")
