feat: app system challenges
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@dextradata.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#!/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()
|
||||
Reference in New Issue
Block a user