convertme.py

Published: April 2, 2026

Description

Run the Python script -- it asks you to convert a random decimal number to binary.

Download convertme.py from the challenge page.

Solution

  1. Step 1Run the script
    Execute the script. It generates a random decimal number and asks you to type its binary representation.
    python3 convertme.py
    Learn more

    Binary (base-2) is the foundational number system of all digital computing. Every value a computer stores or processes is ultimately represented as a sequence of 0s and 1s -- each called a bit. Understanding binary is essential for understanding how computers handle integers, memory addresses, network masks, and file permissions.

    The script generates a random decimal number so you cannot simply memorize the answer -- you need to perform the conversion yourself or use a tool. This is intentional: the challenge teaches the concept rather than a specific value.

  2. Step 2Convert the decimal number to binary
    Use Python's built-in bin() function, which returns a string prefixed with '0b'. Slice off the prefix with [2:] to get just the binary digits.
    python3 -c "print(bin(25)[2:])"
    Learn more

    Python's bin() built-in converts any integer to its binary string representation. The return value is always prefixed with "0b" -- Python's notation for binary literals -- so slicing with [2:] strips that prefix and leaves only the digit string (e.g., "11001" for 25).

    The manual conversion algorithm works by repeatedly dividing the number by 2 and recording the remainders from bottom to top. For example, 25 ÷ 2 = 12 remainder 1, 12 ÷ 2 = 6 remainder 0, 6 ÷ 2 = 3 remainder 0, 3 ÷ 2 = 1 remainder 1, 1 ÷ 2 = 0 remainder 1 -- reading the remainders upward gives 11001.

    Python also provides hex() and oct() for hexadecimal and octal conversions, both using the same [2:] prefix-stripping trick. These number bases appear constantly in CTF challenges: hex in memory dumps and shellcode, octal in Unix file permissions.

  3. Step 3Enter the binary value
    Type the binary answer into the script prompt. If correct, the script prints the flag.
    Learn more

    This step reinforces that the flag is gated behind a correct answer -- a common CTF pattern where knowledge or computation is required before a secret is revealed. In real systems, this mirrors challenge-response authentication: the server poses a problem, and only a client with the correct knowledge can respond.

    For harder variants of this type of challenge (where the server gives you very little time to respond), you would automate the response using pwntools: receive the number, compute bin(n)[2:] programmatically, and send it back -- all within milliseconds. Building that habit now prepares you for timed challenges later.

Flag

picoCTF{...}

Binary (base-2) has only digits 0 and 1; each position is a power of 2. Python's bin() prefixes with '0b' -- slicing [2:] removes it to give just the binary digits.

More General Skills