binhexa picoCTF 2024 Solution

Published: April 3, 2024

Description

How well can you perfom basic binary operations?

Additional details will be available after launching your challenge instance.

Port provided per instance

Launch the picoCTF instance so it assigns you a unique port number for your session.

Connect to titan.picoctf.net with that port via netcat to receive the randomized prompts.

bash
nc titan.picoctf.net <PORT_FROM_INSTANCE>
  1. Step 1Understand the challenge
    Each run gives a series of six questions that perform operations on two binary numbers. The values below are from one walkthrough; your connection will use different operands. Use the Binary Calculator tool for most of these conversions since it handles AND/OR/XOR, addition, and bit shifts without mistakes.
    Learn more

    Binary is base-2 notation - numbers are represented using only the digits 0 and 1. Every bit position represents a power of 2 (1, 2, 4, 8, 16, ...), just as every digit in decimal represents a power of 10. Understanding binary arithmetic is foundational to all of computing: CPUs operate in binary at the hardware level, and bitwise operations are used everywhere from networking (subnet masks) to cryptography (XOR ciphers) to data compression.

    The six operations in this challenge cover the core bitwise and arithmetic operations:

    • AND (&) - outputs 1 only when both input bits are 1. Used for masking: isolating specific bits by ANDing with a mask.
    • OR (|) - outputs 1 when at least one input bit is 1. Used for setting bits: forcing specific positions to 1.
    • Left shift (<<) - shifts all bits left by N positions, appending zeros on the right. Equivalent to multiplying by 2^N.
    • Right shift (>>) - shifts all bits right by N positions, discarding the rightmost bits. Equivalent to integer division by 2^N.
    • Addition (+) - standard binary addition with carry propagation, identical in principle to decimal addition.
    • Multiplication (*) - binary long multiplication; equivalent to repeated addition and shifting.

    The final step asks you to convert the result to hexadecimal. Hex(base-16) is a compact representation of binary: each hex digit maps exactly to 4 binary bits (a "nibble"). Programmers use hex because it is far more readable than long binary strings - a 32-bit value needs 32 binary digits but only 8 hex digits.

  1. Compute 11010100 & 00100001

    Answer: 00000000

    Any overlapping 1 bits survive the AND; otherwise the result bit is 0.

  2. Compute 11010100 | 00100001

    Answer: 11110101

    OR preserves 1s from either operand. RapidTables' binary calculator makes this trivial.

  3. Multiply 11010100 * 00100001

    Answer: 1101101010100

    Binary multiplication mirrors base-10 long multiplication: stack the numbers and shift addends.

  4. Shift 11010100 left by 1 bit

    Answer: 110101000

    Appending a single 0 on the right multiplies the number by two.

  5. Compute 11010100 + 00100001

    Answer: 11110101

    Binary addition carries just like decimal math, so watch the carry chain in the middle bits.

  6. Shift 00100001 right by 1 bit

    Answer: 10000

    A right shift divides by two, chopping the least-significant bit.

Helpful resources

Related guides

Flag

picoCTF{b1tw^3se_0p3eR@tI0n_su33essFuL_aea...}

After answering all six prompts correctly, the service asks for the hexadecimal form of the final value (10000₂ = 0x10). Submit that answer to receive the flag above.

Frequently asked questions

Common questions about the binhexa solution and the techniques it uses.

Why do the binary numbers change every time I reconnect?

The challenge server randomizes the two operands each session to force you to actually perform the operations rather than memorize a set of answers. The six operation types (AND, OR, left shift, right shift, addition, multiplication) and the final hex-conversion step stay the same, only the operands vary. That is why walking through with a tool like the Binary Calculator is faster than trying to compute by hand under a time limit.

What is the difference between a left shift and multiplication by 2?

A left shift by N positions is mathematically equivalent to multiplying by 2^N for non-negative integers, because each bit position represents a power of 2. CPUs implement shifts as a single cycle while multiplication takes several, so optimizing compilers routinely replace multiply-by-power-of-2 with shifts. In this challenge the << and * prompts can both show up; recognizing that 1010 << 2 equals 101000 (40 in decimal, same as 10 * 4) is the whole trick.

Why does the service ask for the hexadecimal form at the end?

After the six binary operations, you end up with a binary result (10000 in the walkthrough). Converting to hex groups the bits into nibbles of four: 10000 split from the right is 1 0000, which is 0x10. Hex is how bytes are commonly represented in real tools (memory dumps, network packets, cryptographic keys), so the challenge reinforces that you can move fluently between bases. Submitting 0x10 unlocks the flag.

Want more picoCTF 2024 writeups?

Tools used in this challenge

Related reading

Do these first

What to try next