Entry
X Gon' Give It To Ya
Entry task for crypto
MD5 (entry.zip) = 7c1ad8ac9871e3fa788c4ac977108833
Author: mechfrog88
We were given a Python file, with the FLAG
variable as grey{...}
Therefore, we figured that we have to get the flag with the Python file given!
import secrets
FLAG = b'grey{...}'
assert len(FLAG) == 40
key = secrets.token_bytes(4)
def encrypt(m):
return bytes([x ^ y for x, y in zip(m,key)])
c = b''
for i in range(0, len(FLAG), 4):
c += encrypt(bytes(FLAG[i : i + 4]))
print(c.hex())
# 982e47b0840b47a59c334facab3376a19a1b50ac861f43bdbc2e5bb98b3375a68d3046e8de7d03b4
There are a few things we took note of;
Key
Encrypt function
Flag
Hex output (commented out at the bottom of the code)
We were given the hex output, therefore we realized that we have to reverse the hex output in order to get the flag! π₯
The key
variable tells us that the secret key is 4 bytes long.
Given the FLAG
variable, we know that "grey" is the the first 4 characters.
The first 4 bytes of the hex output is 98 2e 47 b0
Encrypt function showed x ^ y
at the return statement, therefore, it is doing an XOR operation.
Given the information above, we deduced that x ^ y
equals to grey ^ 982e47b0
Using a online XOR calculator, we got ff5c22c9
.
We will take note of ff5c22c9
as that is our secret key to solve this challenge!

What we did next was simply just reverse the whole operation using the Secret Key that we managed to figure out and Hex output that was given to us!
import secrets
FLAG = bytes.fromhex('982e47b0840b47a59c334facab3376a19a1b50ac861f43bdbc2e5bb98b3375a68d3046e8de7d03b4')
key = bytes.fromhex('ff5c22c9')
def encrypt(m):
return bytes([x ^ y for x, y in zip(m,key)])
c = b''
for i in range(0, len(FLAG), 4):
print(c)
c += encrypt(bytes(FLAG[i : i + 4]))
print(c)
Flag: grey{WelcomeToTheGreyCatCryptoWorld!!!!}
Also did anyone noticed that XOR sounds like the song from Deadpool? No? Alright π

Last updated