Description
If I told you a word was 0x70 in hexadecimal, could you tell me what it is in ASCII?
Solution
Want to try it yourself first?
The guided walkthrough reveals hints one step at a time.
Step 1
Convert hex to ASCII with PythonObservationI noticed the challenge presented a single hex literal, 0x70, and asked for its ASCII equivalent, which suggested using Python's chr() function to convert the integer directly to its corresponding character.0x70 in hex equals 112 in decimal. Python's chr() converts any integer to its corresponding ASCII/Unicode character. chr(0x70) returns 'p', which is the flag contents.pythonpython3 -c "print(chr(0x70))"Expected output
p
What didn't work first
Tried: Treating 0x70 as a decimal number and passing it directly to chr(70) instead of chr(0x70).
chr(70) returns 'F' (uppercase F, decimal 70), not 'p' (decimal 112). The 0x prefix means the value is hexadecimal, so 0x70 is 7*16+0 = 112 in decimal. Skipping the hex-to-decimal conversion step produces a completely different character.
Tried: Using ord('0x70') to try to convert the string literal directly.
ord() takes a single character, so ord('0x70') raises TypeError because '0x70' is a 4-character string, not a single char. The correct approach is to pass the integer literal 0x70 to chr(), letting Python parse the hex prefix automatically.
Learn more
Hexadecimal (base 16) uses digits 0-9 and letters A-F to represent values 0-15 in a single character. The prefix
0xsignals a hex literal in most programming languages. A single hex digit represents 4 bits (a nibble), so two hex digits represent one byte (8 bits). This makes hex the standard notation for raw byte values - you will see it everywhere in binary exploitation, network protocols, and cryptography.ASCII (American Standard Code for Information Interchange) is a 7-bit character encoding standard that maps integers 0-127 to characters. The printable range is 32-126. Key landmarks to memorize:
- 0x41-0x5A (65-90) = uppercase A-Z
- 0x61-0x7A (97-122) = lowercase a-z
- 0x30-0x39 (48-57) = digits 0-9
- 0x20 (32) = space, 0x0A (10) = newline, 0x00 (0) = null terminator
Python's
chr()andord()functions are the primary tools for converting between integers and characters.chr(0x70)gives'p';ord('p')gives112. For converting a sequence of hex bytes to a string, usebytes.fromhex('70696e67').decode(). Understanding the relationship between hex values and ASCII is essential for reading disassembly, interpreting network captures, and debugging binary formats.Beyond Python, there are many quick ways to perform ASCII lookups in a terminal. The command
printf '%d\n' '''pprints the decimal value of a character in bash. Theman asciipage on most Unix systems displays a full ASCII table organized by decimal, octal, and hex values side by side - a useful reference to keep open during binary challenges. Online tools like CyberChef's "From Charcode" operation handle bulk conversions when you have many bytes to decode at once.Extended ASCII and Unicode are important extensions to understand as well. Standard ASCII only covers 128 code points (0-127). Extended ASCII encodings like Latin-1 (ISO-8859-1) added a second block of 128 characters (128-255) covering accented European letters. Modern systems use Unicode (UTF-8 encoding), which is backward-compatible with ASCII for the first 128 code points but extends far beyond. In binary exploitation, off-by-one errors between ASCII and Unicode assumptions can cause real security bugs, such as when byte values above 127 are interpreted differently depending on which encoding a program assumes.
In CTF competitions, single hex-byte-to-ASCII conversions like this challenge are intentionally trivial to teach the fundamental mechanics. The same skill scales up directly: shellcode is written as hex bytes (
\x70\x6c\x61\x79), network protocol dissection involves identifying fields by their hex values, and format string attacks manipulate ASCII control characters. Memorizing the key ranges - uppercase letters start at0x41, lowercase at0x61, digits at0x30- makes these tasks significantly faster in timed competitions.
Interactive tools
- Base64 & Base32 DecoderDecode Base64 and Base32 strings with auto-detection. Multi-layer mode unwraps nested encodings automatically.
- Recipe ChainStack decoders into a pipeline: Base64, hex, ROT, XOR, Morse, URL, Atbash, Vigenère, and more. Magic mode auto-discovers the chain. Bookmark the URL to save it.
- Number Base ConverterConvert numbers between binary, octal, decimal, and hexadecimal instantly. Enter any value and see all four bases update in real time.
Alternate Solution
Use the Binary to Hex tool on this site to look up hex 0x70 and instantly see its ASCII character - no Python or command line needed.
Flag
Reveal flag
picoCTF{p}
Hexadecimal 0x70 = decimal 112 = ASCII 'p'. Python's chr() converts any integer to its ASCII/Unicode character.