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

PDF
StackOverflow
PDF
Symfony3 w duecie z Vue.js
PDF
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
PDF
Web Application Firewall: Suckseed or Succeed
PPTX
antoanthongtin_Lesson 3- Software Security (1).pptx
PPTX
Secure programming with php
PDF
DEFCON 23 - Jason Haddix - how do i shot web
PPTX
Introduction to path traversal attack
StackOverflow
Symfony3 w duecie z Vue.js
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Web Application Firewall: Suckseed or Succeed
antoanthongtin_Lesson 3- Software Security (1).pptx
Secure programming with php
DEFCON 23 - Jason Haddix - how do i shot web
Introduction to path traversal attack

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

PPTX
FBScanner: IBSurgeon's tool to solve all types of performance problems with F...
PPTX
Bsides final
PDF
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
PPTX
Reversing malware analysis training part10 exploit development basics
PPTX
Application and Website Security -- Fundamental Edition
PDF
Art of Web Backdoor - Pichaya Morimoto
PDF
BSides IR in Heterogeneous Environment
PPT
Download It
PDF
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PDF
Threat Con 2021: What's Hitting my Honeypots
PDF
Metasploit Humla for Beginner
PPTX
Advanced programming in unix.pptx
PPTX
CodeIgniter i18n Security Flaw
PDF
DEFCON 23 - Gerard Laygui - forensic artifacts pass the hash att
PPTX
[OWASP Poland Day] Application security - daily questions & answers
PDF
OSCP Preparation Guide @ Infosectrain
TXT
Tech websites
ODP
Pen test methodology
PDF
Pentesting RESTful webservices
FBScanner: IBSurgeon's tool to solve all types of performance problems with F...
Bsides final
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
Reversing malware analysis training part10 exploit development basics
Application and Website Security -- Fundamental Edition
Art of Web Backdoor - Pichaya Morimoto
BSides IR in Heterogeneous Environment
Download It
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
Threat Con 2021: What's Hitting my Honeypots
Metasploit Humla for Beginner
Advanced programming in unix.pptx
CodeIgniter i18n Security Flaw
DEFCON 23 - Gerard Laygui - forensic artifacts pass the hash att
[OWASP Poland Day] Application security - daily questions & answers
OSCP Preparation Guide @ Infosectrain
Tech websites
Pen test methodology
Pentesting RESTful webservices
Ad

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
AI in Product Development-omnex systems
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Strategies for Manufacturing Companies
PDF
System and Network Administraation Chapter 3
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
history of c programming in notes for students .pptx
Understanding Forklifts - TECH EHS Solution
Upgrade and Innovation Strategies for SAP ERP Customers
Reimagine Home Health with the Power of Agentic AI​
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Odoo Companies in India – Driving Business Transformation.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
L1 - Introduction to python Backend.pptx
AI in Product Development-omnex systems
How to Migrate SBCGlobal Email to Yahoo Easily
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
CHAPTER 2 - PM Management and IT Context
VVF-Customer-Presentation2025-Ver1.9.pptx
Nekopoi APK 2025 free lastest update
Digital Strategies for Manufacturing Companies
System and Network Administraation Chapter 3
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Navsoft: AI-Powered Business Solutions & Custom Software Development
history of c programming in notes for students .pptx
Ad

Introduction to Stack Buffer Over‌flow for beginners