← All courses

An introductory reverse engineering lesson

How to tell what a program does

A small utility has lost its documentation. How could your team find out what it does? Reverse engineering starts with the evidence you can observe. Here, the relevant part has already been translated into plain pseudocode so you can work through it in your browser.

About 10 minutesNo sign-up requiredTry the exercise

Read the available evidence

You receive a short summary of a fictional utility called File Shelf. It takes one filename as input and returns one short label. The rest of the program is unavailable.

Read the pseudocode from top to bottom. “Return” shows the label and ends processing for that input. A name without a dot has an empty suffix.

Extract from the summary
name = trim spaces at both ends of the input
if name is empty → return “Name required”

suffix = text after the final dot, in lowercase
if suffix is “jpg” or “png” → return “Image”
otherwise → return “Other”

Predict three results

For each input, write down the label and the condition responsible for it. Then describe the probable purpose of this utility in one sentence.

InputWhat to notice
“ May.JPG ”The name contains spaces and uppercase letters.
“may.jpg.txt”The name contains two dots.
“ ”There are only spaces between the quotes.
Check your answers and reasoning
  1. “Image”. Trimming removes the spaces. Converting the final suffix JPG to lowercase produces jpg, which matches.
  2. “Other”. The text after the last dot is txt. The earlier jpg has no effect on the condition.
  3. “Name required”. Trimming leaves an empty string. Processing ends before the suffix is checked.

The evidence supports a filename-based label. A plain text file named “may.png” would receive the label “Image”. Establishing that it contains a photograph would require checking its contents. Establishing whether the program opens, moves or deletes any files would require evidence from other parts of the program.

Continue learning

Explore the Academy’s free learning materials.