fix chall itoid
This commit is contained in:
+32
-20
@@ -17,40 +17,52 @@ while True:
|
||||
print("2. bingo")
|
||||
print("3. decrypt")
|
||||
print("4. key?")
|
||||
inp = int(input("> "))
|
||||
try:
|
||||
inp = int(input("> "))
|
||||
except (ValueError, EOFError):
|
||||
print("Invalid input")
|
||||
continue
|
||||
|
||||
if inp == 1:
|
||||
print("pt (hex)")
|
||||
inp = input("> ")
|
||||
ct = cipher.encrypt(int(inp, 16))
|
||||
print('ct : ', '{0:x}'.format(ct))
|
||||
try:
|
||||
inp = input("> ")
|
||||
ct = cipher.encrypt(int(inp, 16))
|
||||
print('ct : ', '{0:x}'.format(ct))
|
||||
except (ValueError, EOFError):
|
||||
print("Invalid hex input")
|
||||
|
||||
elif inp == 2:
|
||||
print("key (hex)")
|
||||
user_hex = input("> ").strip()
|
||||
try:
|
||||
user_hex = input("> ").strip()
|
||||
user_key = bytes.fromhex(user_hex)
|
||||
except Exception:
|
||||
print("nope")
|
||||
continue
|
||||
|
||||
if len(user_key) == 66 and user_key == key:
|
||||
try:
|
||||
print(flag_bytes.decode())
|
||||
except Exception:
|
||||
print(flag_bytes.hex())
|
||||
else:
|
||||
|
||||
if len(user_key) == 66 and user_key == key:
|
||||
try:
|
||||
print(flag_bytes.decode())
|
||||
except Exception:
|
||||
print(flag_bytes.hex())
|
||||
else:
|
||||
print("nope")
|
||||
except (ValueError, EOFError):
|
||||
print("nope")
|
||||
|
||||
elif inp == 3:
|
||||
print("ct (hex)")
|
||||
inp = input("> ")
|
||||
pt = cipher.decrypt(int(inp, 16))
|
||||
print('pt : ', '{0:x}'.format(pt))
|
||||
try:
|
||||
inp = input("> ")
|
||||
pt = cipher.decrypt(int(inp, 16))
|
||||
print('pt : ', '{0:x}'.format(pt))
|
||||
except (ValueError, EOFError):
|
||||
print("Invalid hex input")
|
||||
|
||||
elif inp == 4:
|
||||
ct = cipher.encrypt(key_int)
|
||||
print('ct : ', '{0:x}'.format(ct))
|
||||
try:
|
||||
ct = cipher.encrypt(key_int)
|
||||
print('ct : ', '{0:x}'.format(ct))
|
||||
except Exception:
|
||||
print("Encryption error")
|
||||
|
||||
else:
|
||||
exit()
|
||||
|
||||
Reference in New Issue
Block a user