Misc

Tbh I didn't know where to put this challenge, it isn't really crypto soooo here we are

Magic Keys

We're given a file called messed_up.jpg and the following script

from pwn import xor

with open("MagicKeys/flag.jpg", "rb") as f:
    img = f.read()

key = img[:12]
flag = xor(img, key)
with open("MagicKeys/messed_up.jpg", "wb") as f:
    f.write(flag)

let's ask ChatGPT about what this script does...

Fair enough, now what could those 12 bytes be? LETS ASK CHATGPT AGAIN

Okayy the jpg signature hmmmm, after some web surfing we find that the jpg signature is:FF D8 FF E0 00 10 4A 46 49 46 00 01

This is our Key!

Now with our XOR properties knowledge, we find that we can just XOR the messed_up.jpg file with the signature and we'll have restored our flag image.

from pwn import xor
key = [0xFF, 0xD8 ,0xFF ,0xE0 ,0x00 ,0x10 ,0x4A ,0x46 ,0x49 ,0x46 ,0x00, 0x01]

with open("messed_up.jpg", "rb") as f:
    img = f.read()

flag = xor(img, key)
with open("flag.jpg", "wb") as f:
    f.write(flag)

running this script gives us this beautiful picture of the great pyramids of Giza:

Last updated