Skip to content

Instantly share code, notes, and snippets.

@kkrypt0nn

kkrypt0nn/r4c.py Secret

Created March 28, 2022 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkrypt0nn/b59f814cc800a402ab510a693efcda6c to your computer and use it in GitHub Desktop.
Save kkrypt0nn/b59f814cc800a402ab510a693efcda6c to your computer and use it in GitHub Desktop.
Solution for challenge Weak Rivest 4 at the Insomni'hack 2022 CTF
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