SlideShare a Scribd company logo
Buffer Overflow
Lab 8
Process Memory Regions
Higher memory addresses
Fixed address
Stack pointer
(SP) points to
top of stack

Lower memory addresses
Stack Frame
• Logical block
– pushed when calling a function
– popped when returning

• Contains:
– parameters to functions
– local variables
– data necessary to recover program state

• Frame pointer points to fixed location within
frame
– variables are referenced by offsets to the FP
Function Calls
Calling a Function
void function(int a, int b, int c){
char buffer1[5];
char buffer2[10];
}
void main() {
function(1,2,3);
}

1. Push 3 arguments
2. Push return address
3. Copy SP into FP to create
new FP and save it on the
stack (SFP)
4. Advance SP to reserve
space for local variables and
state information
Buffer Overflow
• What is a buffer?
– a contiguous block of memory that holds multiple
instances of the same data type

• What’s buffer overflow?
– Stuffing more data into a buffer than it can handle

• This common programming error can be taken
advantage of to execute arbitrary code
Example
void copy(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';
large_string[255] = '0';
copy(large_string);
return 0;
}

• strcpy() is copying the contents of *str (larger_string[]) into buffer[] until string NULL character
• buffer[] is much smaller than *str. (16 bytes vs. 256 bytes)
All 240 bytes after buffer in the stack are being overwritten (INCLUDING the SFP and RET)
• large_string is filled with the character 'A‘ (0x41)
RET = 0x41414141 which is outside of the process address space
• When the function returns and tries to read the next instruction from that address
=> Segmentation Fault!!!
Buffer Overflow Example
S
t
a
c
k
g
r
o
w
t
h

M
e
m
o
r
y
A
d
d
r
e
s
s
e
s

Parent Routine’s Stack
Frame

Parent Routine’s Stack
Frame

Parent Routine’s Stack
Frame

Function Arguments

Function Arguments

A

A

A

A

Return Address

Return Address

A

A

A

A

Saved Frame Pointer

Saved Frame Pointer

A

A

A

A

Char *bar

Char *bar

A

A

A

A

char buffer[16]

A

A

A

A

A

A

A

A

A

A

A

A

buffer[15]
char buffer[16]

buffer[0]
Unallocated Stack Space

0

l

l

o

e

h

Unallocated Stack Space

Unallocated Stack Space
Exploiting Buffer Overflow
• A buffer overflow allows us to change the
return address of a function
• We can change the flow of execution of the
program and execute arbitrary code
• Which code?
– Spawn a shell so we can execute anything
How to Execute Our Code?
• Place the code we are trying to execute in the
buffer we are overflowing
• Overwrite the return address so it points back
into the buffer
Lab 8
• Build sthttpd: light-weight HTTP server and apply patch
to introduce vulnerability
–
–
–
–

$ tar xvf sthttpd-2.26.4.tar.gz
$ cd sthttpd-2.26.4
$ patch –pNUM < patch_file
$ ./configure and make (with -fno-stack-protector)

• Run it on port 12100 – 12327
– ./thttpd –p 12100
– Run $ ps aux | grep thttpd, and make sure that no one
else is using your port

• Do a simple request like
– wget http://localhost:12100
Crashing The Server
• Send the web server a suitably-formatted
request
– $ wget http://localhost:12100/AAAA...AA
– How many A’s should there be?

• Where does the buffer overflow occur? Why?
– Look at the code
Lab Hints
• Run the web server under GDB and get traceback (bt) after the crash
–./thttpd –p 8080
– Find the pid for thttpd
ps –aux | grep thttpd
– Run gdb
$ gdb
$ (gdb) attach <pid>
– Send your crashing request (from the web browser, or another terminal
using wget or curl)
– Continue(c) and when it crashes do bt
– Include this in lab8.txt
• Describe how you would build a remote exploit in the modified thttpd
–Smashing the stack for Fun and Profit will be helpful
Lab Hints
• How to create assembly language files (.s files)
– Remove the .o file
• $ rm thttpd.o

– Edit Makefile using your favorite editor
• $ vim Makefile

– Search for ‘CFLAGS’ flag
• Add -S after -O2
• CFLAGS = -O2 –S
• Save and quit

– Make the removed .o file
• $ make thttpd.o

– You will see ‘thttpd.s’ or ‘thttps.o’ has been created with
assembly code in it
Lab
• Adding options to ./configure and make
– $ CC=gcc CFLAGS=options1 LDFLAGS=options2 ./configure
• $ CC=gcc CFLAGS='-fmudflap -fno-stack-protector' LDFLAGS=lmudflap ./configure

– $ CC=gcc CFLAGS=options1 LDFLAGS=options2 make
• $ CC=gcc CFLAGS='-fmudflap -fno-stack-protector' LDFLAGS=lmudflap make

– Options for CFLAGS
• -fno-stack-protector
• -fstack-protector
• -fmudflap

– Options for LDFLAGS
• -lmudflap

More Related Content

What's hot

Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
GeeksLab Odessa
 
CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly
Sam Bowne
 
postgres loader
postgres loaderpostgres loader
postgres loader
INRIA-OAK
 
System Programming and Administration
System Programming and AdministrationSystem Programming and Administration
System Programming and Administration
Krasimir Berov (Красимир Беров)
 
Memory allocation
Memory allocationMemory allocation
Memory allocation
sanya6900
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
Stefan
 
Robert Metzger - Connecting Apache Flink to the World - Reviewing the streami...
Robert Metzger - Connecting Apache Flink to the World - Reviewing the streami...Robert Metzger - Connecting Apache Flink to the World - Reviewing the streami...
Robert Metzger - Connecting Apache Flink to the World - Reviewing the streami...
Flink Forward
 
Introduction to c part -3
Introduction to c   part -3Introduction to c   part -3
Run time
Run timeRun time
Central processing unit and stack organization r013
Central processing unit and stack organization   r013Central processing unit and stack organization   r013
Central processing unit and stack organization r013
arunachalamr16
 
Apache Crunch
Apache CrunchApache Crunch
Apache Crunch
Alwin James
 
Csp scala wixmeetup2016
Csp scala wixmeetup2016Csp scala wixmeetup2016
Csp scala wixmeetup2016
Ruslan Shevchenko
 
Csa stack
Csa stackCsa stack
Csa stack
PCTE
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
Ruslan Shevchenko
 
Presto overview
Presto overviewPresto overview
Presto overview
Shixiong Zhu
 
Clojure+ClojureScript Webapps
Clojure+ClojureScript WebappsClojure+ClojureScript Webapps
Clojure+ClojureScript Webapps
Falko Riemenschneider
 
Introduction to knitr - May Sheffield R Users group
Introduction to knitr - May Sheffield R Users groupIntroduction to knitr - May Sheffield R Users group
Introduction to knitr - May Sheffield R Users group
Paul Richards
 
Access to non local names
Access to non local namesAccess to non local names
Access to non local names
Varsha Kumar
 
AllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW SecurityAllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW Security
AllBits BVBA (freelancer)
 

What's hot (19)

Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
 
CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly
 
postgres loader
postgres loaderpostgres loader
postgres loader
 
System Programming and Administration
System Programming and AdministrationSystem Programming and Administration
System Programming and Administration
 
Memory allocation
Memory allocationMemory allocation
Memory allocation
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
Robert Metzger - Connecting Apache Flink to the World - Reviewing the streami...
Robert Metzger - Connecting Apache Flink to the World - Reviewing the streami...Robert Metzger - Connecting Apache Flink to the World - Reviewing the streami...
Robert Metzger - Connecting Apache Flink to the World - Reviewing the streami...
 
Introduction to c part -3
Introduction to c   part -3Introduction to c   part -3
Introduction to c part -3
 
Run time
Run timeRun time
Run time
 
Central processing unit and stack organization r013
Central processing unit and stack organization   r013Central processing unit and stack organization   r013
Central processing unit and stack organization r013
 
Apache Crunch
Apache CrunchApache Crunch
Apache Crunch
 
Csp scala wixmeetup2016
Csp scala wixmeetup2016Csp scala wixmeetup2016
Csp scala wixmeetup2016
 
Csa stack
Csa stackCsa stack
Csa stack
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
 
Presto overview
Presto overviewPresto overview
Presto overview
 
Clojure+ClojureScript Webapps
Clojure+ClojureScript WebappsClojure+ClojureScript Webapps
Clojure+ClojureScript Webapps
 
Introduction to knitr - May Sheffield R Users group
Introduction to knitr - May Sheffield R Users groupIntroduction to knitr - May Sheffield R Users group
Introduction to knitr - May Sheffield R Users group
 
Access to non local names
Access to non local namesAccess to non local names
Access to non local names
 
AllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW SecurityAllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW Security
 

Viewers also liked

Al2ed chapter7
Al2ed chapter7Al2ed chapter7
Al2ed chapter7
Abdullelah Al-Fahad
 
2006 ssiai
2006 ssiai2006 ssiai
Buffer Overflows 101: Some Assembly Required
Buffer Overflows 101: Some Assembly RequiredBuffer Overflows 101: Some Assembly Required
Buffer Overflows 101: Some Assembly Required
Kory Kyzar
 
DEP/ASLR bypass without ROP/JIT
DEP/ASLR bypass without ROP/JITDEP/ASLR bypass without ROP/JIT
DEP/ASLR bypass without ROP/JIT
Artem I. Baranov
 
Fuzzing | Null OWASP Mumbai | 2016 June
Fuzzing | Null OWASP Mumbai | 2016 JuneFuzzing | Null OWASP Mumbai | 2016 June
Fuzzing | Null OWASP Mumbai | 2016 June
nullowaspmumbai
 
Shellcode injection
Shellcode injectionShellcode injection
Shellcode injection
Dhaval Kapil
 
Buffer Overflow
Buffer OverflowBuffer Overflow
Buffer Overflow
Kaustubh Padwad
 
6 buffer overflows
6   buffer overflows6   buffer overflows
6 buffer overflows
drewz lin
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
Mustafa Salah
 
Exploiting stack overflow 101
Exploiting stack overflow 101Exploiting stack overflow 101
Exploiting stack overflow 101
n|u - The Open Security Community
 
Exploit Development
Exploit DevelopmentExploit Development
Exploit Development
kyaw thiha
 
APT(Advanced Persistent Threats) & strategies to counter APT
APT(Advanced Persistent Threats) & strategies to counter APTAPT(Advanced Persistent Threats) & strategies to counter APT
APT(Advanced Persistent Threats) & strategies to counter APT
Avkash Kathiriya
 
Installation of Drupal on Windows XP with XAMPP
Installation of Drupal on Windows XP with XAMPPInstallation of Drupal on Windows XP with XAMPP
Installation of Drupal on Windows XP with XAMPP
Rupesh Kumar
 
Smashing The Stack
Smashing The StackSmashing The Stack
Smashing The Stack
Daniele Bellavista
 
Exploit development 101 - Part 1 - Null Singapore
Exploit development 101 - Part 1 - Null SingaporeExploit development 101 - Part 1 - Null Singapore
Exploit development 101 - Part 1 - Null Singapore
Mohammed A. Imran
 
8086 addressing modes
8086 addressing modes8086 addressing modes
8086 addressing modes
j4jiet
 
Buffer Overflow Attacks
Buffer Overflow AttacksBuffer Overflow Attacks
Buffer Overflow Attacks
harshal kshatriya
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
Kapil Nagrale
 
11 instruction sets addressing modes
11  instruction sets addressing modes 11  instruction sets addressing modes
11 instruction sets addressing modes
Sher Shah Merkhel
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
Evgeni Tsonev
 

Viewers also liked (20)

Al2ed chapter7
Al2ed chapter7Al2ed chapter7
Al2ed chapter7
 
2006 ssiai
2006 ssiai2006 ssiai
2006 ssiai
 
Buffer Overflows 101: Some Assembly Required
Buffer Overflows 101: Some Assembly RequiredBuffer Overflows 101: Some Assembly Required
Buffer Overflows 101: Some Assembly Required
 
DEP/ASLR bypass without ROP/JIT
DEP/ASLR bypass without ROP/JITDEP/ASLR bypass without ROP/JIT
DEP/ASLR bypass without ROP/JIT
 
Fuzzing | Null OWASP Mumbai | 2016 June
Fuzzing | Null OWASP Mumbai | 2016 JuneFuzzing | Null OWASP Mumbai | 2016 June
Fuzzing | Null OWASP Mumbai | 2016 June
 
Shellcode injection
Shellcode injectionShellcode injection
Shellcode injection
 
Buffer Overflow
Buffer OverflowBuffer Overflow
Buffer Overflow
 
6 buffer overflows
6   buffer overflows6   buffer overflows
6 buffer overflows
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
 
Exploiting stack overflow 101
Exploiting stack overflow 101Exploiting stack overflow 101
Exploiting stack overflow 101
 
Exploit Development
Exploit DevelopmentExploit Development
Exploit Development
 
APT(Advanced Persistent Threats) & strategies to counter APT
APT(Advanced Persistent Threats) & strategies to counter APTAPT(Advanced Persistent Threats) & strategies to counter APT
APT(Advanced Persistent Threats) & strategies to counter APT
 
Installation of Drupal on Windows XP with XAMPP
Installation of Drupal on Windows XP with XAMPPInstallation of Drupal on Windows XP with XAMPP
Installation of Drupal on Windows XP with XAMPP
 
Smashing The Stack
Smashing The StackSmashing The Stack
Smashing The Stack
 
Exploit development 101 - Part 1 - Null Singapore
Exploit development 101 - Part 1 - Null SingaporeExploit development 101 - Part 1 - Null Singapore
Exploit development 101 - Part 1 - Null Singapore
 
8086 addressing modes
8086 addressing modes8086 addressing modes
8086 addressing modes
 
Buffer Overflow Attacks
Buffer Overflow AttacksBuffer Overflow Attacks
Buffer Overflow Attacks
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
11 instruction sets addressing modes
11  instruction sets addressing modes 11  instruction sets addressing modes
11 instruction sets addressing modes
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
 

Similar to test

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
 
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 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
 
Buffer Overflows
Buffer OverflowsBuffer Overflows
Buffer Overflows
Sumit Kumar
 
CNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugsCNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugs
Sam Bowne
 
CNIT 127: Ch 4: Introduction to format string bugs
CNIT 127: Ch 4: Introduction to format string bugsCNIT 127: Ch 4: Introduction to format string bugs
CNIT 127: Ch 4: Introduction to format string bugs
Sam Bowne
 
Osd ctw spark
Osd ctw sparkOsd ctw spark
Osd ctw spark
Wisely chen
 
Lec05
Lec05Lec05
CNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugsCNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugs
Sam Bowne
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
Japneet Singh
 
CNIT 127: 4: Format string bugs
CNIT 127: 4: Format string bugsCNIT 127: 4: Format string bugs
CNIT 127: 4: Format string bugs
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
 
Memory Management with Java and C++
Memory Management with Java and C++Memory Management with Java and C++
Memory Management with Java and C++
Mohammad Shaker
 
FBTFTP: an opensource framework to build dynamic tftp servers
FBTFTP: an opensource framework to build dynamic tftp serversFBTFTP: an opensource framework to build dynamic tftp servers
FBTFTP: an opensource framework to build dynamic tftp servers
Angelo Failla
 
Bypassing ASLR Exploiting CVE 2015-7545
Bypassing ASLR Exploiting CVE 2015-7545Bypassing ASLR Exploiting CVE 2015-7545
Bypassing ASLR Exploiting CVE 2015-7545
Kernel TLV
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploits
hughpearse
 
Bypassing DEP using ROP
Bypassing DEP using ROPBypassing DEP using ROP
Bypassing DEP using ROP
Japneet Singh
 
H2O World - What's New in H2O with Cliff Click
H2O World - What's New in H2O with Cliff ClickH2O World - What's New in H2O with Cliff Click
H2O World - What's New in H2O with Cliff Click
Sri Ambati
 
Compilation and Execution
Compilation and ExecutionCompilation and Execution
Compilation and Execution
Chong-Kuan Chen
 

Similar to test (20)

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
 
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 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
 
Buffer Overflows
Buffer OverflowsBuffer Overflows
Buffer Overflows
 
CNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugsCNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugs
 
CNIT 127: Ch 4: Introduction to format string bugs
CNIT 127: Ch 4: Introduction to format string bugsCNIT 127: Ch 4: Introduction to format string bugs
CNIT 127: Ch 4: Introduction to format string bugs
 
Osd ctw spark
Osd ctw sparkOsd ctw spark
Osd ctw spark
 
Lec05
Lec05Lec05
Lec05
 
CNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugsCNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugs
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
CNIT 127: 4: Format string bugs
CNIT 127: 4: Format string bugsCNIT 127: 4: Format string bugs
CNIT 127: 4: Format string bugs
 
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
 
Memory Management with Java and C++
Memory Management with Java and C++Memory Management with Java and C++
Memory Management with Java and C++
 
FBTFTP: an opensource framework to build dynamic tftp servers
FBTFTP: an opensource framework to build dynamic tftp serversFBTFTP: an opensource framework to build dynamic tftp servers
FBTFTP: an opensource framework to build dynamic tftp servers
 
Bypassing ASLR Exploiting CVE 2015-7545
Bypassing ASLR Exploiting CVE 2015-7545Bypassing ASLR Exploiting CVE 2015-7545
Bypassing ASLR Exploiting CVE 2015-7545
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploits
 
Bypassing DEP using ROP
Bypassing DEP using ROPBypassing DEP using ROP
Bypassing DEP using ROP
 
H2O World - What's New in H2O with Cliff Click
H2O World - What's New in H2O with Cliff ClickH2O World - What's New in H2O with Cliff Click
H2O World - What's New in H2O with Cliff Click
 
Compilation and Execution
Compilation and ExecutionCompilation and Execution
Compilation and Execution
 

Recently uploaded

EV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker JamiesonEV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker Jamieson
Forth
 
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
ggany
 
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt HertensteinCharging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Forth
 
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
afkxen
 
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
afkxen
 
EV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin DonnellyEV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin Donnelly
Forth
 
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
MarynaYurchenko2
 
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
utuvvas
 
Dahua Security Camera System Guide esetia
Dahua Security Camera System Guide esetiaDahua Security Camera System Guide esetia
Dahua Security Camera System Guide esetia
Esentia Systems
 
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program  by Kevin MillerCharging Fueling & Infrastructure (CFI) Program  by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
Forth
 
Here's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDsHere's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDs
jennifermiller8137
 
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat PleinCharging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Forth
 
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa WarheitExpanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Forth
 
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
78tq3hi2
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
u2cz10zq
 
Catalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptxCatalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptx
Blue Star Brothers
 
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
g1inbfro
 
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
78tq3hi2
 

Recently uploaded (18)

EV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker JamiesonEV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker Jamieson
 
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
 
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt HertensteinCharging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
 
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
 
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
 
EV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin DonnellyEV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin Donnelly
 
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
 
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
 
Dahua Security Camera System Guide esetia
Dahua Security Camera System Guide esetiaDahua Security Camera System Guide esetia
Dahua Security Camera System Guide esetia
 
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program  by Kevin MillerCharging Fueling & Infrastructure (CFI) Program  by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
 
Here's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDsHere's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDs
 
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat PleinCharging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
 
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa WarheitExpanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
 
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
 
Catalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptxCatalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptx
 
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
 
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
 

test

  • 2. Process Memory Regions Higher memory addresses Fixed address Stack pointer (SP) points to top of stack Lower memory addresses
  • 3. Stack Frame • Logical block – pushed when calling a function – popped when returning • Contains: – parameters to functions – local variables – data necessary to recover program state • Frame pointer points to fixed location within frame – variables are referenced by offsets to the FP
  • 5. Calling a Function void function(int a, int b, int c){ char buffer1[5]; char buffer2[10]; } void main() { function(1,2,3); } 1. Push 3 arguments 2. Push return address 3. Copy SP into FP to create new FP and save it on the stack (SFP) 4. Advance SP to reserve space for local variables and state information
  • 6. Buffer Overflow • What is a buffer? – a contiguous block of memory that holds multiple instances of the same data type • What’s buffer overflow? – Stuffing more data into a buffer than it can handle • This common programming error can be taken advantage of to execute arbitrary code
  • 7. Example void copy(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'; large_string[255] = '0'; copy(large_string); return 0; } • strcpy() is copying the contents of *str (larger_string[]) into buffer[] until string NULL character • buffer[] is much smaller than *str. (16 bytes vs. 256 bytes) All 240 bytes after buffer in the stack are being overwritten (INCLUDING the SFP and RET) • large_string is filled with the character 'A‘ (0x41) RET = 0x41414141 which is outside of the process address space • When the function returns and tries to read the next instruction from that address => Segmentation Fault!!!
  • 8. Buffer Overflow Example S t a c k g r o w t h M e m o r y A d d r e s s e s Parent Routine’s Stack Frame Parent Routine’s Stack Frame Parent Routine’s Stack Frame Function Arguments Function Arguments A A A A Return Address Return Address A A A A Saved Frame Pointer Saved Frame Pointer A A A A Char *bar Char *bar A A A A char buffer[16] A A A A A A A A A A A A buffer[15] char buffer[16] buffer[0] Unallocated Stack Space 0 l l o e h Unallocated Stack Space Unallocated Stack Space
  • 9. Exploiting Buffer Overflow • A buffer overflow allows us to change the return address of a function • We can change the flow of execution of the program and execute arbitrary code • Which code? – Spawn a shell so we can execute anything
  • 10. How to Execute Our Code? • Place the code we are trying to execute in the buffer we are overflowing • Overwrite the return address so it points back into the buffer
  • 11. Lab 8 • Build sthttpd: light-weight HTTP server and apply patch to introduce vulnerability – – – – $ tar xvf sthttpd-2.26.4.tar.gz $ cd sthttpd-2.26.4 $ patch –pNUM < patch_file $ ./configure and make (with -fno-stack-protector) • Run it on port 12100 – 12327 – ./thttpd –p 12100 – Run $ ps aux | grep thttpd, and make sure that no one else is using your port • Do a simple request like – wget http://localhost:12100
  • 12. Crashing The Server • Send the web server a suitably-formatted request – $ wget http://localhost:12100/AAAA...AA – How many A’s should there be? • Where does the buffer overflow occur? Why? – Look at the code
  • 13. Lab Hints • Run the web server under GDB and get traceback (bt) after the crash –./thttpd –p 8080 – Find the pid for thttpd ps –aux | grep thttpd – Run gdb $ gdb $ (gdb) attach <pid> – Send your crashing request (from the web browser, or another terminal using wget or curl) – Continue(c) and when it crashes do bt – Include this in lab8.txt • Describe how you would build a remote exploit in the modified thttpd –Smashing the stack for Fun and Profit will be helpful
  • 14. Lab Hints • How to create assembly language files (.s files) – Remove the .o file • $ rm thttpd.o – Edit Makefile using your favorite editor • $ vim Makefile – Search for ‘CFLAGS’ flag • Add -S after -O2 • CFLAGS = -O2 –S • Save and quit – Make the removed .o file • $ make thttpd.o – You will see ‘thttpd.s’ or ‘thttps.o’ has been created with assembly code in it
  • 15. Lab • Adding options to ./configure and make – $ CC=gcc CFLAGS=options1 LDFLAGS=options2 ./configure • $ CC=gcc CFLAGS='-fmudflap -fno-stack-protector' LDFLAGS=lmudflap ./configure – $ CC=gcc CFLAGS=options1 LDFLAGS=options2 make • $ CC=gcc CFLAGS='-fmudflap -fno-stack-protector' LDFLAGS=lmudflap make – Options for CFLAGS • -fno-stack-protector • -fstack-protector • -fmudflap – Options for LDFLAGS • -lmudflap