Description
This file doesn't look like much... just a bunch of 1s and 0s. But maybe it's not just random noise. Can you recover anything meaningful from this?
Setup
Download the file and inspect its contents.
The file contains ASCII '1' and '0' characters - interpret them as binary data.
head -c 100 digits.binSolution
Walk me through it- Step 1Inspect how the digits are framedLook at the first ~200 bytes with od -c. You need to know whether '0' and '1' are space-separated, newline-separated, or contiguous before you slice into 8-bit groups.bash
head -c 200 digits.bin | od -cbashwc -c digits.binLearn more
od -cprints each byte as a printable character (or escape), so you immediately see whether the file is one long run of0/1, or whether there are spaces, tabs, or newlines between groups.wc -cdivided by the bit-grouping (usually 8) tells you how many bytes the decoded flag should be, which catches off-by-one mistakes early. - Step 2Inspect the fileOpen digits.bin and confirm it contains a sequence of '1' and '0' ASCII characters representing binary data.bash
cat digits.binLearn more
The distinction between binary data and ASCII text representing binary is fundamental. The file here contains the literal characters
'0'(ASCII 48) and'1'(ASCII 49) - not actual binary values 0 and 1. The file is valid text that you read with your eyes and then interpret mathematically.This encoding is common in low-level education and CTF introductory challenges because it makes binary arithmetic visible. Every 8 characters form one byte (octet), and each character position represents a power of two from 27 (128) down to 20 (1). For example,
01100101= 0+64+32+0+0+4+0+1 = 101 = ASCII 'e'.In real-world applications, binary-to-text representations are used whenever binary data must traverse a text-only channel: Base64 is the most common (used in email MIME, JSON web tokens, and PEM certificates), while raw binary-as-ASCII is mostly pedagogical or used in signal-level protocols like old-school modems.
- Step 3Convert binary to textSplit the string into 8-bit chunks and convert each to its ASCII byte. Strip trailing null padding. See CTF encodings and Python for CTF for the broader toolkit.python
python3 -c " data = open('digits.bin').read().strip().replace('\n','').replace(' ','') flag = bytes(int(data[i:i+8],2) for i in range(0,len(data),8)) print(flag.rstrip(b'\x00').decode()) "Learn more
Python's
int(bits, 2)converts a binary string to an integer using base 2. Slicing withdata[i:i+8]steps through the string in 8-character windows, one byte at a time. Building abytesobject first lets you call.rstrip(b'\x00')to strip trailing null padding before decoding - many encoders zero-pad to a block boundary, and a stray\x00in the decoded string trips up downstream tooling.The same logic applies to other bases:
int(s, 8)for octal,int(s, 16)for hexadecimal.bytes.fromhex()andbase64.b64decode()handle the most common CTF encodings.A useful mental shortcut: printable ASCII (32-126) fits in 7 bits, so the MSB is always 0 for those characters. If the flag is all printable ASCII you can sanity-check by confirming every 8th bit is 0, but always slice the full 8 bits when decoding so you don't mangle non-ASCII bytes.
Alternate Solution
Use the Binary → Hex Converter on this site to convert the binary data to hex, then interpret each hex byte as ASCII. You can also paste chunks of the binary into the Number Base Converter to convert individual 8-bit groups to their decimal/ASCII equivalents.
Flag
picoCTF{...}
The flag is encoded as a plain binary string - convert each 8-bit group to ASCII.