Exploit › Module 5 › Lesson 4
Lab — Secure Build
Pack SECURE_FLAGS Makefile, FORTIFY/ASan notes, and safe API diff — full secure rebuild of YOUR $PWN_LAB toy.
Visual · pwn_build_lab
Lab: secure build pack. $PWN_LAB only. Original Cyberlium.
Opening
Build lab ships the hardened artifact chain — flags, sanitizers, APIs, checksec — defender deliverable.
Lessons 5-1–5-3 covered compiler flags, FORTIFY/ASan, and safe API refactors. This lab merges Makefile snippet, sanitizer sample, API diff, and final checksec transcript for secure toy rebuild in $PWN_LAB. No weak-build export. Next: Quiz — Secure Build Hygiene.
1. Lab contract: secure build pack
Create $HOME/cyberlium-lab/t24-m05-l04-build-lab.txt merging SECURE_FLAGS, FORTIFY/ASan card, safe API diff, final checksec, and sha256 of secure toy binary.
Optional: CI yaml snippet showing asan job + release job separation.
Command guide
Try these commands — Lab contract: secure build pack
═══ TOOLS & WEBSITES ═══ Browse / read these (authorized learning only — stay in YOUR lab / program scope)
GCC hardening guide — https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html checksec — https://github.com/slimm609/checksec.sh pwn.college — https://pwn.college/ (secure build awareness)
═══ INSTALL ═══
Linux (Debian/Ubuntu):
Command — copy this
sudo apt install build-essential pipx install checksec.py # or: sudo apt install checksec
macOS:
Command — copy this
xcode-select --install # or brew install gcc pipx install checksec.py
Windows: Use WSL or MinGW Use WSL: pipx install checksec.py Use WSL or install file for Windows
═══ LINUX / macOS ═══
Command — copy this
export LAB_PWN=${LAB_PWN:-$HOME/cyberlium-lab/t24-pwn}
gcc -Wall -Wno-deprecated-declarations -O0 -g -o "$LAB_PWN/bin/build_vuln" "$LAB_PWN/src/bof_vuln.c"
gcc -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIE -pie -Wl,-z,relro,-z,now -O0 -g \
-o "$LAB_PWN/bin/build_safe" "$LAB_PWN/src/bof_safe.c"
file "$LAB_PWN/bin/build_vuln" "$LAB_PWN/bin/build_safe"
if command -v checksec >/dev/null 2>&1; then checksec --file="$LAB_PWN/bin/build_vuln" "$LAB_PWN/bin/build_safe"; else readelf -l "$LAB_PWN/bin/build_safe" | grep GNU_STACK; fi
grep -E 'vuln|safe|harden' "$LAB_PWN/notes/compiler-flags.txt" | head -5Primary tools to practice this lesson: gcc, checksec, file. Reference sites: GCC hardening guide (https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html); checksec (https://github.com/slimm609/checksec.sh); pwn.college (https://pwn.college/). Run every command in the box — install first, then the usage lines — only on YOUR lab / program scope.
2. Verification checklist
Rebuild clean; run toy without crash on fixed input; ASan test target passes; checksec shows NX+Canary+PIE+Full RELRO.
Grep pack for shellcode, ROP, gets — must be zero in release sections.
3. Lock the proof
chmod 600 on the pack. Quiz next — then Crash Observation Literacy.
Secure build pack is the handoff artifact to crash triage module.
4. What you ship: secure build pack for $PWN_LAB
Merged flags, sanitizer, API diff, checksec, sha256. $PWN_LAB named. Release-hardened toy only. chmod 600.
5. What you record before the next lesson
Date. Secure build pack path. $PWN_LAB named. File t24-m05-l04-build-lab.txt chmod 600.
6. Wrong vs right: weaponized exploits vs memory-safety literacy
Worked failure — same MSF word, opposite target. Right never needs a café Wi-Fi or classmate laptop.
Wrong
Ship weak contrast binary as final artifact. Skip checksec after API refactor.
Right
Write YOUR secure build pack with verification checklist. chmod 600. Next: Quiz — Secure Build Hygiene.
Mission: freeze YOUR secure build pack
1) Merge M5 sections. 2) Attach final checksec and sha256. 3) Confirm ASan clean on test target. 4) chmod 600.
Stuck? Ask Cyberlium AI Mentor
checksec + sha256 + Makefile = reproducible secure build proof.
Knowledge Check
APPLY: This lab requires:
Multiple choice
Knowledge Check
APPLY: True or False: Secure build pack should include final toy sha256.
True or False
Knowledge Check
APPLY: After safe API refactor you should:
Multiple choice