What Reverse Engineering Is For, and the Analyst's Workflow
A security team receives a 40 KB executable found on a build server. Nobody knows where it came from. Is it a forgotten internal tool, a modified copy of a legitimate program, or something that phones home? Nobody will hand over source code, so somebody has to read the binary. That is reverse engineering in its most common professional form: a question about a program, answered from the program itself, under time pressure, with a written result at the end.
Four reasons to reverse engineer
| Use | The question | Typical output |
|---|---|---|
| Malware analysis | What does this sample do, how does it persist and communicate, how do we detect and remove it? | indicators of compromise (hashes, strings, file paths, domains), YARA and detection rules, a behaviour report (continued in Malware Analysis, Digital Forensics & Incident Response) |
| Vulnerability research | Where does this program trust its input too much? Did the vendor's patch really fix the bug? | a vulnerability report with a proof that it exists (in a lab), a fix recommendation, coordinated disclosure (Responsible Disclosure) |
| Interoperability | What is the format of this undocumented file or protocol, so our program can read it? | a format specification, a compatible parser (the use the EU Software Directive protects explicitly, see the introduction) |
| Auditing and assurance | Does the vendor's binary do what the contract says? Was it built with the hardening flags? Does it match the published source? | an audit finding, a hardening checklist, a reproducible-build comparison |
Patch diffing sits between the second and fourth uses: comparing a program before and after a security update shows exactly which function changed, which tells defenders how urgent the update is. Tools such as BinDiff and Diaphora do it at scale.
The workflow
Every analysis, from a two-minute triage to a two-week deep dive, follows the same loop. Cheap, safe steps come first; running the program comes later and only in an isolated lab.
- Triage (minutes): cryptographic hash (the sample's identity), file type, size, architecture, compiler hints, readable strings, imported functions, protections. Decide whether it deserves more time and which questions matter.
- Static analysis (hours): read the headers, disassemble, recover functions and control flow, rename things as you understand them. The program never runs, so this is always safe.
- Dynamic analysis (in an isolated lab): run it under a debugger or tracer to confirm what static analysis suggested, watch system calls, read memory at the interesting moment.
- Document: every finding with its evidence (address, bytes, transcript) so somebody else can reproduce it.
Triage in practice
The session builds a small toy "report tool" that reads a file and writes a summary, then runs the triage steps on it. Nothing is executed until the last line, and the program only touches a file the session creates.
cat > report.c <<'SRC'
#include <stdio.h>
#include <string.h>
static const char *OUT = "summary.txt";
int main(int argc, char **argv) {
if (argc < 2) { fprintf(stderr, "usage: report FILE\n"); return 2; }
FILE *in = fopen(argv[1], "r");
if (!in) { perror("open"); return 1; }
char line[256]; int lines = 0, errors = 0;
while (fgets(line, sizeof line, in)) {
lines++;
if (strstr(line, "ERROR")) errors++;
}
fclose(in);
FILE *out = fopen(OUT, "w");
fprintf(out, "lines=%d errors=%d\n", lines, errors);
fclose(out);
return 0;
}
SRC
gcc -O2 report.c -o report
echo "== identity"; sha256sum report | cut -c1-16; stat -c 'size=%s bytes' report
echo "== type"; file -b report | cut -d, -f1-2
echo "== hardening"; checksec --output=csv --file=report | cut -d, -f1-4
echo "== strings"; strings -n 6 report | grep -E 'usage|summary|ERROR|lines='
echo "== imports"; nm -D report | awk '$1=="U"{print $2}' | sed 's/@.*//' | sort | tr '\n' ' '; echo
echo "== behaviour (lab run on our own input)"
printf 'ok\nERROR disk\nok\nERROR net\n' > app.log
./report app.log && cat summary.txt== identity
bbf04c9f0f8f955a
size=16352 bytes
== type
ELF 64-bit LSB pie executable, x86-64
== hardening
Full RELRO,Canary found,NX enabled,PIE enabled
== strings
usage: report FILE
summary.txt
lines=%d errors=%d
== imports
__fprintf_chk __libc_start_main __stack_chk_fail fclose fgets fopen fwrite perror strstr
== behaviour (lab run on our own input)
lines=4 errors=2
Before running anything, the imports already tell the story: fopen, fgets, strstr, fclose and two output functions mean "reads a file, searches text, writes a file". Two names are not in the source: __fprintf_chk is the fortified fprintf that -O2 with _FORTIFY_SOURCE substitutes, and fwrite is what GCC made of fprintf(stderr, "usage..."), a constant string with no format. Imports show what the compiler emitted, not what the author typed. The strings name the output file and the word it searches for. checksec shows a normally hardened build. The run confirms the hypothesis. Real triage is the same, with less friendly answers: imports resolved at run time, strings encrypted, a packer on top. Later sections cover each of those.
How the results are used for detection
An analysis is only useful when it turns into something a defender can act on:
- Indicators: the file hash (exact identity), distinctive strings (
summary.txtand the formatlines=%d errors=%dhere), file paths, mutex names, network destinations. They feed blocklists and searches across the fleet. - Rules: a YARA rule over strings and byte patterns, a Sigma or EDR rule over the behaviour seen in the dynamic step (this file opens, that process starts).
- Capability summaries: "reads files, writes files, no network" is a sentence a manager can use to decide what to do next.
How the work is kept safe and correct
- Static first, dynamic only in an isolated lab (Lab Safety Rules): a VM with no route to production, snapshots before every run, and no shared folders with your host.
- Hash before anything else, and record it in your notes. If the file changes (a self-modifying sample, a mistaken copy), the hash tells you.
- Write down what you know and how you know it. "Function at 0x1240 compares the input with a constant (objdump listing, lines 12-20)" is evidence; "it checks the password" is a guess.
Pitfalls
- Running the sample first. It feels faster, and it is the one step that can hurt you.
- Trusting one tool.
file,stringsand a disassembler can each be fooled by a crafted file; when two of them disagree, believe neither until you have looked at the bytes. - Analysing the wrong thing. A stripped release build and a debug build of "the same program" differ; a packed file must be unpacked before its code means anything.
- Scope creep. An audit of one binary does not authorise probing the vendor's licence server.
Practice
1. A vendor says their agent "only sends anonymous statistics". Which triage step gives the first evidence for or against, without running it?
The imports and strings: network functions (socket, connect, getaddrinfo, an HTTP library), host names or URLs, and functions that read files or system identifiers. Then confirm in a lab with a tracer and a packet capture.
2. Why record the SHA-256 of a sample before anything else?
It is the sample's identity: other analysts, threat intelligence and later re-analysis refer to it by hash, and it proves the file you analysed is the file you received.
3. Which of the four uses does a hardening check of a vendor binary belong to?
Auditing and assurance.
Test yourself
Which step of the workflow should only ever happen in an isolated lab?
- Triage
- Static analysis
- Dynamic analysis: running the program
- Documentation
What does comparing a program before and after a security update (patch diffing) give defenders?
- The source code
- The function that changed, and so a view of how serious the fixed bug was
- A licence key
- The vendor's build server
In the triage session, which evidence suggested 'reads a file, searches text, writes a file' before the program ran?
- The file size
- The imported functions fopen, fgets, strstr, fclose and the output functions
- The SHA-256 hash
- The ELF type
Why is 'Function at 0x1240 compares the input with a constant (objdump listing lines 12-20)' a better note than 'it checks the password'?
- It is shorter
- It gives the location and the evidence, so someone else can reproduce it
- It sounds more technical
- Notes are not needed