import paramiko
import sys

# Konfigurasi VPS Alpha 
# Berdasarkan ssh_audit.py sebelumnya:
HOST = '160.187.143.253'
USER = 'root'
PASS = ';ur7n)LC1BQ;'

def run():
    print(f"[*] Menghubungkan ke VPS Alpha ({HOST})...")
    c = paramiko.SSHClient()
    c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    try:
        c.connect(HOST, username=USER, password=PASS, timeout=10)
    except Exception as e:
        print(f"[!] Gagal terhubung: {e}")
        sys.exit(1)
        
    print("[*] Terhubung! Mengeksekusi Injeksi Database (PKX Pasal 7b)...")
    
    # 1. Pindah ke direktori IAM dan eksekusi script
    # 2. Tangkap output untuk bukti forensik
    cmd = "cd /var/www/jumpa/iam && node seed_pkx_users.js"
    stdin, stdout, stderr = c.exec_command(cmd)
    
    out = stdout.read().decode('utf-8').strip()
    err = stderr.read().decode('utf-8').strip()
    
    if out:
        print("\n--- STDOUT ---")
        print(out)
    if err:
        print("\n--- STDERR ---")
        print(err)
        
    c.close()
    print("\n[*] Selesai.")

if __name__ == '__main__':
    run()
