ucdavis-ecs189m

[RADIOACTIVE] python exploits for uc davis class ecs189m
git clone git://git.figbert.com/ucdavis-ecs189m.git
Log | Files | Refs

commit 61d11e1892cb90bbcc8f42d883a5cc7ee3e07156
parent f264a2e04eca9332b4df7c5aca9f729c4db5e532
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Thu, 10 Oct 2019 11:33:59 -0700

Simplifying passgen of third_flag.py

Diffstat:
Mthird_flag.py | 30+++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/third_flag.py b/third_flag.py @@ -18,33 +18,29 @@ def dec_to_str(num): st += char return st +def passgen(low: str, high: str) -> str: + return dec_to_str((str_to_dec(low)+str_to_dec(high))/2) + cracked = False attempt = 1 -LO26 = "aaaaaaaaaaaaaaaaaaaa" -HI26 = "zzzzzzzzzzzzzzzzzzzz" -LO10 = str_to_dec(LO26) -HI10 = str_to_dec(HI26) -MID10 = (LO10 + HI10)/2 -MID26 = dec_to_str(MID10) +LO = "aaaaaaaaaaaaaaaaaaaa" +HI = "zzzzzzzzzzzzzzzzzzzz" +password = passgen(LO, HI) conn = remote("twinpeaks.cs.ucdavis.edu", 30004) print(conn.recv()) while not cracked: - conn.sendline(MID26) - print("Attempt {}:\nPass sent as:\n{}\nCurrent low:\n{}\nCurrent high:\n{}\n".format(attempt, MID26, LO26, HI26)) + conn.sendline(password) + print("Attempt {}:\nPass sent as:\n{}\nCurrent low:\n{}\nCurrent high:\n{}\n".format(attempt, password, LO, HI)) attempt += 1 response = conn.recvline_contains(b"strcmp") print("Server response:\n{}\n".format(response)) if b" -1 " in response: - LO26 = MID26 - LO10 = str_to_dec(LO26) - MID10 = (LO10 + HI10)/2 - MID26 = dec_to_str(MID10) + LO = password + password = passgen(LO, HI) elif b" 1 " in response: - HI26 = MID26 - HI10 = str_to_dec(HI26) - MID10 = (LO10 + HI10)/2 - MID26 = dec_to_str(MID10) + HI = password + password = passgen(LO, HI) else: - print("Password cracked as: {}".format(MID26)) + print("Password cracked as: {}".format(password)) cracked = True conn.interactive() \ No newline at end of file