Lesson 1 of 9

Reverse engineering and bytes

Goal

A program is bytes, and a byte is a number from 0 to 255

01

Explanation

Reverse engineering means working out how a program works on the inside by looking at its bytes instead of its source code. You'll learn it here on small programs we built for you. It's legitimate when you're studying your own program or one whose license allows it, doing security research, or solving educational challenges called crackmes. Cracking paid software, getting around an anti-cheat system, or breaking the protection on a script that isn't yours is not part of it, and we don't teach it. Everything in this area is bytes we made up, and all of it runs in Python inside your browser.

The first thing you need is to see a program the way the computer sees it: as a sequence of bytes. A byte is eight bits, so it's a whole number from 0 to 255. In Python, the bytes type holds a sequence of them. You create one from a list of numbers, like bytes([0x89, 0x50]), and read each byte by its index just as you would in a list, so data[0] gives you a number, not a character.

The functions you already know work on it too: len(data) gives the number of bytes and sum(data) their total. The data.hex() method shows it as a hexadecimal string with two characters per byte, and that's how you'll read bytes in every lesson in this area.

02

Your task

Write a function summary(data) that takes any block of bytes and returns a tuple of four values in this order: its first byte, its last byte, the sum of all its bytes, and its hex string. The bytes in data are the first six bytes of an image file, so try your function on them.

Checks

5 checks
  1. summary returns the first and last byte
  2. summary adds up the bytes
  3. summary returns the hex string
  4. summary works on another block
  5. The bytes in data are unchanged
03

Hints

0/3
Track lessons0 of 9 done

Start from the byte: hexadecimal, byte order and bitwise operations, then reading file structures, extracting strings and breaking XOR.

Beginner level, 9 lessons, 2 hours in total.

main.py
OutputPython (Pyodide)

Loading Python. This only happens once. Your browser keeps it after that.

–/5

Checks start once the environment is ready.

5 checks listed under “Your task”.

Track lessons0 of 9 done

Start from the byte: hexadecimal, byte order and bitwise operations, then reading file structures, extracting strings and breaking XOR.

Beginner level, 9 lessons, 2 hours in total.