5-溢出漏洞I
文章目录
Outline
● Understanding of Stack Layout
● Vulnerable code
● Challenges in exploitation
● Shellcode
● Countermeasures
一、栈布局
程序的内存栈结构
Program Memory Stack
#include <stdio.h>
#include <stdlib.h>
int x=100; // data
int main(){
// data stored on stack
int a=2; float b=2.5;
static int y; // bss
// allocate memory on heap
int *ptr = (int *) malloc(2*sizeof(int));
ptr[0]=5; ptr[1]=6; // value 5 and 6 stored on heap
printf("address on stack: &a =0x%x\n",&a);
printf(" &b =0x%x\n",&b);
printf("address on heap: &ptr[0]=0x%x\n",&ptr[0