🔬
CTFs
  • 🚩nitrozeus's CTF Writeups
  • Tutorial
    • Install Windows 10 VM on M1 Mac
  • My Notes
    • Capture-The-Flag
      • Windows Forensics
      • Memory Forensics
      • Base32, Base64
      • Steganography
      • Email Analysis
      • Malware Analysis
      • MD4, MD5 Cracking
      • Social Engineering
      • OSINT
      • Google Dorking
      • Reconnaissance
      • Port Scan (nmap)
  • 2023
    • 🧠BrainHack CDDC 2023
      • Gallery
      • Eazy Network Analysis
      • What the hell happened to the PC?!
      • Audio Steganography
  • 2022
    • 🐱Grey Cat The Flag 2022
      • Parcel
      • Memory Game (Part 1)
      • Too Fast
      • Entry
      • Ghost
      • Firmware
      • Image Upload
      • flappy-js
    • ⛵STANDCON 2022
      • I Sea You (Part 1)
      • Locate Me
      • I Sea You (Part 2)
      • Trolley Trolling
      • A New Gateway
      • Walks like a cat, barks like a dog
      • Shark in the Ocean
      • Atlan Safe P1
      • Gift from Russia
      • Asmuth Shares
      • Memedump
      • Warmup Forensics
    • 🦁STACK the Flags 2022
      • Finding Nyan
      • New Task!
      • Hit you with that
      • Cobalt Struck
      • PyRunner
Powered by GitBook
On this page
  1. 2022
  2. Grey Cat The Flag 2022

Entry

X Gon' Give It To Ya

PreviousToo FastNextGhost

Last updated 2 years ago

Entry task for crypto

MD5 (entry.zip) = 7c1ad8ac9871e3fa788c4ac977108833

Author: mechfrog88

Take Note: For this challenge, you need to have a rough understanding of how operation works.

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;

  1. Key

  2. Encrypt function

  3. Flag

  4. Hex output (commented out at the bottom of the code)

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

Given the information above, we deduced that x ^ y equals to grey ^ 982e47b0

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!!!!}

We were given the hex output, therefore we realized that we have to reverse the hex output in order to get the flag!

Encrypt function showed x ^ y at the return statement, therefore, it is doing an operation.

Using a online XOR , we got ff5c22c9.

Also did anyone noticed that XOR sounds like the song from Deadpool? No? Alright

🐱
🔥
😞
bitwise
XOR
calculator
secret key!!
X Gon' Give It To Ya