Programming Foundations
Vulnerabilities live in programs. If we want to understand why a program crashes, accepts something it should reject, or wanders into memory it does not own, we need to read the instructions it was built from.
You do not need to become a professional software developer before doing vulnerability research. You do need enough programming fluency to follow a value through a small program, predict which path it will take, change one piece, and explain the result. That is what this module is for.
We will begin with Python because it lets us concentrate on program behavior without introducing a compiler and manual memory management at the same time. Then we will move to C, where the relationship between source code, compiled instructions, and memory becomes much more visible. C is less forgiving. This is inconvenient when writing software and extremely educational when researching it.
Module sequence
Section titled “Module sequence”Learning how programs behave
Section titled “Learning how programs behave”- What Is a Program? — Source code, instructions, input, output, state, and what it means to run code.
- Python Scripts and Values — Your first scripts, variables, basic types, and terminal arguments.
- Decisions and Repetition — Conditions, comparisons, loops, and tracing the path a program takes.
- Functions, Errors, and Files — Breaking work into functions, interpreting failures, and reading data from disk.
- Python Behavior Lab — Investigate a script whose behavior changes with its input.
Getting closer to the machine
Section titled “Getting closer to the machine”- C Programs and Compilation — Build a small native program and connect source code to the resulting executable.
- Types, Functions, and Control Flow in C — Revisit familiar programming ideas under C’s stricter rules.
- Arrays, Strings, Pointers, and Memory — Build the mental model needed for later debugging and exploitation.
- C Memory Lab — Predict and observe how a small program lays out and changes data.
Putting the process together
Section titled “Putting the process together”- Reading Unfamiliar Code — Turn source code into a map of inputs, decisions, state changes, and outputs.
- Code Investigation Lab — Apply the complete process to an unfamiliar but bounded program.
The numbering contains eight lessons and three labs. Labs are listed in the order you will encounter them because saving every exercise for the end would be a fine way to forget the first half before using it.
Tools used in this module
Section titled “Tools used in this module”Everything runs inside the Linux course VM. We will use:
- the terminal and filesystem commands from Linux Foundations;
- a plain text editor;
- Python 3;
- GCC, the GNU C compiler;
- ordinary command-line inspection tools;
- small course programs that are safe to change and break.
Setup instructions appear when each tool is first needed. Do not install a random collection of development tools in advance. More software is not the same thing as more understanding.
How to work through the examples
Section titled “How to work through the examples”Keep a directory for your programming exercises and a separate research notebook. Before running an example, write down what you expect it to do. Afterward, record what actually happened and explain any difference.
That prediction step may feel slow. It is also the beginning of debugging and vulnerability research. Running a program repeatedly without a question is not investigation; it is just making the computer warm.
Start with What Is a Program?