WCU / Cybersecurity
~/CSC 472/Class 04/KP 03
Class 04 · KP 03 / 18

Constraint 1: Position Independence

  • The attacker rarely knows the exact address where the payload lands — stack addresses shift with environment and ASLR.
  • Shellcode must run correctly wherever it is placed: it must be position-independent code (PIC).
  • Practical rules:
  • No hardcoded absolute addresses.
  • Use relative addressing and register-relative references.
  • Common trick: compute needed data on the stack at runtime rather than referencing a fixed data section.
Key Takeaway

Shellcode cannot assume where it lives in memory, so it is written to be relocatable.