🏳️
The CTF Recipes
  • Introduction
  • Cryptography
    • Introduction
    • General knowledge
      • Encoding
        • Character encoding
          • ASCII
          • Unicode
          • UTF-8
        • Data encoding
          • Base16
          • Base32
          • Base64
      • Maths
        • Modular arithmetic
          • Greatest Common Divisor
          • Fermat's little theorem
          • Quadratic residues
          • Tonelli-Shanks
          • Chinese Remainder Theorem
          • Modular binomial
      • Padding
        • PKCS#7
    • Misc
      • XOR
    • Mono-alphabetic substitution
      • Index of coincidence
      • frequency analysis
      • Well known algorithms
        • 🔴Scytale
        • 🔴ROT
        • 🔴Polybe
        • 🔴Vigenere
        • 🔴Pigpen cipher
        • 🔴Affine cipher
    • Symmetric Cryptography
      • AES
        • Block Encryption procedure
          • Byte Substitution
          • Shift Row
          • Mix Column
          • Add Key
          • Key Expansion / Key Schedule
        • Mode of Operation
          • ECB
            • Block shuffling
              • Challenge example
            • ECB Oracle
              • Challenge example
          • CBC
            • Bit flipping
              • Challenge example
            • Padding oracle
              • Challenge example
          • OFB
            • Key stream reconstruction
            • Encrypt to Uncrypt
  • 🛠️Pwn
    • General knowledge
      • STACK
        • Variables storage
        • Stack frame
      • PLT and GOT
      • HEAP
        • HEAP operations
        • Chunk
        • Bins
        • Chunk allocation and reallocation
      • Syscall
    • Architectures
      • aarch32
        • Registers
        • Instruction set
        • Calling convention
      • aarch64
        • Registers
        • Instruction set
        • Calling convention
      • mips32
        • Registers
        • Instruction set
        • Calling convention
      • mips64
        • Registers
        • Instruction set
        • Calling convention
      • x86 / x64
        • Registers
        • Instruction set
        • Calling convention
    • Stack exploitation
      • Stack Buffer Overflow
        • Dangerous functions
          • gets
          • memcpy
          • sprintf
          • strcat
          • strcpy
        • Basics
          • Challenge example
        • Instruction pointer Overwrite
          • Challenge example
        • De Bruijn Sequences
        • Stack reading
          • Challenge example
      • Format string
        • Dangerous functions
          • printf
          • fprintf
        • Placeholder
        • Data Leak
          • Challenge example
        • Data modification
          • Challenge example
      • Arbitrary code execution
        • Shellcode
        • ret2reg
        • Code reuse attack
          • Ret2plt
          • Ret2dlresolve
          • GOT Overwrite
          • Ret2LibC
          • Leaking LibC
          • Ret2csu
          • Return Oriented Programming - ROP
          • Sigreturn Oriented Programming - SROP
          • Blind Return Oriented Programming - BROP
            • Challenge example
          • 🔴Call Oriented Programming - COP
          • 🔴Jump Oriented Programming - JOP
          • One gadget
        • Stack pivoting
    • 🛠️Heap exploitation
      • Heap overflow
        • Challenge example
      • Use after free
        • Challenge example
      • 🛠️Double free
      • 🔴Unlink exploit
    • Protections
      • Stack Canaries
      • No eXecute
      • PIE
      • ASLR
      • RELRO
    • Integer overflow
Powered by GitBook
On this page
  • LIFO (Last In First Out)
  1. Pwn
  2. General knowledge

STACK

The stack is a data structure that operates as a last-in-first-out (LIFO) structure

LIFO (Last In First Out)

Imagine that you have a stack of books on your desk. The books are stacked on top of each other in a certain order, with the bottom book being the first one you put on the stack and the top book being the last one you added.

This is like a LIFO system, because the last book you added (the top one) is the first one you can take off the stack. So if you want to grab a book from the middle of the stack, you have to take off the top few books first and then you can reach the one you want.

the "top" of the stack is at the lowest memory address, and the "bottom" is at the highest memory address

Segment | Address                          | Contents
--------|----------------------------------|------------------------------------------
Stack   |               ^                  | Local variables, function params
        |               |                  |
        | 0xaaaaaaaa (just an example)     |
        | ...                              |
        | +------------------------------+ | Each frame is specific to a procedure. 
        | |                              | | Each frame contains the local variables 
        | |           Frame 2            | | of the procedure, the return address, and
        | |                              | | a backup of the input parameters, or a 
        | +------------------------------+ | copy of certain registers.
        | +------------------------------+ | 
        | |                              | | The frame 1 normally corresponds to the
        | |           Frame 1            | | 'main' function.
        | |                              | |
        | +------------------------------+ |
        | 0xffffffff                       |
--------|----------------------------------|-----------------------------------------

PreviousGeneral knowledgeNextVariables storage

Last updated 8 months ago

🛠️