Files
ctf-notes/app-system/elf-x86-stack-buffer-overflow-basic-1/helper_recon.py
Tuan-Dat Tran 5cd3b5a531 feat: app system challenges
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@dextradata.com>
2026-03-23 09:19:03 +01:00

40 lines
1.1 KiB
Python

#!/usr/bin/env python3
import paramiko
HOST = "challenge02.root-me.org"
PORT = 2222
USER = "app-systeme-ch13"
PASSWORD = "app-systeme-ch13"
def run() -> None:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(
hostname=HOST, port=PORT, username=USER, password=PASSWORD, timeout=15
)
try:
commands = [
"pwd",
"ls -la",
"file ch13",
"checksec --file=ch13 || true",
"./ch13 <<<'AAAA'",
]
for cmd in commands:
stdin, stdout, stderr = client.exec_command(cmd)
out = stdout.read().decode("utf-8", errors="replace")
err = stderr.read().decode("utf-8", errors="replace")
print(f"--- $ {cmd} ---")
if out:
print(out, end="" if out.endswith("\n") else "\n")
if err:
print("[stderr]")
print(err, end="" if err.endswith("\n") else "\n")
finally:
client.close()
if __name__ == "__main__":
run()