Introduction to ctf(pwn) stack overflow

Stack overflow means that the number of bytes written by the program into a variable on the stack exceeds the number of bytes applied for by the variable itself, which causes
the value of the variable in the adjacent stack to be changed. This problem is a specific buffer overflow vulnerability, similar to
overflow methods such as heap overflow and bss segment overflow. Stack overflow vulnerabilities can cause a program to crash, or cause an attacker to control the execution flow of the program. In addition, it is not difficult to find that the basic premise for stack overflow is

  1. The program must write data to the stack.
  2. The size of the data written is not well controlled.

Generally speaking, we will have the following coverage requirements

  1. Override the return address of the function, at this time just look at EBP directly.
  2. To overwrite the contents of a variable on the stack, more detailed calculations are required at this time.
  3. Overwrite the content of a variable in the bss segment.
  4. According to the actual implementation, overwrite the content of a specific variable or address.

The reason why we want to overwrite an address is because we want to directly or indirectly control the program execution flow by overwriting the address .

If you want a further level of understanding, please refer to the example: Pwn forgot—stack overflow; (Method 1)

Guess you like

Origin blog.csdn.net/weixin_45556441/article/details/114407571