SlideShare ist ein Scribd-Unternehmen logo
MEMORY ALLOCATION
DIVING INTO
TO UNDERSTAND BUFFER OVERFLOW BETTER
DYNAMIC MEMORY ALLOCATION
WHOAMI
Oguzhan Topgul
Application Security Engineer @FORTINET
www.oguzhantopgul.com
@oguzhantopgul
DYNAMIC MEMORY ALLOCATION
CPU REGISTERS
▸ EIP: Instruction Pointer - Next instruction to be executed
▸ ESP: Stack Pointer - Top of the stack
▸ EBP: Base Pointer - Base of the stack
▸ EAX: Accumulator Register - Generally holds the return value
▸ EBX: Base Register - Generally used to address memory
▸ ECX: Counter Register - Generally used in shift, rotate instructions and loops
▸ EDX: Data Register - Generally used in arithmetic and I/O operations
▸ ESI: Source Index Register
▸ EDI: Destination Index Register
DYNAMIC MEMORY ALLOCATION
PROGRAM MEMORY
.TEXT
.DATA
HEAP
STACK
.BSS
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
- a.k.a Code Segment
- Executable Instructions
- Read-only
DYNAMIC MEMORY ALLOCATION
PROGRAM MEMORY
.TEXT
.DATA
HEAP
STACK
.BSS
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
- a.k.a initialized data
- global variables w/ pre-defined value
- static variables w/ pre-defined value
within the functions
keeps its value between invocations
#include <stdio.h>
void foo()
{
int a = 10;
static int sa = 10;
a += 5;
sa += 5;
printf("a = %d, sa = %dn", a, sa);
}
int main()
{
int i;
for (i = 0; i < 10; ++i)
foo();
}
a = 15, sa = 15
a = 15, sa = 20
a = 15, sa = 25
a = 15, sa = 30
a = 15, sa = 35
a = 15, sa = 40
a = 15, sa = 45
a = 15, sa = 50
a = 15, sa = 55
a = 15, sa = 60
DYNAMIC MEMORY ALLOCATION
PROGRAM MEMORY
.TEXT
.DATA
HEAP
STACK
.BSS
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
- a.k.a uninitialized data
- global variables w/o pre-defined value
- static variables w/o predefined value
within the functions
DYNAMIC MEMORY ALLOCATION
PROGRAM MEMORY
.TEXT
.DATA
HEAP
STACK
.BSS
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
- grows low->high
- malloc, calloc, realloc, free
- shared by all
- threads,
- shared libraries
- dynamically loaded modules
DYNAMIC MEMORY ALLOCATION
PROGRAM MEMORY
.TEXT
.DATA
HEAP
STACK
.BSS
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
- LIFO
- On x86, stack grows Higher->Lower
- What’s stored in Stack:
- Function arguments,
- Local variables
- Function return address
- PUSH adds to the top, POP removes from top
} Stack Frame
#include <stdio.h>
int x = 20;
int y;
int main()
{
char buf[5];
for (i = 0; i < 10; ++i)
foo(15);
}
void foo(int arg)
{
int a = 10;
static int sa = 10;
sa += 5;
char* int = malloc(10 * sizeof(int));
printf("sa = %dn”,sa);
}
DYNAMIC MEMORY ALLOCATION
PROGRAM MEMORY
.TEXT
.DATA
HEAP
STACK
.BSS
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
double multiplyByTwo (double input) {
double twice = input * 2.0;
return twice;
}
int main (int argc, char *argv[])
{
int age = 30;
double salary = 12345.67;
double myList[3] = {1.2, 2.3, 3.4};
printf("salary is %.3fn", multiplyByTwo(salary));
return 0;
}
DYNAMIC MEMORY ALLOCATION
double *multiplyByTwo (double *input) {
double *twice = malloc(sizeof(double));
*twice = *input * 2.0;
return twice;
}
int main (int argc, char *argv[])
{
int *age = malloc(sizeof(int));
*age = 30;
double *salary = malloc(sizeof(double));
*salary = 12345.67;
double *myList = malloc(3 * sizeof(double));
myList[0] = 1.2;
myList[1] = 2.3;
myList[2] = 3.4;
double *twiceSalary = multiplyByTwo(salary);
printf(“salary is %.3fn", *twiceSalary);
free(age);
free(salary);
free(myList);
free(twiceSalary);
return 0;
}
DEFINE VARIABLES ON STACK VS HEAP
DYNAMIC MEMORY ALLOCATION
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
- Stack Pointer (SP, ESP) tracks the top of the
stack (last address on the stack)
- Changes during the execution (PUSH&POP)
- Base Pointer (BP, EBP) a.k.a Frame Pointer (FP)
shows the bottom of the stack
- Fixed during the execution
- local variables and arguments are
referenced by their offset from EBP
EBP
ARG 1
ARG 2
LOCAL VAR 2
LOCAL VAR 1
EBP + 8
EBP + 12
EBP - 8
EBP - 4
ESP
RETURN ADDREBP + 4
DYNAMIC MEMORY ALLOCATION
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
int main()
{
function(1,2,3);
}
void function(int a, int b, int c)
{
char buffer1[5];
}
<function>:
push ebp
mov ebp,esp
sub esp,0x10
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e6c
nop
leave
ret
<main>:
push ebp
mov ebp,esp
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e5c
push 0x3
push 0x2
push 0x1
call 1189 <function>
add esp,0xc
nop
leave
ret
EBP - MAIN ESP
DYNAMIC MEMORY ALLOCATION
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
int main()
{
function(1,2,3);
}
void function(int a, int b, int c)
{
char buffer1[5];
}
ARG 3
EBP - MAIN
<function>:
push ebp
mov ebp,esp
sub esp,0x10
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e6c
nop
leave
ret
<main>:
push ebp
mov ebp,esp
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e5c
push 0x3
push 0x2
push 0x1
call 1189 <function>
add esp,0xc
nop
leave
ret
ESP
DYNAMIC MEMORY ALLOCATION
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
int main()
{
function(1,2,3);
}
void function(int a, int b, int c)
{
char buffer1[5];
}
ARG 3
EBP - MAIN
<function>:
push ebp
mov ebp,esp
sub esp,0x10
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e6c
nop
leave
ret
<main>:
push ebp
mov ebp,esp
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e5c
push 0x3
push 0x2
push 0x1
call 1189 <function>
add esp,0xc
nop
leave
ret
ARG 2 ESP
DYNAMIC MEMORY ALLOCATION
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
int main()
{
function(1,2,3);
}
void function(int a, int b, int c)
{
char buffer1[5];
}
ARG 3
EBP - MAIN
<function>:
push ebp
mov ebp,esp
sub esp,0x10
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e6c
nop
leave
ret
<main>:
push ebp
mov ebp,esp
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e5c
push 0x3
push 0x2
push 0x1
call 1189 <function>
add esp,0xc
nop
leave
ret
ARG 2
ARG 1 ESP
DYNAMIC MEMORY ALLOCATION
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
int main()
{
function(1,2,3);
}
void function(int a, int b, int c)
{
char buffer1[5];
}
ARG 3
EBP - MAIN
<function>:
push ebp
mov ebp,esp
sub esp,0x10
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e6c
nop
leave
ret
<main>:
push ebp
mov ebp,esp
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e5c
push 0x3
push 0x2
push 0x1
call 1189 <function>
add esp,0xc
nop
leave
ret
ARG 2
ARG 1
RETURN ADDR ESP
EIP
{
PUSH EIP
JMP function
DYNAMIC MEMORY ALLOCATION
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
int main()
{
function(1,2,3);
}
void function(int a, int b, int c)
{
char buffer1[5];
}
ARG 3
EBP - MAIN
<function>:
push ebp
mov ebp,esp
sub esp,0x10
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e6c
nop
leave
ret
<main>:
push ebp
mov ebp,esp
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e5c
push 0x3
push 0x2
push 0x1
call 1189 <function>
add esp,0xc
nop
leave
ret
ARG 2
ARG 1
RETURN ADDR
EBP - FUNCTION ESP
DYNAMIC MEMORY ALLOCATION
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - FUNCTION
ARG 1
ARG 2
EBP + 8
EBP + 12
EBP - 8
EBP - 4
RETURN ADDREBP + 4
int main()
{
function(1,2,3);
}
void function(int a, int b, int c)
{
char buffer1[5];
}
ARG 3EBP + 16
EBP - 12
EBP - 16 ESP
EBP - MAIN
<function>:
push ebp
mov ebp,esp
sub esp,0x10
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e6c
nop
leave
ret
<main>:
push ebp
mov ebp,esp
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e5c
push 0x3
push 0x2
push 0x1
call 1189 <function>
add esp,0xc
nop
leave
ret
DYNAMIC MEMORY ALLOCATIONTEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
ARG 1
ARG 2
RETURN ADDR
int main()
{
function(1,2,3);
}
void function(int a, int b, int c)
{
char buffer1[5];
}
ARG 3
EBP - MAIN
<function>:
push ebp
mov ebp,esp
sub esp,0x10
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e6c
nop
leave
ret
<main>:
push ebp
mov ebp,esp
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e5c
push 0x3
push 0x2
push 0x1
call 1189 <function>
add esp,0xc
nop
leave
ret
ESP
{
RESTORE ALLOCATED MEMORY
POP EBP
POP RETURN ADDR
JMP RETURN ADDR
DYNAMIC MEMORY ALLOCATION
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
ARG 1
ARG 2
int main()
{
function(1,2,3);
}
void function(int a, int b, int c)
{
char buffer1[5];
}
ARG 3
EBP - MAIN
<function>:
push ebp
mov ebp,esp
sub esp,0x10
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e6c
nop
leave
ret
<main>:
push ebp
mov ebp,esp
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e5c
push 0x3
push 0x2
push 0x1
call 1189 <function>
add esp,0xc
nop
leave
ret
ESP
DYNAMIC MEMORY ALLOCATION
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
int main()
{
function(1,2,3);
}
void function(int a, int b, int c)
{
char buffer1[5];
}
EBP - MAIN
<function>:
push ebp
mov ebp,esp
sub esp,0x10
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e6c
nop
leave
ret
<main>:
push ebp
mov ebp,esp
call 11ba <__x86.get_pc_thunk.ax>
add eax,0x2e5c
push 0x3
push 0x2
push 0x1
call 1189 <function>
add esp,0xc
nop
leave
ret
ESP
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ESP
void function(char *str)
{
char buffer[16];
strcpy(buffer,str);
}
int main()
{
char large_string[256];
int i;
for(i = 0; i < 255; i++)
large_string[i] = 'A';
function(large_string);
}
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX ESP
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX
EBP - 280 ESP
EBP - 4
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX
EBP - 280 ESP
EBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0x00
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX
EBP - 280 ESP
EBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0x00
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX
EBP - 280 ESP
EBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0x00
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX
EBP - 280 ESP
EBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0x00
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX
EBP - 280 ESP
EBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0x00
EBP - 276
EBP - 272
EBP - 268
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX
EBP - 280 ESP
EBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0x00
EBP - 276
EBP - 272
EBP - 268 0x41
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX
EBP - 280 ESP
EBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0x01
EBP - 276
EBP - 272
EBP - 268 0x41
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX
EBP - 280 ESP
EBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0xff
EBP - 276
EBP - 272
EBP - 268 0x41
}for loop
0x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECX
EBP - 280
ESP
EBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0xff
EBP - 276
EBP - 272
EBP - 268 0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
EBP - 284
EBP - 288
EBP - 292
TEXT
STACK
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECXEBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0xff
EBP - 268 0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
ADDRESS OF EBP-267 ESPEBP - 296
LOW MEMORY ADDRESS
HIGH MEMORY ADDRESS
EBP - MAIN
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
ECXEBP - 4
EBP - 8
EBP - 12 0x00 0x00 0x00 0xff
EBP - 268 0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
RETURN ADDR ESP
ADDRESS OF EBP-267EBP - 296
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
HIGH MEMORY ADDRESS
EBP - MAIN
ECX
0x00 0x00 0x00 0xff
0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
EBX
RETURN ADDR
ADDRESS OF LARGE_STRING
EBP - 4 ESP
EBP - FUNCTION
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
HIGH MEMORY ADDRESS
EBP - MAIN
ECX
0x00 0x00 0x00 0xff
0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
EBX
RETURN ADDR
ADDRESS OF LARGE_STRING
EBP - 4
.
.
.
EBP - 24
EBP - FUNCTION
ESP
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
HIGH MEMORY ADDRESS
EBP - MAIN
ECX
0x00 0x00 0x00 0xff
0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
EBP - FUNCTION
EBX
RETURN ADDR
ADDRESS OF LARGE_STRING
EBP - 4
.
.
.
EBP - 24
EBP - 28
EBP - 32 ESP
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
HIGH MEMORY ADDRESS
EBP - MAIN
ECX
0x00 0x00 0x00 0xff
0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
EBP - FUNCTION
EBX
RETURN ADDR
ADDRESS OF LARGE_STRING
EBP - 4
.
.
.
EBP - 24
EBP - 28
EBP - 32 ESP
EBP + 8
ADDRESS OF LARGE_STRINGEBP - 36
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
HIGH MEMORY ADDRESS
EBP - MAIN
ECX
0x00 0x00 0x00 0xff
0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
EBP - FUNCTION
EBX
RETURN ADDR
ADDRESS OF LARGE_STRING
EBP - 4
16 BYTE BUFFER.
.
.
EBP - 24
EBP - 28
EBP - 32
EBP + 8
ADDRESS OF LARGE_STRINGEBP - 36
ADDRESS OF BUFFEREBP - 40 ESP
TEXT
STACK JUST BEFORE STRCPY
00001199 <function>:
1199:55 push ebp
119a:89 e5 mov ebp,esp
119c:53 push ebx
119d:83 ec 14 sub esp,0x14
…
11aa:83 ec 08 sub esp,0x8
11ad:ff 75 08 push DWORD PTR [ebp+0x8]
11b0:8d 55 e8 lea edx,[ebp-0x18]
11b3:52 push edx
11b4:89 c3 mov ebx,eax
11b6:e8 75 fe ff ff call 1030 <strcpy@plt>
11bb:83 c4 10 add esp,0x10
11be:90 nop
11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4]
11c2:c9 leave
11c3:c3 ret
000011c4 <main>:
…
11ce:55 push ebp
11cf:89 e5 mov ebp,esp
11d1:51 push ecx
11d2:81 ec 14 01 00 00 sub esp,0x114
…
11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
11e9:eb 12 jmp 11fd <main+0x39>
11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c]
11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc]
11f4:01 d0 add eax,edx
11f6:c6 00 41 mov BYTE PTR [eax],0x41
11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1
11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe
1204:7e e5 jle 11eb <main+0x27>
1206:83 ec 0c sub esp,0xc
1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c]
120f:50 push eax
1210:e8 84 ff ff ff call 1199 <function>
1215:83 c4 10 add esp,0x10
1218:90 nop
1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4]
121c:c9 leave
121d:8d 61 fc lea esp,[ecx-0x4]
1220:c3 ret
HIGH MEMORY ADDRESS
EBP - MAIN
ECX
0x00 0x00 0x00 0xff
0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
EBP - FUNCTION
EBX
RETURN ADDR
ADDRESS OF LARGE_STRING
EBP - 4
16 BYTE BUFFER.
.
.
EBP - 24
EBP - 28
EBP - 32
EBP + 8
ADDRESS OF LARGE_STRINGEBP - 36
ADDRESS OF BUFFEREBP - 40 ESP
0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41
0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41
DYNAMIC MEMORY ALLOCATION
STACK AFTER STRCPY
DYNAMIC MEMORY ALLOCATION
BUFFER OVERFLOW
int main()
{
char large_string[256];
int i;
for(i = 0; i < 255; i++)
large_string[i] = 'A';
char buffer[16];
strcpy(buffer, large_string);
}
int main(int argc, char **argv)
{
char buffer[16];
gets(buffer);
}
▸ What happens if you fill the buffer with a user input?
▸ User can enter an input with the length > 16
HIGH MEMORY ADDRESS
EBP - MAIN
ECX
0x00 0x00 0x00 0xff
0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
.
.
.
0x410x410x410x41
EBP - FUNCTION
EBX
RETURN ADDR
ADDRESS OF LARGE_STRING
16 BYTE BUFFER
0x410x410x410x41
0x410x410x410x41
0x410x410x410x41
user codemyofAddress
0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41
USER CODE
BUFFER OVERFLOW
▸ Overwrite the return address
▸ Change the program flow
DYNAMIC MEMORY ALLOCATION

Weitere ähnliche Inhalte

Was ist angesagt?

Sahul
SahulSahul
Sahu
SahuSahu
Infrastructure As Code With Terraform
Infrastructure As Code With TerraformInfrastructure As Code With Terraform
Infrastructure As Code With Terraform
Mystic Coders, LLC
 
Watch Me Install Alfresco
Watch Me Install AlfrescoWatch Me Install Alfresco
Watch Me Install Alfresco
Alfresco Software
 
Hadoop installation
Hadoop installationHadoop installation
Hadoop installation
Leon Gladston
 
Ansible leveraging 2.0
Ansible leveraging 2.0Ansible leveraging 2.0
Ansible leveraging 2.0
bcoca
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
JacobMenke1
 
Linux-Fu for PHP Developers
Linux-Fu for PHP DevelopersLinux-Fu for PHP Developers
Linux-Fu for PHP Developers
Lorna Mitchell
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
bcoca
 
PE Packers Used in Malicious Software - Part 2
PE Packers Used in Malicious Software - Part 2PE Packers Used in Malicious Software - Part 2
PE Packers Used in Malicious Software - Part 2
amiable_indian
 
Sah
SahSah
Setting up a HADOOP 2.2 cluster on CentOS 6
Setting up a HADOOP 2.2 cluster on CentOS 6Setting up a HADOOP 2.2 cluster on CentOS 6
Setting up a HADOOP 2.2 cluster on CentOS 6
Manish Chopra
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
How to Save, backup and restore IOS on Cisco router
How to Save, backup and restore IOS on Cisco routerHow to Save, backup and restore IOS on Cisco router
How to Save, backup and restore IOS on Cisco router
tcpipguru
 
Web Audio API + AngularJS
Web Audio API + AngularJSWeb Audio API + AngularJS
Web Audio API + AngularJS
Chris Bateman
 
SecZone 2011: Scrubbing SAP clean with SOAP
SecZone 2011: Scrubbing SAP clean with SOAPSecZone 2011: Scrubbing SAP clean with SOAP
SecZone 2011: Scrubbing SAP clean with SOAP
Chris John Riley
 
Mercurial for Kittens
Mercurial for KittensMercurial for Kittens
Mercurial for Kittens
nya3jp
 
Flask SQLAlchemy
Flask SQLAlchemy Flask SQLAlchemy
Flask SQLAlchemy
Eueung Mulyana
 
Building apache modules
Building apache modulesBuilding apache modules
Building apache modules
Marian Marinov
 
Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)
dantleech
 

Was ist angesagt? (20)

Sahul
SahulSahul
Sahul
 
Sahu
SahuSahu
Sahu
 
Infrastructure As Code With Terraform
Infrastructure As Code With TerraformInfrastructure As Code With Terraform
Infrastructure As Code With Terraform
 
Watch Me Install Alfresco
Watch Me Install AlfrescoWatch Me Install Alfresco
Watch Me Install Alfresco
 
Hadoop installation
Hadoop installationHadoop installation
Hadoop installation
 
Ansible leveraging 2.0
Ansible leveraging 2.0Ansible leveraging 2.0
Ansible leveraging 2.0
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
 
Linux-Fu for PHP Developers
Linux-Fu for PHP DevelopersLinux-Fu for PHP Developers
Linux-Fu for PHP Developers
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
PE Packers Used in Malicious Software - Part 2
PE Packers Used in Malicious Software - Part 2PE Packers Used in Malicious Software - Part 2
PE Packers Used in Malicious Software - Part 2
 
Sah
SahSah
Sah
 
Setting up a HADOOP 2.2 cluster on CentOS 6
Setting up a HADOOP 2.2 cluster on CentOS 6Setting up a HADOOP 2.2 cluster on CentOS 6
Setting up a HADOOP 2.2 cluster on CentOS 6
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
How to Save, backup and restore IOS on Cisco router
How to Save, backup and restore IOS on Cisco routerHow to Save, backup and restore IOS on Cisco router
How to Save, backup and restore IOS on Cisco router
 
Web Audio API + AngularJS
Web Audio API + AngularJSWeb Audio API + AngularJS
Web Audio API + AngularJS
 
SecZone 2011: Scrubbing SAP clean with SOAP
SecZone 2011: Scrubbing SAP clean with SOAPSecZone 2011: Scrubbing SAP clean with SOAP
SecZone 2011: Scrubbing SAP clean with SOAP
 
Mercurial for Kittens
Mercurial for KittensMercurial for Kittens
Mercurial for Kittens
 
Flask SQLAlchemy
Flask SQLAlchemy Flask SQLAlchemy
Flask SQLAlchemy
 
Building apache modules
Building apache modulesBuilding apache modules
Building apache modules
 
Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)
 

Ähnlich wie Diving Into Memory Allocation to Understand Buffer Overflow Better

Reversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basicsReversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basics
Cysinfo Cyber Security Community
 
CNIT 127: Ch 2: Stack Overflows in Linux
CNIT 127: Ch 2: Stack Overflows in LinuxCNIT 127: Ch 2: Stack Overflows in Linux
CNIT 127: Ch 2: Stack Overflows in Linux
Sam Bowne
 
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
CODE BLUE
 
127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux
Sam Bowne
 
CNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on LinuxCNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on Linux
Sam Bowne
 
Basic ASM by @binaryheadache
Basic ASM by @binaryheadacheBasic ASM by @binaryheadache
Basic ASM by @binaryheadache
camsec
 
The Stack and Buffer Overflows
The Stack and Buffer OverflowsThe Stack and Buffer Overflows
The Stack and Buffer Overflows
UTD Computer Security Group
 
CNIT 127: Ch 2: Stack overflows on Linux
CNIT 127: Ch 2: Stack overflows on LinuxCNIT 127: Ch 2: Stack overflows on Linux
CNIT 127: Ch 2: Stack overflows on Linux
Sam Bowne
 
X86 assembly & GDB
X86 assembly & GDBX86 assembly & GDB
X86 assembly & GDB
Jian-Yu Li
 
127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux
Sam Bowne
 
CNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on LinuxCNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on Linux
Sam Bowne
 
ROP
ROPROP
Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughter
Quinn Wilton
 
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsReverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Asuka Nakajima
 
Exploit techniques - a quick review
Exploit techniques - a quick reviewExploit techniques - a quick review
Exploit techniques - a quick review
Ce.Se.N.A. Security
 
17
1717
Return Oriented Programming (ROP chaining)
Return Oriented Programming (ROP chaining)Return Oriented Programming (ROP chaining)
Return Oriented Programming (ROP chaining)
Abhinav Chourasia, GMOB
 
ROP 輕鬆談
ROP 輕鬆談ROP 輕鬆談
ROP 輕鬆談
hackstuff
 
Exploiting Memory Overflows
Exploiting Memory OverflowsExploiting Memory Overflows
Exploiting Memory Overflows
Ankur Tyagi
 
rop heap attacks cfi int overflows computer security
rop heap attacks cfi int overflows computer securityrop heap attacks cfi int overflows computer security
rop heap attacks cfi int overflows computer security
FannyBellows
 

Ähnlich wie Diving Into Memory Allocation to Understand Buffer Overflow Better (20)

Reversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basicsReversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basics
 
CNIT 127: Ch 2: Stack Overflows in Linux
CNIT 127: Ch 2: Stack Overflows in LinuxCNIT 127: Ch 2: Stack Overflows in Linux
CNIT 127: Ch 2: Stack Overflows in Linux
 
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
 
127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux
 
CNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on LinuxCNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on Linux
 
Basic ASM by @binaryheadache
Basic ASM by @binaryheadacheBasic ASM by @binaryheadache
Basic ASM by @binaryheadache
 
The Stack and Buffer Overflows
The Stack and Buffer OverflowsThe Stack and Buffer Overflows
The Stack and Buffer Overflows
 
CNIT 127: Ch 2: Stack overflows on Linux
CNIT 127: Ch 2: Stack overflows on LinuxCNIT 127: Ch 2: Stack overflows on Linux
CNIT 127: Ch 2: Stack overflows on Linux
 
X86 assembly & GDB
X86 assembly & GDBX86 assembly & GDB
X86 assembly & GDB
 
127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux
 
CNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on LinuxCNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on Linux
 
ROP
ROPROP
ROP
 
Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughter
 
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsReverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
 
Exploit techniques - a quick review
Exploit techniques - a quick reviewExploit techniques - a quick review
Exploit techniques - a quick review
 
17
1717
17
 
Return Oriented Programming (ROP chaining)
Return Oriented Programming (ROP chaining)Return Oriented Programming (ROP chaining)
Return Oriented Programming (ROP chaining)
 
ROP 輕鬆談
ROP 輕鬆談ROP 輕鬆談
ROP 輕鬆談
 
Exploiting Memory Overflows
Exploiting Memory OverflowsExploiting Memory Overflows
Exploiting Memory Overflows
 
rop heap attacks cfi int overflows computer security
rop heap attacks cfi int overflows computer securityrop heap attacks cfi int overflows computer security
rop heap attacks cfi int overflows computer security
 

Mehr von Oguzhan Topgul

Malicious Word Document Analysis
Malicious Word Document AnalysisMalicious Word Document Analysis
Malicious Word Document Analysis
Oguzhan Topgul
 
iOS'da Zararlı Yazılım Yok (mu?)
iOS'da Zararlı Yazılım Yok (mu?)iOS'da Zararlı Yazılım Yok (mu?)
iOS'da Zararlı Yazılım Yok (mu?)
Oguzhan Topgul
 
Media Files : Android's New Nightmare
Media Files :  Android's New NightmareMedia Files :  Android's New Nightmare
Media Files : Android's New Nightmare
Oguzhan Topgul
 
Androidin Yeni Kabusu: Medya Dosyalari (Media Files: Android's New Nightmare)
Androidin Yeni Kabusu: Medya Dosyalari (Media Files: Android's New Nightmare)Androidin Yeni Kabusu: Medya Dosyalari (Media Files: Android's New Nightmare)
Androidin Yeni Kabusu: Medya Dosyalari (Media Files: Android's New Nightmare)
Oguzhan Topgul
 
Geçmişten Günümüze Mobil Zararlı Yazılımlar
Geçmişten Günümüze Mobil Zararlı YazılımlarGeçmişten Günümüze Mobil Zararlı Yazılımlar
Geçmişten Günümüze Mobil Zararlı YazılımlarOguzhan Topgul
 
iOS Güvenlik Mekanizmaları - UNISIP Siber Güvenlik Sempozyumu 2014
iOS Güvenlik Mekanizmaları - UNISIP Siber Güvenlik Sempozyumu 2014iOS Güvenlik Mekanizmaları - UNISIP Siber Güvenlik Sempozyumu 2014
iOS Güvenlik Mekanizmaları - UNISIP Siber Güvenlik Sempozyumu 2014Oguzhan Topgul
 
Android'de Parmak Kaldırmadan Konusmak - İzinsiz Uygulamda İzin Kullanmak Sib...
Android'de Parmak Kaldırmadan Konusmak - İzinsiz Uygulamda İzin Kullanmak Sib...Android'de Parmak Kaldırmadan Konusmak - İzinsiz Uygulamda İzin Kullanmak Sib...
Android'de Parmak Kaldırmadan Konusmak - İzinsiz Uygulamda İzin Kullanmak Sib...Oguzhan Topgul
 

Mehr von Oguzhan Topgul (7)

Malicious Word Document Analysis
Malicious Word Document AnalysisMalicious Word Document Analysis
Malicious Word Document Analysis
 
iOS'da Zararlı Yazılım Yok (mu?)
iOS'da Zararlı Yazılım Yok (mu?)iOS'da Zararlı Yazılım Yok (mu?)
iOS'da Zararlı Yazılım Yok (mu?)
 
Media Files : Android's New Nightmare
Media Files :  Android's New NightmareMedia Files :  Android's New Nightmare
Media Files : Android's New Nightmare
 
Androidin Yeni Kabusu: Medya Dosyalari (Media Files: Android's New Nightmare)
Androidin Yeni Kabusu: Medya Dosyalari (Media Files: Android's New Nightmare)Androidin Yeni Kabusu: Medya Dosyalari (Media Files: Android's New Nightmare)
Androidin Yeni Kabusu: Medya Dosyalari (Media Files: Android's New Nightmare)
 
Geçmişten Günümüze Mobil Zararlı Yazılımlar
Geçmişten Günümüze Mobil Zararlı YazılımlarGeçmişten Günümüze Mobil Zararlı Yazılımlar
Geçmişten Günümüze Mobil Zararlı Yazılımlar
 
iOS Güvenlik Mekanizmaları - UNISIP Siber Güvenlik Sempozyumu 2014
iOS Güvenlik Mekanizmaları - UNISIP Siber Güvenlik Sempozyumu 2014iOS Güvenlik Mekanizmaları - UNISIP Siber Güvenlik Sempozyumu 2014
iOS Güvenlik Mekanizmaları - UNISIP Siber Güvenlik Sempozyumu 2014
 
Android'de Parmak Kaldırmadan Konusmak - İzinsiz Uygulamda İzin Kullanmak Sib...
Android'de Parmak Kaldırmadan Konusmak - İzinsiz Uygulamda İzin Kullanmak Sib...Android'de Parmak Kaldırmadan Konusmak - İzinsiz Uygulamda İzin Kullanmak Sib...
Android'de Parmak Kaldırmadan Konusmak - İzinsiz Uygulamda İzin Kullanmak Sib...
 

Kürzlich hochgeladen

Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
riddhimaagrawal986
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
Madan Karki
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
Prakhyath Rai
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
ElakkiaU
 
integral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdfintegral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdf
gaafergoudaay7aga
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
TaghreedAltamimi
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Data Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptxData Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptx
ramrag33
 

Kürzlich hochgeladen (20)

Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
 
integral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdfintegral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdf
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Data Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptxData Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptx
 

Diving Into Memory Allocation to Understand Buffer Overflow Better

  • 1. MEMORY ALLOCATION DIVING INTO TO UNDERSTAND BUFFER OVERFLOW BETTER
  • 2. DYNAMIC MEMORY ALLOCATION WHOAMI Oguzhan Topgul Application Security Engineer @FORTINET www.oguzhantopgul.com @oguzhantopgul
  • 3. DYNAMIC MEMORY ALLOCATION CPU REGISTERS ▸ EIP: Instruction Pointer - Next instruction to be executed ▸ ESP: Stack Pointer - Top of the stack ▸ EBP: Base Pointer - Base of the stack ▸ EAX: Accumulator Register - Generally holds the return value ▸ EBX: Base Register - Generally used to address memory ▸ ECX: Counter Register - Generally used in shift, rotate instructions and loops ▸ EDX: Data Register - Generally used in arithmetic and I/O operations ▸ ESI: Source Index Register ▸ EDI: Destination Index Register
  • 4. DYNAMIC MEMORY ALLOCATION PROGRAM MEMORY .TEXT .DATA HEAP STACK .BSS LOW MEMORY ADDRESS HIGH MEMORY ADDRESS - a.k.a Code Segment - Executable Instructions - Read-only
  • 5. DYNAMIC MEMORY ALLOCATION PROGRAM MEMORY .TEXT .DATA HEAP STACK .BSS LOW MEMORY ADDRESS HIGH MEMORY ADDRESS - a.k.a initialized data - global variables w/ pre-defined value - static variables w/ pre-defined value within the functions keeps its value between invocations #include <stdio.h> void foo() { int a = 10; static int sa = 10; a += 5; sa += 5; printf("a = %d, sa = %dn", a, sa); } int main() { int i; for (i = 0; i < 10; ++i) foo(); } a = 15, sa = 15 a = 15, sa = 20 a = 15, sa = 25 a = 15, sa = 30 a = 15, sa = 35 a = 15, sa = 40 a = 15, sa = 45 a = 15, sa = 50 a = 15, sa = 55 a = 15, sa = 60
  • 6. DYNAMIC MEMORY ALLOCATION PROGRAM MEMORY .TEXT .DATA HEAP STACK .BSS LOW MEMORY ADDRESS HIGH MEMORY ADDRESS - a.k.a uninitialized data - global variables w/o pre-defined value - static variables w/o predefined value within the functions
  • 7. DYNAMIC MEMORY ALLOCATION PROGRAM MEMORY .TEXT .DATA HEAP STACK .BSS LOW MEMORY ADDRESS HIGH MEMORY ADDRESS - grows low->high - malloc, calloc, realloc, free - shared by all - threads, - shared libraries - dynamically loaded modules
  • 8. DYNAMIC MEMORY ALLOCATION PROGRAM MEMORY .TEXT .DATA HEAP STACK .BSS LOW MEMORY ADDRESS HIGH MEMORY ADDRESS - LIFO - On x86, stack grows Higher->Lower - What’s stored in Stack: - Function arguments, - Local variables - Function return address - PUSH adds to the top, POP removes from top } Stack Frame
  • 9. #include <stdio.h> int x = 20; int y; int main() { char buf[5]; for (i = 0; i < 10; ++i) foo(15); } void foo(int arg) { int a = 10; static int sa = 10; sa += 5; char* int = malloc(10 * sizeof(int)); printf("sa = %dn”,sa); } DYNAMIC MEMORY ALLOCATION PROGRAM MEMORY .TEXT .DATA HEAP STACK .BSS LOW MEMORY ADDRESS HIGH MEMORY ADDRESS
  • 10. double multiplyByTwo (double input) { double twice = input * 2.0; return twice; } int main (int argc, char *argv[]) { int age = 30; double salary = 12345.67; double myList[3] = {1.2, 2.3, 3.4}; printf("salary is %.3fn", multiplyByTwo(salary)); return 0; } DYNAMIC MEMORY ALLOCATION double *multiplyByTwo (double *input) { double *twice = malloc(sizeof(double)); *twice = *input * 2.0; return twice; } int main (int argc, char *argv[]) { int *age = malloc(sizeof(int)); *age = 30; double *salary = malloc(sizeof(double)); *salary = 12345.67; double *myList = malloc(3 * sizeof(double)); myList[0] = 1.2; myList[1] = 2.3; myList[2] = 3.4; double *twiceSalary = multiplyByTwo(salary); printf(“salary is %.3fn", *twiceSalary); free(age); free(salary); free(myList); free(twiceSalary); return 0; } DEFINE VARIABLES ON STACK VS HEAP
  • 11. DYNAMIC MEMORY ALLOCATION STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS - Stack Pointer (SP, ESP) tracks the top of the stack (last address on the stack) - Changes during the execution (PUSH&POP) - Base Pointer (BP, EBP) a.k.a Frame Pointer (FP) shows the bottom of the stack - Fixed during the execution - local variables and arguments are referenced by their offset from EBP EBP ARG 1 ARG 2 LOCAL VAR 2 LOCAL VAR 1 EBP + 8 EBP + 12 EBP - 8 EBP - 4 ESP RETURN ADDREBP + 4
  • 12. DYNAMIC MEMORY ALLOCATION STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS int main() { function(1,2,3); } void function(int a, int b, int c) { char buffer1[5]; } <function>: push ebp mov ebp,esp sub esp,0x10 call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e6c nop leave ret <main>: push ebp mov ebp,esp call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e5c push 0x3 push 0x2 push 0x1 call 1189 <function> add esp,0xc nop leave ret EBP - MAIN ESP
  • 13. DYNAMIC MEMORY ALLOCATION STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS int main() { function(1,2,3); } void function(int a, int b, int c) { char buffer1[5]; } ARG 3 EBP - MAIN <function>: push ebp mov ebp,esp sub esp,0x10 call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e6c nop leave ret <main>: push ebp mov ebp,esp call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e5c push 0x3 push 0x2 push 0x1 call 1189 <function> add esp,0xc nop leave ret ESP
  • 14. DYNAMIC MEMORY ALLOCATION STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS int main() { function(1,2,3); } void function(int a, int b, int c) { char buffer1[5]; } ARG 3 EBP - MAIN <function>: push ebp mov ebp,esp sub esp,0x10 call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e6c nop leave ret <main>: push ebp mov ebp,esp call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e5c push 0x3 push 0x2 push 0x1 call 1189 <function> add esp,0xc nop leave ret ARG 2 ESP
  • 15. DYNAMIC MEMORY ALLOCATION STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS int main() { function(1,2,3); } void function(int a, int b, int c) { char buffer1[5]; } ARG 3 EBP - MAIN <function>: push ebp mov ebp,esp sub esp,0x10 call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e6c nop leave ret <main>: push ebp mov ebp,esp call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e5c push 0x3 push 0x2 push 0x1 call 1189 <function> add esp,0xc nop leave ret ARG 2 ARG 1 ESP
  • 16. DYNAMIC MEMORY ALLOCATION STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS int main() { function(1,2,3); } void function(int a, int b, int c) { char buffer1[5]; } ARG 3 EBP - MAIN <function>: push ebp mov ebp,esp sub esp,0x10 call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e6c nop leave ret <main>: push ebp mov ebp,esp call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e5c push 0x3 push 0x2 push 0x1 call 1189 <function> add esp,0xc nop leave ret ARG 2 ARG 1 RETURN ADDR ESP EIP { PUSH EIP JMP function
  • 17. DYNAMIC MEMORY ALLOCATION STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS int main() { function(1,2,3); } void function(int a, int b, int c) { char buffer1[5]; } ARG 3 EBP - MAIN <function>: push ebp mov ebp,esp sub esp,0x10 call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e6c nop leave ret <main>: push ebp mov ebp,esp call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e5c push 0x3 push 0x2 push 0x1 call 1189 <function> add esp,0xc nop leave ret ARG 2 ARG 1 RETURN ADDR EBP - FUNCTION ESP
  • 18. DYNAMIC MEMORY ALLOCATION STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - FUNCTION ARG 1 ARG 2 EBP + 8 EBP + 12 EBP - 8 EBP - 4 RETURN ADDREBP + 4 int main() { function(1,2,3); } void function(int a, int b, int c) { char buffer1[5]; } ARG 3EBP + 16 EBP - 12 EBP - 16 ESP EBP - MAIN <function>: push ebp mov ebp,esp sub esp,0x10 call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e6c nop leave ret <main>: push ebp mov ebp,esp call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e5c push 0x3 push 0x2 push 0x1 call 1189 <function> add esp,0xc nop leave ret
  • 19. DYNAMIC MEMORY ALLOCATIONTEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS ARG 1 ARG 2 RETURN ADDR int main() { function(1,2,3); } void function(int a, int b, int c) { char buffer1[5]; } ARG 3 EBP - MAIN <function>: push ebp mov ebp,esp sub esp,0x10 call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e6c nop leave ret <main>: push ebp mov ebp,esp call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e5c push 0x3 push 0x2 push 0x1 call 1189 <function> add esp,0xc nop leave ret ESP { RESTORE ALLOCATED MEMORY POP EBP POP RETURN ADDR JMP RETURN ADDR
  • 20. DYNAMIC MEMORY ALLOCATION STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS ARG 1 ARG 2 int main() { function(1,2,3); } void function(int a, int b, int c) { char buffer1[5]; } ARG 3 EBP - MAIN <function>: push ebp mov ebp,esp sub esp,0x10 call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e6c nop leave ret <main>: push ebp mov ebp,esp call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e5c push 0x3 push 0x2 push 0x1 call 1189 <function> add esp,0xc nop leave ret ESP
  • 21. DYNAMIC MEMORY ALLOCATION STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS int main() { function(1,2,3); } void function(int a, int b, int c) { char buffer1[5]; } EBP - MAIN <function>: push ebp mov ebp,esp sub esp,0x10 call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e6c nop leave ret <main>: push ebp mov ebp,esp call 11ba <__x86.get_pc_thunk.ax> add eax,0x2e5c push 0x3 push 0x2 push 0x1 call 1189 <function> add esp,0xc nop leave ret ESP
  • 22. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ESP void function(char *str) { char buffer[16]; strcpy(buffer,str); } int main() { char large_string[256]; int i; for(i = 0; i < 255; i++) large_string[i] = 'A'; function(large_string); }
  • 23. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX ESP
  • 24. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX EBP - 280 ESP EBP - 4
  • 25. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX EBP - 280 ESP EBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0x00
  • 26. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX EBP - 280 ESP EBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0x00
  • 27. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX EBP - 280 ESP EBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0x00
  • 28. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX EBP - 280 ESP EBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0x00
  • 29. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX EBP - 280 ESP EBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0x00 EBP - 276 EBP - 272 EBP - 268
  • 30. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX EBP - 280 ESP EBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0x00 EBP - 276 EBP - 272 EBP - 268 0x41
  • 31. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX EBP - 280 ESP EBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0x01 EBP - 276 EBP - 272 EBP - 268 0x41
  • 32. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX EBP - 280 ESP EBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0xff EBP - 276 EBP - 272 EBP - 268 0x41 }for loop 0x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41
  • 33. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECX EBP - 280 ESP EBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0xff EBP - 276 EBP - 272 EBP - 268 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41 EBP - 284 EBP - 288 EBP - 292
  • 34. TEXT STACK LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECXEBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0xff EBP - 268 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41 ADDRESS OF EBP-267 ESPEBP - 296
  • 35. LOW MEMORY ADDRESS HIGH MEMORY ADDRESS EBP - MAIN 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret ECXEBP - 4 EBP - 8 EBP - 12 0x00 0x00 0x00 0xff EBP - 268 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41 RETURN ADDR ESP ADDRESS OF EBP-267EBP - 296
  • 36. 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret HIGH MEMORY ADDRESS EBP - MAIN ECX 0x00 0x00 0x00 0xff 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41 EBX RETURN ADDR ADDRESS OF LARGE_STRING EBP - 4 ESP EBP - FUNCTION
  • 37. 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret HIGH MEMORY ADDRESS EBP - MAIN ECX 0x00 0x00 0x00 0xff 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41 EBX RETURN ADDR ADDRESS OF LARGE_STRING EBP - 4 . . . EBP - 24 EBP - FUNCTION ESP
  • 38. 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret HIGH MEMORY ADDRESS EBP - MAIN ECX 0x00 0x00 0x00 0xff 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41 EBP - FUNCTION EBX RETURN ADDR ADDRESS OF LARGE_STRING EBP - 4 . . . EBP - 24 EBP - 28 EBP - 32 ESP
  • 39. 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret HIGH MEMORY ADDRESS EBP - MAIN ECX 0x00 0x00 0x00 0xff 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41 EBP - FUNCTION EBX RETURN ADDR ADDRESS OF LARGE_STRING EBP - 4 . . . EBP - 24 EBP - 28 EBP - 32 ESP EBP + 8 ADDRESS OF LARGE_STRINGEBP - 36
  • 40. 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret HIGH MEMORY ADDRESS EBP - MAIN ECX 0x00 0x00 0x00 0xff 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41 EBP - FUNCTION EBX RETURN ADDR ADDRESS OF LARGE_STRING EBP - 4 16 BYTE BUFFER. . . EBP - 24 EBP - 28 EBP - 32 EBP + 8 ADDRESS OF LARGE_STRINGEBP - 36 ADDRESS OF BUFFEREBP - 40 ESP
  • 42. 00001199 <function>: 1199:55 push ebp 119a:89 e5 mov ebp,esp 119c:53 push ebx 119d:83 ec 14 sub esp,0x14 … 11aa:83 ec 08 sub esp,0x8 11ad:ff 75 08 push DWORD PTR [ebp+0x8] 11b0:8d 55 e8 lea edx,[ebp-0x18] 11b3:52 push edx 11b4:89 c3 mov ebx,eax 11b6:e8 75 fe ff ff call 1030 <strcpy@plt> 11bb:83 c4 10 add esp,0x10 11be:90 nop 11bf:8b 5d fc mov ebx,DWORD PTR [ebp-0x4] 11c2:c9 leave 11c3:c3 ret 000011c4 <main>: … 11ce:55 push ebp 11cf:89 e5 mov ebp,esp 11d1:51 push ecx 11d2:81 ec 14 01 00 00 sub esp,0x114 … 11e2:c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0 11e9:eb 12 jmp 11fd <main+0x39> 11eb:8d 95 f4 fe ff ff lea edx,[ebp-0x10c] 11f1:8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 11f4:01 d0 add eax,edx 11f6:c6 00 41 mov BYTE PTR [eax],0x41 11f9:83 45 f4 01 add DWORD PTR [ebp-0xc],0x1 11fd:81 7d f4 fe 00 00 00 cmp DWORD PTR [ebp-0xc],0xfe 1204:7e e5 jle 11eb <main+0x27> 1206:83 ec 0c sub esp,0xc 1209:8d 85 f4 fe ff ff lea eax,[ebp-0x10c] 120f:50 push eax 1210:e8 84 ff ff ff call 1199 <function> 1215:83 c4 10 add esp,0x10 1218:90 nop 1219:8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 121c:c9 leave 121d:8d 61 fc lea esp,[ecx-0x4] 1220:c3 ret HIGH MEMORY ADDRESS EBP - MAIN ECX 0x00 0x00 0x00 0xff 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41 EBP - FUNCTION EBX RETURN ADDR ADDRESS OF LARGE_STRING EBP - 4 16 BYTE BUFFER. . . EBP - 24 EBP - 28 EBP - 32 EBP + 8 ADDRESS OF LARGE_STRINGEBP - 36 ADDRESS OF BUFFEREBP - 40 ESP 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41
  • 44. DYNAMIC MEMORY ALLOCATION BUFFER OVERFLOW int main() { char large_string[256]; int i; for(i = 0; i < 255; i++) large_string[i] = 'A'; char buffer[16]; strcpy(buffer, large_string); } int main(int argc, char **argv) { char buffer[16]; gets(buffer); } ▸ What happens if you fill the buffer with a user input? ▸ User can enter an input with the length > 16
  • 45. HIGH MEMORY ADDRESS EBP - MAIN ECX 0x00 0x00 0x00 0xff 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 . . . 0x410x410x410x41 EBP - FUNCTION EBX RETURN ADDR ADDRESS OF LARGE_STRING 16 BYTE BUFFER 0x410x410x410x41 0x410x410x410x41 0x410x410x410x41 user codemyofAddress 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 0x41 USER CODE BUFFER OVERFLOW ▸ Overwrite the return address ▸ Change the program flow DYNAMIC MEMORY ALLOCATION