Two quiet ways into a bank never involve a virus. In the first, nobody breaks anything. An attacker types a password and it works, because a customer chose "Dhaka2026", or used the same password on a quiz site that was breached last year. In the second, nobody tricks a person either. An attacker types a name that is a little too long into a form, and a program written years ago in C lets the extra characters spill into the memory next to it, so an ordinary user suddenly becomes an administrator. Both attacks leave a clean log: a valid login, a normal-looking request. Neither needs malware.
This chapter is about both. A few words first, in case you need them. A vulnerability is a weakness an attacker can use, and it can be a flaw in code or a weak password. An exploit is the method that uses it. In the stages of an attack, everything here happens when the attacker is getting in or getting stronger once inside.
By the end of this chapter you'll tell brute force, dictionary, hybrid, credential stuffing and password spraying apart, and count how long a password attack takes online and offline. You'll read a short C program that overflows a buffer and say what a stack canary, ASLR and NX each do about it (Part 2 explains all three). You'll recognise command injection, SQL injection, directory traversal and privilege escalation, and fix each in code. And you'll apply STRIDE and the secure software development life cycle to a design, so that these mistakes are caught before an attacker finds them. Every program here was compiled and run on a real machine, and the output you see is the real output.
We go in three parts: the password and everything that is done to it; four attacks on software, each with a real run; and then how a team thinks and builds so that software doesn't carry such flaws.