-
-
Save kkrypt0nn/b59f814cc800a402ab510a693efcda6c to your computer and use it in GitHub Desktop.
Solution for challenge Weak Rivest 4 at the Insomni'hack 2022 CTF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
pt1 = "495F646F5F6E6F745F6C696B655F706F6E696573" | |
ct1 = "D058DECB037A10916E9D8B0E5345BB381AE8D8EE" | |
ct2 = "D049E9DF182420AB5EC6BD101229940517B59CE0" | |
flag = "" | |
for i in range(0, len(ct1) - 1, 2): | |
ct1_pair = int("0x" + ct1[i:i+2], 16) # Get two characters from ct1 | |
ct2_pair = int("0x" + ct2[i:i+2], 16) # Get two characters from ct2 | |
result = ct1_pair ^ ct2_pair | |
for k in range (0x0, 0x7f): # Loop over all characters in the ASCII table | |
if (int("0x" + pt1[i:i+2], 16) ^ k) == result: # Check if the XORed number is the same as the result | |
flag += chr(k) | |
print(flag, end="\r") | |
time.sleep(0.5) # That is just to look cool 😎 | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment