SlideShare a Scribd company logo
Introduction to Exploitation
th!nkh@ck-hackartist
Outline
• What is exploitation
• Study Points
• CPU Registers & Instructions
• Flow of Function
• Managing Memory
What is exploitation?
• The kind of exploitation is various

For software, hardware, system and etc.
• What is the goal of the exploitation?

The exploitation is getting actions you want it to do.
• What is needed?

Skill of computer languages

Knowledge of Operating System

Understanding architecture.

Study Points
• We will focus on :

CPU registers,

Understanding stack of computer,

A glance about assembly and C
• Why we study those

Most of exploitations come from memory corruption.
CPU Registers & Instructions
• Cores of CPU

CPU consists of registers, instructions.
• What does the different architecture of CPU means?

It means that they have the different instructions each others.
• Are you hard to get assembly?

Do not afraid to face it. Because assembly was made for us
with human friendly representation of opcodes.
• Special instructions

EBP, ESP, EIP
CPU Registers & Instructions
• 16 bits data registers can be accessed to high and low
half bits by AL&AH, BL&BH and etc.
16 Bits 32 Bits 64 Bits Description
AX EAX RAX Accumulator
BX EBX RBX Base Index
CX ECX RCX Counter
DX EDX RDX Data
BP EBP RBP Base Pointer
SP ESP RSP Stack Pointer
IP EIP RIP Instruction Pointer
SI ESI RSI Source Index Pointer
DI EDI RDI Destination Index Pointer
Composition of a Function
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
Name
Parameters
Body
Return type
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
func2(buffer);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
func2(buffer);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
func2(buffer);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
func2(buffer);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
func2(buffer);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
func2(buffer);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
func1(argv[1]);
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
Variation of Stack memory
void func2(char *x) {
printf(“You entered: %sn", x);
}
void func1(char *str) {
char buffer[16];
strcpy(buffer, str);
func2(buffer);
}
int main(int argc, char *argv[]) {
if (argc > 1)
func1(argv[1]);
else printf(“No arguments!n");
}
What is Stack?
• Stack is one of data structure.

LIFO - Last In First Out
• Imagine reading book and stacking
them. After reading them, we simply
take over the top of books. In the
circumstances, it is difficult to get a
book in middle of the tower.
Managing Memory
• One of role of Operating System is managing memory. In order
to manage memory, the memory is segmented into several
parts. The way memory is segmented is depends on OS.
However, main memory is existed and important in all OS.
• Main memory is represented to “logical” structure and consists
of several stack frames.
• Stack frame is a significantly important part. The stack frame is
represented by two pointers:

Base pointer(EBP or RBP) indicates start of current stack frame.

Stack pointer(ESP or RSP) indicates end of current stack frame.
Back to Previous Position
Empty memory
Top of memory
Start of memory
Newer stack frame
EBP
ESP
Back to Previous Position
Empty memory
Top of memory
Start of memory
Newer stack frame
EBPESP
Back to Previous Position
Empty memory
Top of memory
Start of memory
Newer stack frame
EBP
ESP
Back to Previous Position
Empty memory
Top of memory
Start of memory
Newer stack frame
EBP
ESP
Back to Previous Position
Empty memory
Top of memory
Start of memory
Newer stack frame
EBP
ESP
Back to Previous Position
Empty memory
Top of memory
Start of memory
Newer stack frame
EBPESP
Back to Previous Position
Empty memory
Top of memory
Start of memory
Newer stack frame
EBP ESP
Back to Previous Position
Empty memory
Top of memory
Start of memory
Newer stack frame
EBP ESP?
Back to Previous Position
Empty memory
Saved EBP
Top of memory
Start of memory
Newer stack frame
EBP
ESP
Back to Previous Position
Empty memory
Saved EBP
Top of memory
Start of memory
Newer stack frame
EBPESP
Back to Previous Position
Empty memory
Saved EBP
Top of memory
Start of memory
Newer stack frame
EBP
ESP
Back to Previous Position
Empty memory
Saved EBP
Top of memory
Start of memory
Newer stack frame
EBP
ESP
Back to Previous Position
Empty memory
Saved EBP
Top of memory
Start of memory
Newer stack frame
EBP
ESP
Back to Previous Position
Empty memory
Saved EBP
Top of memory
Start of memory
Newer stack frame
EBP
ESP
Back to Previous Position
Empty memory
Saved EBP
Top of memory
Start of memory
Newer stack frame
EBP
ESP
x86 calling conventions
• There are three types for calling function.

stdcall : The default call type of WinAPI32. A callee is
responsible for cleaning stack frame for arguments.

cdecl : The default call type of C. A caller is
responsible for cleaning stack frame.
• There are many call types.
Difference between them
push <arg2>

push <arg1>
call <callee>

push ebp
mov ebp esp
push <local variables>

pop ebp
ret <args size>
push <arg2>

push <arg1>
call <callee>

push ebp
mov ebp esp
push <local variables>

pop ebp
ret 0
add esp <args size>
Caller
Callee
Caller
cdecl stdcall
Thank you for listening.

More Related Content

What's hot

The Ring programming language version 1.6 book - Part 91 of 189
The Ring programming language version 1.6 book - Part 91 of 189The Ring programming language version 1.6 book - Part 91 of 189
The Ring programming language version 1.6 book - Part 91 of 189
Mahmoud Samir Fayed
 
Python and sysadmin I
Python and sysadmin IPython and sysadmin I
Python and sysadmin I
Guixing Bai
 
What the &~#@&lt;!? (Pointers in Rust)
What the &~#@&lt;!? (Pointers in Rust)What the &~#@&lt;!? (Pointers in Rust)
What the &~#@&lt;!? (Pointers in Rust)
David Evans
 
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...
Mr. Vengineer
 
Commit ускоривший python 2.7.11 на 30% и новое в python 3.5
Commit ускоривший python 2.7.11 на 30% и новое в python 3.5Commit ускоривший python 2.7.11 на 30% и новое в python 3.5
Commit ускоривший python 2.7.11 на 30% и новое в python 3.5
PyNSK
 
EuroPython 2016 - Do I Need To Switch To Golang
EuroPython 2016 - Do I Need To Switch To GolangEuroPython 2016 - Do I Need To Switch To Golang
EuroPython 2016 - Do I Need To Switch To Golang
Max Tepkeev
 
C for Java programmers (part 1)
C for Java programmers (part 1)C for Java programmers (part 1)
C for Java programmers (part 1)
Dmitry Zinoviev
 
Concurrency
ConcurrencyConcurrency
Concurrency
Mårten Rånge
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processing
Rodrigo Senra
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
Rodrigo Almeida
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
Sumit Raj
 
Kernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtKernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring Naught
David Evans
 
The Ring programming language version 1.2 book - Part 64 of 84
The Ring programming language version 1.2 book - Part 64 of 84The Ring programming language version 1.2 book - Part 64 of 84
The Ring programming language version 1.2 book - Part 64 of 84
Mahmoud Samir Fayed
 
Hooking signals and dumping the callstack
Hooking signals and dumping the callstackHooking signals and dumping the callstack
Hooking signals and dumping the callstack
Thierry Gayet
 
System Calls
System CallsSystem Calls
System Calls
David Evans
 
Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02
nikomatsakis
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
fisher.w.y
 
Modern technologies in data science
Modern technologies in data science Modern technologies in data science
Modern technologies in data science
Chucheng Hsieh
 
Python Quick Start
Python Quick StartPython Quick Start
Python Quick Start
Abbas Ali
 
Rust Mozlando Tutorial
Rust Mozlando TutorialRust Mozlando Tutorial
Rust Mozlando Tutorial
nikomatsakis
 

What's hot (20)

The Ring programming language version 1.6 book - Part 91 of 189
The Ring programming language version 1.6 book - Part 91 of 189The Ring programming language version 1.6 book - Part 91 of 189
The Ring programming language version 1.6 book - Part 91 of 189
 
Python and sysadmin I
Python and sysadmin IPython and sysadmin I
Python and sysadmin I
 
What the &~#@&lt;!? (Pointers in Rust)
What the &~#@&lt;!? (Pointers in Rust)What the &~#@&lt;!? (Pointers in Rust)
What the &~#@&lt;!? (Pointers in Rust)
 
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...
 
Commit ускоривший python 2.7.11 на 30% и новое в python 3.5
Commit ускоривший python 2.7.11 на 30% и новое в python 3.5Commit ускоривший python 2.7.11 на 30% и новое в python 3.5
Commit ускоривший python 2.7.11 на 30% и новое в python 3.5
 
EuroPython 2016 - Do I Need To Switch To Golang
EuroPython 2016 - Do I Need To Switch To GolangEuroPython 2016 - Do I Need To Switch To Golang
EuroPython 2016 - Do I Need To Switch To Golang
 
C for Java programmers (part 1)
C for Java programmers (part 1)C for Java programmers (part 1)
C for Java programmers (part 1)
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processing
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
 
Kernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtKernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring Naught
 
The Ring programming language version 1.2 book - Part 64 of 84
The Ring programming language version 1.2 book - Part 64 of 84The Ring programming language version 1.2 book - Part 64 of 84
The Ring programming language version 1.2 book - Part 64 of 84
 
Hooking signals and dumping the callstack
Hooking signals and dumping the callstackHooking signals and dumping the callstack
Hooking signals and dumping the callstack
 
System Calls
System CallsSystem Calls
System Calls
 
Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
 
Modern technologies in data science
Modern technologies in data science Modern technologies in data science
Modern technologies in data science
 
Python Quick Start
Python Quick StartPython Quick Start
Python Quick Start
 
Rust Mozlando Tutorial
Rust Mozlando TutorialRust Mozlando Tutorial
Rust Mozlando Tutorial
 

Viewers also liked

Smashing The Stack
Smashing The StackSmashing The Stack
Smashing The Stack
Daniele Bellavista
 
Introduction to Linux Exploit Development
Introduction to Linux Exploit DevelopmentIntroduction to Linux Exploit Development
Introduction to Linux Exploit Development
johndegruyter
 
Exploit techniques and mitigation
Exploit techniques and mitigationExploit techniques and mitigation
Exploit techniques and mitigation
Yaniv Shani
 
Introduction to pointers and memory management in C
Introduction to pointers and memory management in CIntroduction to pointers and memory management in C
Introduction to pointers and memory management in C
Uri Dekel
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploits
hughpearse
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
Priyank Kapadia
 
The Stack Frame
The Stack FrameThe Stack Frame
The Stack Frame
Ivo Marinkov
 
How Functions Work
How Functions WorkHow Functions Work
How Functions Work
Saumil Shah
 
Insecure coding in C (and C++)
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)
Olve Maudal
 
Ctf hello,world!
Ctf hello,world! Ctf hello,world!
Ctf hello,world!
Hacks in Taiwan (HITCON)
 
DIVIDICON
DIVIDICONDIVIDICON
DIVIDICON
Marco Castellano
 
Usage of GDB
Usage of GDBUsage of GDB
Usage of GDB
Jongseok Choi
 
Structure - Processing Linkages in Polyethylene
Structure - Processing Linkages in PolyethyleneStructure - Processing Linkages in Polyethylene
Structure - Processing Linkages in Polyethylene
david_brough1
 
Повторення слів і виразів
Повторення слів і виразівПовторення слів і виразів
Повторення слів і виразів
Natalia Slipenko
 
Aicle epv
Aicle epvAicle epv
Aicle epv
vaom
 
Lgpl license
Lgpl licenseLgpl license
Lgpl license
Eric Juan
 
Digipak analysis
Digipak analysisDigipak analysis
Digipak analysis
Ollie Shepherd
 
bertumbuh melalui membaca
bertumbuh melalui membacabertumbuh melalui membaca
bertumbuh melalui membaca
Simamora Sabam
 
Increase your Following on Twitter With Hashtags!
Increase your Following on Twitter With Hashtags!Increase your Following on Twitter With Hashtags!
Increase your Following on Twitter With Hashtags!
Megan Davis
 
Catálogo
CatálogoCatálogo
Catálogo
Iñaki Cabral
 

Viewers also liked (20)

Smashing The Stack
Smashing The StackSmashing The Stack
Smashing The Stack
 
Introduction to Linux Exploit Development
Introduction to Linux Exploit DevelopmentIntroduction to Linux Exploit Development
Introduction to Linux Exploit Development
 
Exploit techniques and mitigation
Exploit techniques and mitigationExploit techniques and mitigation
Exploit techniques and mitigation
 
Introduction to pointers and memory management in C
Introduction to pointers and memory management in CIntroduction to pointers and memory management in C
Introduction to pointers and memory management in C
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploits
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
 
The Stack Frame
The Stack FrameThe Stack Frame
The Stack Frame
 
How Functions Work
How Functions WorkHow Functions Work
How Functions Work
 
Insecure coding in C (and C++)
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)
 
Ctf hello,world!
Ctf hello,world! Ctf hello,world!
Ctf hello,world!
 
DIVIDICON
DIVIDICONDIVIDICON
DIVIDICON
 
Usage of GDB
Usage of GDBUsage of GDB
Usage of GDB
 
Structure - Processing Linkages in Polyethylene
Structure - Processing Linkages in PolyethyleneStructure - Processing Linkages in Polyethylene
Structure - Processing Linkages in Polyethylene
 
Повторення слів і виразів
Повторення слів і виразівПовторення слів і виразів
Повторення слів і виразів
 
Aicle epv
Aicle epvAicle epv
Aicle epv
 
Lgpl license
Lgpl licenseLgpl license
Lgpl license
 
Digipak analysis
Digipak analysisDigipak analysis
Digipak analysis
 
bertumbuh melalui membaca
bertumbuh melalui membacabertumbuh melalui membaca
bertumbuh melalui membaca
 
Increase your Following on Twitter With Hashtags!
Increase your Following on Twitter With Hashtags!Increase your Following on Twitter With Hashtags!
Increase your Following on Twitter With Hashtags!
 
Catálogo
CatálogoCatálogo
Catálogo
 

Similar to Basic of Exploitation

Buffer OverFlow
Buffer OverFlowBuffer OverFlow
Buffer OverFlow
Rambabu Duddukuri
 
TLPI - 6 Process
TLPI - 6 ProcessTLPI - 6 Process
TLPI - 6 Process
Shu-Yu Fu
 
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
Teddy Hsiung
 
bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018
AlastairRobertson9
 
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Miguel Arroyo
 
Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughter
Quinn Wilton
 
Presentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasuresPresentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasures
tharindunew
 
(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory
Nico Ludwig
 
C q 3
C q 3C q 3
StackOverflow
StackOverflowStackOverflow
StackOverflow
Susam Pal
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
dudarev
 
Buffer Overflows
Buffer OverflowsBuffer Overflows
Buffer Overflows
Sumit Kumar
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
Programming Homework Help
 
20140531 serebryany lecture02_find_scary_cpp_bugs
20140531 serebryany lecture02_find_scary_cpp_bugs20140531 serebryany lecture02_find_scary_cpp_bugs
20140531 serebryany lecture02_find_scary_cpp_bugs
Computer Science Club
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
Programming Exam Help
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
Srikanth
 
C - aptitude3
C - aptitude3C - aptitude3
C - aptitude3
Srikanth
 
Explorando el Diseño de la Memoria en Rust
Explorando el Diseño de la Memoria en RustExplorando el Diseño de la Memoria en Rust
Explorando el Diseño de la Memoria en Rust
Germán Küber
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo
JinTaek Seo
 
strings
stringsstrings
strings
teach4uin
 

Similar to Basic of Exploitation (20)

Buffer OverFlow
Buffer OverFlowBuffer OverFlow
Buffer OverFlow
 
TLPI - 6 Process
TLPI - 6 ProcessTLPI - 6 Process
TLPI - 6 Process
 
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
 
bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018
 
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
 
Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughter
 
Presentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasuresPresentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasures
 
(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory
 
C q 3
C q 3C q 3
C q 3
 
StackOverflow
StackOverflowStackOverflow
StackOverflow
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
 
Buffer Overflows
Buffer OverflowsBuffer Overflows
Buffer Overflows
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
20140531 serebryany lecture02_find_scary_cpp_bugs
20140531 serebryany lecture02_find_scary_cpp_bugs20140531 serebryany lecture02_find_scary_cpp_bugs
20140531 serebryany lecture02_find_scary_cpp_bugs
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
 
C - aptitude3
C - aptitude3C - aptitude3
C - aptitude3
 
Explorando el Diseño de la Memoria en Rust
Explorando el Diseño de la Memoria en RustExplorando el Diseño de la Memoria en Rust
Explorando el Diseño de la Memoria en Rust
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo
 
strings
stringsstrings
strings
 

More from Jongseok Choi

Hyperledger 구조 분석
Hyperledger 구조 분석Hyperledger 구조 분석
Hyperledger 구조 분석
Jongseok Choi
 
Blockchain trends and research
Blockchain trends and researchBlockchain trends and research
Blockchain trends and research
Jongseok Choi
 
블록체인 개요
블록체인 개요블록체인 개요
블록체인 개요
Jongseok Choi
 
Bitcoin and Ethereum
Bitcoin and EthereumBitcoin and Ethereum
Bitcoin and Ethereum
Jongseok Choi
 
Effective Go
Effective GoEffective Go
Effective Go
Jongseok Choi
 
oneM2M security summary
oneM2M security summaryoneM2M security summary
oneM2M security summary
Jongseok Choi
 
Case Study on Intelligent IoT Platform
Case Study on Intelligent IoT PlatformCase Study on Intelligent IoT Platform
Case Study on Intelligent IoT Platform
Jongseok Choi
 
oneM2M Introduction and security
oneM2M Introduction and securityoneM2M Introduction and security
oneM2M Introduction and security
Jongseok Choi
 
IoT Introduction and Security
IoT Introduction and SecurityIoT Introduction and Security
IoT Introduction and Security
Jongseok Choi
 
Gitlab.key
Gitlab.keyGitlab.key
Gitlab.key
Jongseok Choi
 
Web penetration
Web penetrationWeb penetration
Web penetration
Jongseok Choi
 
Svn
SvnSvn
Trend briefs security
Trend briefs securityTrend briefs security
Trend briefs security
Jongseok Choi
 
wordpress with nginx on virtualization, jail
wordpress with nginx on virtualization, jailwordpress with nginx on virtualization, jail
wordpress with nginx on virtualization, jail
Jongseok Choi
 
Web hacking 개요
Web hacking 개요Web hacking 개요
Web hacking 개요
Jongseok Choi
 
Virtualization
VirtualizationVirtualization
Virtualization
Jongseok Choi
 
Forensic 2
Forensic 2Forensic 2
Forensic 2
Jongseok Choi
 

More from Jongseok Choi (17)

Hyperledger 구조 분석
Hyperledger 구조 분석Hyperledger 구조 분석
Hyperledger 구조 분석
 
Blockchain trends and research
Blockchain trends and researchBlockchain trends and research
Blockchain trends and research
 
블록체인 개요
블록체인 개요블록체인 개요
블록체인 개요
 
Bitcoin and Ethereum
Bitcoin and EthereumBitcoin and Ethereum
Bitcoin and Ethereum
 
Effective Go
Effective GoEffective Go
Effective Go
 
oneM2M security summary
oneM2M security summaryoneM2M security summary
oneM2M security summary
 
Case Study on Intelligent IoT Platform
Case Study on Intelligent IoT PlatformCase Study on Intelligent IoT Platform
Case Study on Intelligent IoT Platform
 
oneM2M Introduction and security
oneM2M Introduction and securityoneM2M Introduction and security
oneM2M Introduction and security
 
IoT Introduction and Security
IoT Introduction and SecurityIoT Introduction and Security
IoT Introduction and Security
 
Gitlab.key
Gitlab.keyGitlab.key
Gitlab.key
 
Web penetration
Web penetrationWeb penetration
Web penetration
 
Svn
SvnSvn
Svn
 
Trend briefs security
Trend briefs securityTrend briefs security
Trend briefs security
 
wordpress with nginx on virtualization, jail
wordpress with nginx on virtualization, jailwordpress with nginx on virtualization, jail
wordpress with nginx on virtualization, jail
 
Web hacking 개요
Web hacking 개요Web hacking 개요
Web hacking 개요
 
Virtualization
VirtualizationVirtualization
Virtualization
 
Forensic 2
Forensic 2Forensic 2
Forensic 2
 

Recently uploaded

AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
kalichargn70th171
 

Recently uploaded (20)

AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
 

Basic of Exploitation

  • 2. Outline • What is exploitation • Study Points • CPU Registers & Instructions • Flow of Function • Managing Memory
  • 3. What is exploitation? • The kind of exploitation is various
 For software, hardware, system and etc. • What is the goal of the exploitation?
 The exploitation is getting actions you want it to do. • What is needed?
 Skill of computer languages
 Knowledge of Operating System
 Understanding architecture.

  • 4. Study Points • We will focus on :
 CPU registers,
 Understanding stack of computer,
 A glance about assembly and C • Why we study those
 Most of exploitations come from memory corruption.
  • 5. CPU Registers & Instructions • Cores of CPU
 CPU consists of registers, instructions. • What does the different architecture of CPU means?
 It means that they have the different instructions each others. • Are you hard to get assembly?
 Do not afraid to face it. Because assembly was made for us with human friendly representation of opcodes. • Special instructions
 EBP, ESP, EIP
  • 6. CPU Registers & Instructions • 16 bits data registers can be accessed to high and low half bits by AL&AH, BL&BH and etc. 16 Bits 32 Bits 64 Bits Description AX EAX RAX Accumulator BX EBX RBX Base Index CX ECX RCX Counter DX EDX RDX Data BP EBP RBP Base Pointer SP ESP RSP Stack Pointer IP EIP RIP Instruction Pointer SI ESI RSI Source Index Pointer DI EDI RDI Destination Index Pointer
  • 7. Composition of a Function void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } Name Parameters Body Return type
  • 8. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); }
  • 9. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); }
  • 10. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); }
  • 11. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); }
  • 12. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); }
  • 13. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]);
  • 14. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]);
  • 15. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]);
  • 16. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]);
  • 17. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]);
  • 18. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]);
  • 19. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]); func2(buffer);
  • 20. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]); func2(buffer);
  • 21. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]); func2(buffer);
  • 22. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]); func2(buffer);
  • 23. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]); func2(buffer);
  • 24. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]); func2(buffer);
  • 25. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]);
  • 26. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]);
  • 27. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]);
  • 28. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); } func1(argv[1]);
  • 29. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); }
  • 30. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); }
  • 31. Variation of Stack memory void func2(char *x) { printf(“You entered: %sn", x); } void func1(char *str) { char buffer[16]; strcpy(buffer, str); func2(buffer); } int main(int argc, char *argv[]) { if (argc > 1) func1(argv[1]); else printf(“No arguments!n"); }
  • 32. What is Stack? • Stack is one of data structure.
 LIFO - Last In First Out • Imagine reading book and stacking them. After reading them, we simply take over the top of books. In the circumstances, it is difficult to get a book in middle of the tower.
  • 33. Managing Memory • One of role of Operating System is managing memory. In order to manage memory, the memory is segmented into several parts. The way memory is segmented is depends on OS. However, main memory is existed and important in all OS. • Main memory is represented to “logical” structure and consists of several stack frames. • Stack frame is a significantly important part. The stack frame is represented by two pointers:
 Base pointer(EBP or RBP) indicates start of current stack frame.
 Stack pointer(ESP or RSP) indicates end of current stack frame.
  • 34. Back to Previous Position Empty memory Top of memory Start of memory Newer stack frame EBP ESP
  • 35. Back to Previous Position Empty memory Top of memory Start of memory Newer stack frame EBPESP
  • 36. Back to Previous Position Empty memory Top of memory Start of memory Newer stack frame EBP ESP
  • 37. Back to Previous Position Empty memory Top of memory Start of memory Newer stack frame EBP ESP
  • 38. Back to Previous Position Empty memory Top of memory Start of memory Newer stack frame EBP ESP
  • 39. Back to Previous Position Empty memory Top of memory Start of memory Newer stack frame EBPESP
  • 40. Back to Previous Position Empty memory Top of memory Start of memory Newer stack frame EBP ESP
  • 41. Back to Previous Position Empty memory Top of memory Start of memory Newer stack frame EBP ESP?
  • 42. Back to Previous Position Empty memory Saved EBP Top of memory Start of memory Newer stack frame EBP ESP
  • 43. Back to Previous Position Empty memory Saved EBP Top of memory Start of memory Newer stack frame EBPESP
  • 44. Back to Previous Position Empty memory Saved EBP Top of memory Start of memory Newer stack frame EBP ESP
  • 45. Back to Previous Position Empty memory Saved EBP Top of memory Start of memory Newer stack frame EBP ESP
  • 46. Back to Previous Position Empty memory Saved EBP Top of memory Start of memory Newer stack frame EBP ESP
  • 47. Back to Previous Position Empty memory Saved EBP Top of memory Start of memory Newer stack frame EBP ESP
  • 48. Back to Previous Position Empty memory Saved EBP Top of memory Start of memory Newer stack frame EBP ESP
  • 49. x86 calling conventions • There are three types for calling function.
 stdcall : The default call type of WinAPI32. A callee is responsible for cleaning stack frame for arguments.
 cdecl : The default call type of C. A caller is responsible for cleaning stack frame. • There are many call types.
  • 50. Difference between them push <arg2> push <arg1> call <callee> push ebp mov ebp esp push <local variables> pop ebp ret <args size> push <arg2> push <arg1> call <callee> push ebp mov ebp esp push <local variables> pop ebp ret 0 add esp <args size> Caller Callee Caller cdecl stdcall
  • 51. Thank you for listening.