diff --git a/challenge.py b/challenge.py index 0c5fa5c..4a1c70f 100644 --- a/challenge.py +++ b/challenge.py @@ -1,4 +1,11 @@ -from intro import int_to_ascii, hex_to_ascii, hex_to_b64, int_to_message_rsa, xor_13 +from intro import ( + int_to_ascii, + hex_to_ascii, + hex_to_b64, + int_to_message_rsa, + xor_13, + unxor_flag, +) if __name__ == "__main__": # Intro-level challenge @@ -8,4 +15,9 @@ if __name__ == "__main__": print(hex_to_b64("72bca9b68fc16ac7beeb8f849dca1d8a783e8acf9679bf9269f7bf")) print(int_to_message_rsa(11515195063862318899931685488813747395775516287289682636499965282714637259206269)) print("crypto{{{}}}".format(xor_13("label"))) + print(unxor_flag(0xa6c8b6733c9b22de7bc0253266a3867df55acde8635e19c73313, + 0x37dcb292030faa90d07eec17e3b1c6d8daf94c35d4c9191a5e1e, + 0xc1545756687e7573db23aa1c3452a098b71a7fbf0fddddde5fc1, + 0x04ee9855208a2cd59091d04767ae47963170d1660df7f56f5faf + )) # fmt: on diff --git a/intro.py b/intro.py index 6012210..6875ce8 100644 --- a/intro.py +++ b/intro.py @@ -29,3 +29,14 @@ def int_to_message_rsa(input: int) -> str: # Challenge intro-5 def xor_13(input: str) -> str: return xor(input, 13).decode("utf-8") + + +# Challenge intro-6 +def unxor_flag( + key1: str, key2_key1: str, key2_key3: str, flag_key1_key3_key2: str +) -> str: + key_1 = int_to_message_rsa(key1) + key_2 = xor(int_to_message_rsa(key2_key1), key_1) + key_3 = xor(int_to_message_rsa(key2_key3), key_2) + flag = xor(xor(xor(int_to_message_rsa(flag_key1_key3_key2), key_1), key_2), key_3) + return flag.decode("utf-8")