SlideShare a Scribd company logo
Khashayar Fereidani
http://fereidani.com
Introduction to Stack Buffer Overflow for beginners
Islamic Azad University Of Najafabad
Network Security Presentation
By
Khashayar Fereidani
Khashayar Fereidani
http://fereidani.com
Who Am I ?
● Khashayar Fereidani
● Just A Security Enthusiast
Khashayar Fereidani
http://fereidani.com
3/23
First Of All
DEMO
Khashayar Fereidani
http://fereidani.com
What Is Buffer Overflow ?
From Dear Memory Corruption Family
Heap Overflow , Use After Free
Buffer Underflow , Integer Overflow
Buffer Overflow and more ...
Khashayar Fereidani
http://fereidani.com
What After Exploitation ?
1- File Control
2- Operation System Access
3 – Installing Backdoor
4- Full Device Access ( webcam / monitor / mic )
Khashayar Fereidani
http://fereidani.com
Advantages And Disadvantages
● Advantages
1- Effective 2- Locally And Remotely Exploitable
● Disadvantages
1- architecture dependent 2-operation system and even version dependent
3- high exploitation skills needed for this era .
Khashayar Fereidani
http://fereidani.com
New Era For Commercial Exploit
● Exploits from $1000 to $10000000
● Intelligent and Universal
● Die Dear Lamers
Khashayar Fereidani
http://fereidani.com
Some Historical Attacks
1- 1988 Morris worm
6000 machines ( 10% of internet )
2- 2003 SQL Slammer : overflow in MS-SQL server
75,000 machines infected in 10 minutes
3- 2014 Multiple Vulnerabilities in Microsoft /
Adobe / D-link / Cisco / Oracle products
Khashayar Fereidani
http://fereidani.com
9/23
Remember Remember
● ESP : Pointer To Top Of Stack
● EBP : Base Pointer
● EIP : Instruction Pointer
● MOV , JMP , CALL , RET
Khashayar Fereidani
http://fereidani.com
10/23
Introduction To Process Environment Block (PEB)
● Stack ( func , ret info , args )
● Heap
● Data Segment
1- .bss ( Static and uninitialized globals )
2- .data (initialized globals )
3- .text ( usually read only )
● Shared Libraries
Khashayar Fereidani
http://fereidani.com
11/23
Frame
Khashayar Fereidani
http://fereidani.com
12/23
Sample Code
bool authenticate(char *name){
char msg[32];
if (check_username(name)==0){
sprintf(msg, "Unauthorized user '%s'n", name);
Printf(“%s”,msg);
return 0;
}else{
printf("Welcome , %s n", name);
return 1;
}
}
Khashayar Fereidani
http://fereidani.com
13/23
Disassembled Code
0x08048529 <+0>:push %ebp
0x0804852a <+1>:mov %esp,%ebp
0x0804852c <+3>:sub $0x38,%esp
0x0804852f <+6>: mov 0x8(%ebp),%eax
0x08048532 <+9>:mov %eax,(%esp)
0x08048535 <+12>: call 0x804851f
<check_username>
0x0804853a <+17>: test %eax,%eax
0x0804853c <+19>: jne 0x8048572
<authenticate+73>
0x0804853e <+21>: mov 0x8(%ebp),%eax
0x08048541 <+24>: mov %eax,0x8(%esp)
0x08048545 <+28>: movl $0x8048620,0x4(%esp)
0x0804854d <+36>: lea -0x28(%ebp),%eax
0x08048550 <+39>: mov %eax,(%esp)
0x08048553 <+42>: call 0x8048390
<sprintf@plt>
0x08048558 <+47>: lea -0x28(%ebp),%eax
0x0804855b <+50>: mov %eax,0x4(%esp)
0x0804855f <+54>: movl $0x8048639,(%esp)
0x08048566 <+61>: call 0x8048350 <printf@plt>
0x0804856b <+66>: mov $0x0,%eax
0x08048570 <+71>: jmp 0x804858a
<authenticate+97>
0x08048572 <+73>: mov 0x8(%ebp),%eax
0x08048575 <+76>: mov %eax,0x4(%esp)
Khashayar Fereidani
http://fereidani.com
14/23
Point Of View From Stack
ARGV
ARGC
RET
…. main and previously called procedures ….
SAVED EIP
SAVED EBP
msg
Start Of authenticate frame
32 Byte
Khashayar Fereidani
http://fereidani.com
15/23
For Simple Input
ARGV
ARGC
RET
….
SAVED EIP
SAVED EBP
????????
????????
????????
????????
khashayar
Khashayar Fereidani
http://fereidani.com
16/23
For Evil One :D !
ARGV
ARGC
RET
….
AAAA (0x41414141)
AAAA (0x41414141)
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
Khashayar Fereidani
http://fereidani.com
17/23
Exploitation Theory
● Write Our Shellcode to memory
● Get Control Of EIP
● Jump To Our Shellcode
Khashayar Fereidani
http://fereidani.com
18/23
Implementation
ARGV
ARGC
RET
….
(0x[ADDRESS OF SHELLCODE])
0x90909090
NOPNOPNOPNOPNOP
SHELLCODE
SHELLCODE
SHELLCODE
SHELLCODE
Khashayar Fereidani
http://fereidani.com
19/23
What Is Shellcode ?
Khashayar Fereidani
http://fereidani.com
20/23
After Compile
xebx16x31xd2x5b
x88x53x04x53xbb
xedx2ax86x7cxff
xd3x52xbbx12xcb
x81x7cxffxd3xe8
xe5xffxffxffx63
x61x6cx63x4e
● 34 byte
● Exec Calc
Khashayar Fereidani
http://fereidani.com
21/23
Some OS Level Protections
● ASLR (First OpenBSD & Linux)
● DEP ( Software & Hardware )
● STACK GS / COOKIE
●But Bypassed in the wild !
Khashayar Fereidani
http://fereidani.com
22/23
Review An Exploit
Khashayar Fereidani
http://fereidani.com
23/23
Question ?

More Related Content

Similar to Introduction to Stack Buffer Over‌flow for beginners

Bsides final
Bsides finalBsides final
Bsides final
Collyn Hartley
 
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
bugcrowd
 
Reversing malware analysis training part10 exploit development basics
Reversing malware analysis training part10 exploit development basicsReversing malware analysis training part10 exploit development basics
Reversing malware analysis training part10 exploit development basics
Cysinfo Cyber Security Community
 
Application and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental EditionApplication and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental Edition
Daniel Owens
 
Flashack
FlashackFlashack
Art of Web Backdoor - Pichaya Morimoto
Art of Web Backdoor - Pichaya MorimotoArt of Web Backdoor - Pichaya Morimoto
Art of Web Backdoor - Pichaya Morimoto
Pichaya Morimoto
 
BSides IR in Heterogeneous Environment
BSides IR in Heterogeneous EnvironmentBSides IR in Heterogeneous Environment
BSides IR in Heterogeneous Environment
Stefano Maccaglia
 
Download It
Download ItDownload It
Download It
webhostingguy
 
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki LinnakangasPG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
pgdayrussia
 
Threat Con 2021: What's Hitting my Honeypots
Threat Con 2021: What's Hitting my HoneypotsThreat Con 2021: What's Hitting my Honeypots
Threat Con 2021: What's Hitting my Honeypots
APNIC
 
Metasploit Humla for Beginner
Metasploit Humla for BeginnerMetasploit Humla for Beginner
Metasploit Humla for Beginner
n|u - The Open Security Community
 
Advanced programming in unix.pptx
Advanced programming in unix.pptxAdvanced programming in unix.pptx
Advanced programming in unix.pptx
JONASJJONAS1
 
CodeIgniter i18n Security Flaw
CodeIgniter i18n Security FlawCodeIgniter i18n Security Flaw
CodeIgniter i18n Security Flaw
Abbas Naderi
 
DEFCON 23 - Gerard Laygui - forensic artifacts pass the hash att
DEFCON 23 - Gerard Laygui - forensic artifacts pass the hash attDEFCON 23 - Gerard Laygui - forensic artifacts pass the hash att
DEFCON 23 - Gerard Laygui - forensic artifacts pass the hash att
Felipe Prado
 
[OWASP Poland Day] Application security - daily questions & answers
[OWASP Poland Day] Application security - daily questions & answers[OWASP Poland Day] Application security - daily questions & answers
[OWASP Poland Day] Application security - daily questions & answers
OWASP
 
OSCP Preparation Guide @ Infosectrain
OSCP Preparation Guide @ InfosectrainOSCP Preparation Guide @ Infosectrain
OSCP Preparation Guide @ Infosectrain
InfosecTrain
 
Tech websites
Tech websitesTech websites
Tech websites
reddydivakara
 
Pen test methodology
Pen test methodologyPen test methodology
Pen test methodology
Cahyo Darujati
 
Pentesting RESTful webservices
Pentesting RESTful webservicesPentesting RESTful webservices
Pentesting RESTful webservices
Mohammed A. Imran
 
Sql Injections With Real Life Scenarious
Sql Injections With Real Life ScenariousSql Injections With Real Life Scenarious
Sql Injections With Real Life Scenarious
Francis Alexander
 

Similar to Introduction to Stack Buffer Over‌flow for beginners (20)

Bsides final
Bsides finalBsides final
Bsides final
 
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
 
Reversing malware analysis training part10 exploit development basics
Reversing malware analysis training part10 exploit development basicsReversing malware analysis training part10 exploit development basics
Reversing malware analysis training part10 exploit development basics
 
Application and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental EditionApplication and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental Edition
 
Flashack
FlashackFlashack
Flashack
 
Art of Web Backdoor - Pichaya Morimoto
Art of Web Backdoor - Pichaya MorimotoArt of Web Backdoor - Pichaya Morimoto
Art of Web Backdoor - Pichaya Morimoto
 
BSides IR in Heterogeneous Environment
BSides IR in Heterogeneous EnvironmentBSides IR in Heterogeneous Environment
BSides IR in Heterogeneous Environment
 
Download It
Download ItDownload It
Download It
 
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki LinnakangasPG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
 
Threat Con 2021: What's Hitting my Honeypots
Threat Con 2021: What's Hitting my HoneypotsThreat Con 2021: What's Hitting my Honeypots
Threat Con 2021: What's Hitting my Honeypots
 
Metasploit Humla for Beginner
Metasploit Humla for BeginnerMetasploit Humla for Beginner
Metasploit Humla for Beginner
 
Advanced programming in unix.pptx
Advanced programming in unix.pptxAdvanced programming in unix.pptx
Advanced programming in unix.pptx
 
CodeIgniter i18n Security Flaw
CodeIgniter i18n Security FlawCodeIgniter i18n Security Flaw
CodeIgniter i18n Security Flaw
 
DEFCON 23 - Gerard Laygui - forensic artifacts pass the hash att
DEFCON 23 - Gerard Laygui - forensic artifacts pass the hash attDEFCON 23 - Gerard Laygui - forensic artifacts pass the hash att
DEFCON 23 - Gerard Laygui - forensic artifacts pass the hash att
 
[OWASP Poland Day] Application security - daily questions & answers
[OWASP Poland Day] Application security - daily questions & answers[OWASP Poland Day] Application security - daily questions & answers
[OWASP Poland Day] Application security - daily questions & answers
 
OSCP Preparation Guide @ Infosectrain
OSCP Preparation Guide @ InfosectrainOSCP Preparation Guide @ Infosectrain
OSCP Preparation Guide @ Infosectrain
 
Tech websites
Tech websitesTech websites
Tech websites
 
Pen test methodology
Pen test methodologyPen test methodology
Pen test methodology
 
Pentesting RESTful webservices
Pentesting RESTful webservicesPentesting RESTful webservices
Pentesting RESTful webservices
 
Sql Injections With Real Life Scenarious
Sql Injections With Real Life ScenariousSql Injections With Real Life Scenarious
Sql Injections With Real Life Scenarious
 

Recently uploaded

SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
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
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
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
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
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
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
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
 
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
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
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
 
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
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 

Recently uploaded (20)

SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
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
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
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
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
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
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
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 ⚡️
 
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...
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
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
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 

Introduction to Stack Buffer Over‌flow for beginners