September 20, 2026
CyLab Security Acadmey โ bytemancy 2
Category: General Skills

By Aun Raza
2 min read
Difficulty: Medium
Author: LT Syreal Jones
Flag: picoCTF{3ff5_4_d4yz_c689238e}
Challenge Overview
In BYTEMANCY-2, we are given access to a remote service and a short Python source code file. The challenge description says:
"Can you conjure the right bytes?"
We are also told to connect to the program using netcat:
Bash
nc lonely-island.picoctf.net 64477nc lonely-island.picoctf.net 64477The program then asks:
"Send me the HEX BYTE 0xFF 3 times, side-by-side, no space."
At first, this looks simple, but the important detail is that the program expects raw bytes, not the ASCII characters representing hexadecimal values.
1. Understanding the Source Code
The provided app.py contains the following important section:
Python
user_input = sys.stdin.buffer.readline().rstrip(b"\n")
if user_input == b"\xff\xff\xff":
print(open("./flag.txt", "r").read())
break
else:
print("That wasn't it. I got: " + str(user_input))user_input = sys.stdin.buffer.readline().rstrip(b"\n")
if user_input == b"\xff\xff\xff":
print(open("./flag.txt", "r").read())
break
else:
print("That wasn't it. I got: " + str(user_input))This tells us exactly what input the program is checking for.
The condition is:
Python
user_input == b"\xff\xff\xff"user_input == b"\xff\xff\xff"The b before the string means this is a bytes literal.
Each \xff represents one byte with the hexadecimal value:
0xFF0xFFTherefore, the program expects exactly three bytes:
FF FF FFFF FF FFHowever, the challenge specifically says "side-by-side, no space."
So the actual byte sequence that needs to be sent is:
FF FF FFFF FF FFwith no spaces between the bytes:
FFFFFFFFFFFF2. Why Normal Input Does Not Work
If we simply type:
FFFFFFFFFFFFthe program receives the ASCII characters:
46 46 46 46 46 4646 46 46 46 46 46That is not the same as:
FF FF FFFF FF FFThe program is looking for three actual 0xFF bytes, not six ASCII characters representing FF.
This distinction between text representation and raw byte values is the key to the challenge.
3. Generating the Correct Bytes
We can use echo -e to interpret \xFF as a hexadecimal byte.
The required payload is:
echo -e "\xff\xff\xff"echo -e "\xff\xff\xff"This produces three raw bytes:
FF FF FFFF FF FFThere are no spaces between them.
We can verify the bytes conceptually as:
Byte 1 โ 0xFF
Byte 2 โ 0xFF
Byte 3 โ 0xFFByte 1 โ 0xFF
Byte 2 โ 0xFF
Byte 3 โ 0xFF4. Sending the Payload to the Remote Service
Now we pipe those bytes directly into the nc connection:
Bash
echo -e "\xff\xff\xff" | nc lonely-island.picoctf.net 64477echo -e "\xff\xff\xff" | nc lonely-island.picoctf.net 64477Here:
echo -einterprets\xffas a hexadecimal byte.\xff\xff\xffgenerates three0xFFbytes.- | pipes the generated bytes into the next command.
ncconnects to the picoCTF server on port64477.
The server receives the exact byte sequence expected by the Python program:
FF FF FFFF FF FFThe comparison therefore evaluates to true:
Python
if user_input == b"\xff\xff\xff":if user_input == b"\xff\xff\xff":and the program executes:
Python
print(open("./flag.txt", "r").read())print(open("./flag.txt", "r").read())which reveals the flag.
5. Final Solution
The complete command is:
Bash
echo -e "\xff\xff\xff" | nc lonely-island.picoctf.net 64477echo -e "\xff\xff\xff" | nc lonely-island.picoctf.net 64477The key lesson from this challenge is the difference between ASCII characters representing hexadecimal values and the actual byte values themselves.
Instead of sending the text FFFFFF, we need to send three raw 0xFF bytes:
0xFF 0xFF 0xFF0xFF 0xFF 0xFFOnce the correct bytes are supplied, the program accepts the input and prints the flag.