feat: add timer

Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@dextradata.com>
This commit is contained in:
Tuan-Dat Tran
2026-03-21 13:23:39 +01:00
parent c2ca69f2eb
commit 3a3a5587ca
4 changed files with 113 additions and 21 deletions

View File

@@ -1,6 +1,7 @@
import math
import re
import socket
import time
HOST = "challenge01.root-me.org"
@@ -22,7 +23,9 @@ def solve_prompt(prompt: str) -> str:
def main() -> None:
with socket.create_connection((HOST, PORT), timeout=2) as conn:
conn = socket.create_connection((HOST, PORT), timeout=2)
start_time = time.monotonic()
try:
prompt = conn.recv(4096).decode(errors="replace")
print(prompt, end="")
@@ -31,6 +34,10 @@ def main() -> None:
result = conn.recv(4096).decode(errors="replace")
print(result, end="")
finally:
conn.close()
elapsed = time.monotonic() - start_time
print(f"\nConnection lifetime: {elapsed:.3f}s")
if __name__ == "__main__":