SlideShare a Scribd company logo
Anatomy of Stack Overflow attack113 August 2016
Buffer Overflow – a Demo
Bhaskar K. Divecha
+91 – 98193 36001
Anatomy of Stack Overflow attack213 August 2016
Buffer Overflow – a Demo
This session :
• Explains Buffer overflow in simple manner
• Demos Exploitation of vulnerable program
– Works on the Vulnerable C Program
– Tweaks the stack (by sending data to
program)
– Modifies the return address in stack
– Calls some other instruction
Anatomy of Stack Overflow attack313 August 2016
Buffer Overflow – a Demo
What is Buffer overflow?
Buffer overflow is an anomaly where a
program, while writing data to a buffer,
overruns the buffer's boundary and
overwrites adjacent memory locations.
Anatomy of Stack Overflow attack413 August 2016
Buffer Overflow – a Demo
What is Buffer overflow? ...contd.
A buffer overflow condition exists when a
program attempts to put more data in a
buffer than it can hold.
It can corrupt data, crash the program, or
cause the execution of malicious code.
Anatomy of Stack Overflow attack513 August 2016
Buffer Overflow – a Demo
The Exploit
Many memory manipulation functions in C
and C++ do not perform bounds checking
and can easily overwrite the allocated
bounds of the buffers they operate upon.
We will exploit such a vulnerable C program.
Anatomy of Stack Overflow attack613 August 2016
Buffer Overflow – a Demo
The Exploit
We will exploit such a vulnerable C program
by:
– Tweaking the stack (by sending data to
program)
– Modifying the return address in stack
– Calling some other instruction
Anatomy of Stack Overflow attack713 August 2016
Buffer Overflow – a Demo
The Vulnerable Program
void bbFunction1();
main(int bbArgc,char *bbArgv[])
{
int bbVbl = 12;
printf("nValue of bbENV variable before calling bbFunction1 is : %dn",bbVbl);
bbFunction1();
bbVbl = 100;
printf("nValue of bbENV variable after calling bbFunction1 is : %dn",bbVbl);
}
void bbFunction1()
{
char *bbENV, bbBuff[3]="BB";
bbENV=getenv("bbENV");
strcpy(bbBuff,bbENV);
printf("nThe value of Env Vbl "bbENV" is -%s-n",bbBuff);
__asm { int 3 }
}
This programs looks quite
safe for the usual
programmer. .
Anatomy of Stack Overflow attack813 August 2016
Buffer Overflow – a Demo
The Result of Normal run of the program
D:>set bbENV=ABC
D:>bbEnvVariable.exe
Value of bbENV variable before calling bbFunction1 is : 12
The value of Env Vbl "bbENV" is -ABC-
Value of bbENV variable after calling bbFunction1 is : 100
D:>
Anatomy of Stack Overflow attack913 August 2016
Buffer Overflow – a Demo
The Vulnerable Program
void bbFunction1();
main(int bbArgc,char *bbArgv[])
{
int bbVbl = 12;
printf("nValue of bbENV variable before calling bbFunction1 is : %dn",bbVbl);
bbFunction1();
00401021 bbVbl = 100; ▬► This instruction is bypassed
0040102C printf("nValue of bbENV variable after calling bbFunction1 is : %dn",bbVbl);
}
void bbFunction1()
{
char *bbENV, bbBuff[3]="BB";
bbENV=getenv("bbENV");
strcpy(bbBuff,bbENV);
printf("nThe value of Env Vbl "bbENV" is -%s-n",bbBuff);
__asm { int 3 }
}
This programs looks quite
safe for the usual
programmer. But in fact
we can bypass certain
instructions and call
altogether the different
instruction by crafting the
Environment Variable.
Anatomy of Stack Overflow attack1013 August 2016
Buffer Overflow – a Demo
The Result of the program after the Exploit
D:>set bbENV=ABCD1234,
D:>bbEnvVariable
Value of bbENV variable before calling bbFunction1 is : 12
The value of Env Vbl "bbENV" is -ABCD1234,-
Value of bbENV variable after calling bbFunction1 is : 12
D:>
Anatomy of Stack Overflow attack1113 August 2016
Buffer Overflow – a Demo
Know the Concepts to Exploit this Program
1. Stack, it’s contents and it’s working during
function calls and returns.
Stack - a LIFO memory structure where all the
function parameters (incl. Commandline
arguments), return addresses and the local
variables of the function are stored. It grows
downward in memory (from higher address
space to lower address space).
Anatomy of Stack Overflow attack1213 August 2016
Buffer Overflow – a Demo
Know the Concepts to Exploit this Program
... contd.
2. Registers
Registers are 4 bytes or 32 bits as the binary
is compiled for a 32 bit system.
Anatomy of Stack Overflow attack1313 August 2016
Buffer Overflow – a Demo
Know the Concepts to Exploit this Program
... contd.
2. Registers
%eip: The Instruction pointer register stores
the address of the next instruction to be
executed. After every instruction execution
it’s value is incremented depending upon
the size of an instrution.
Anatomy of Stack Overflow attack1413 August 2016
Buffer Overflow – a Demo
Know the Concepts to Exploit this Program
... contd.
2. Registers
%esp: The Stack pointer register stores the
address of the top of the stack. This is the
address of the last element on the stack. It
points to the value in stack at the lowest
memory address.
Anatomy of Stack Overflow attack1513 August 2016
Buffer Overflow – a Demo
Know the Concepts to Exploit this Program
... contd.
2. Registers
%ebp: The Base pointer register usually set to
%esp at the start of the function. This is done
to keep tab of function parameters & local
variables. Local variables are accessed by
subtracting offsets from %ebp & function
parameters are accessed by adding offsets to
it.
Anatomy of Stack Overflow attack1613 August 2016
Buffer Overflow – a Demo
Disassembly of a Vulnerable Program
...
int bbVbl = 12;
printf("nValue of bbENV variable before calling bbFunction1 is : %dn",bbVbl);
bbFunction1();
00401021 bbVbl = 100; ▬► This instruction is bypassed by crafting Environment Variable
0040102C printf("nValue of bbENV variable after calling bbFunction1 is : %dn",bbVbl);
}
00401004 C7 45 FC 0C 00 00 00 mov dword ptr [ebp-4],0Ch ▬► int bbVbl = 12;
0040100B 8B 45 FC mov eax,dword ptr [ebp-4]
0040100E 50 push eax
0040100F 68 00 D0 40 00 push 40D000h
00401014 E8 76 00 00 00 call 0040108F ▬► printf “BEFORE” calling bbFunction1()
00401019 83 C4 08 add esp,8
0040101C E8 1F 00 00 00 call 00401040
00401021 C7 45 FC 64 00 00 00 mov dword ptr [ebp-4],64h ▬► bbVal = 100; (BYPASSED)
00401028 8B 4D FC mov ecx,dword ptr [ebp-4]
0040102B 51 push ecx
0040102C 68 3C D0 40 00 push 40D03Ch
00401031 E8 59 00 00 00 call 0040108F ▬► printf “AFTER” calling bbFunction1()
Anatomy of Stack Overflow attack1713 August 2016
Buffer Overflow – a Demo
Anatomy of Stack Overflow attack1813 August 2016
Buffer Overflow – a Demo
Anatomy of Stack Overflow attack1913 August 2016
Buffer Overflow – a Demo
References
While there are tons of information available on
Internet, I glanced through following 2 sites:
https://dhavalkapil.com/blogs/Buffer-Overflow-Exploit/
https://www.owasp.org/index.php/Buffer_Overflow
Anatomy of Stack Overflow attack2013 August 2016
Thank You
Bhaskar K. Divecha
+91 – 98193 36001
Buffer Overflow – a Demo
Ad

Recommended

Buffer Overflow Attacks
Buffer Overflow Attacks
harshal kshatriya
 
Buffer Overflows
Buffer Overflows
Sumit Kumar
 
Buffer overflow
Buffer overflow
Evgeni Tsonev
 
6 buffer overflows
6 buffer overflows
drewz lin
 
Buffer Overflow Demo by Saurabh Sharma
Buffer Overflow Demo by Saurabh Sharma
n|u - The Open Security Community
 
Presentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasures
tharindunew
 
Control hijacking
Control hijacking
Prachi Gulihar
 
Buffer overflow attacks
Buffer overflow attacks
Kapil Nagrale
 
Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow Attack
Rob Gillen
 
2.Format Strings
2.Format Strings
phanleson
 
Buffer overflow attacks
Buffer overflow attacks
Joe McCarthy
 
Buffer overflow attacks
Buffer overflow attacks
Japneet Singh
 
How to find_vulnerability_in_software
How to find_vulnerability_in_software
sanghwan ahn
 
Buffer Overflow - Smashing the Stack
Buffer Overflow - Smashing the Stack
ironSource
 
08 - Return Oriented Programming, the chosen one
08 - Return Oriented Programming, the chosen one
Alexandre Moneger
 
Fuzzing: Finding Your Own Bugs and 0days! at Arab Security Conference
Fuzzing: Finding Your Own Bugs and 0days! at Arab Security Conference
Rodolpho Concurde
 
Buffer overflow attack
Buffer overflow attack
Krish
 
C format string vulnerability
C format string vulnerability
sluge
 
Leak kernel pointer by exploiting uninitialized uses in Linux kernel
Leak kernel pointer by exploiting uninitialized uses in Linux kernel
JinbumPark
 
Format string vunerability
Format string vunerability
nuc13us
 
Fuzzing: Finding Your Own Bugs and 0days! 1.0
Fuzzing: Finding Your Own Bugs and 0days! 1.0
Rodolpho Concurde
 
From SEH Overwrite with Egg Hunter to Get a Shell!
From SEH Overwrite with Egg Hunter to Get a Shell!
Rodolpho Concurde
 
Perl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testing
Vlatko Kosturjak
 
Metasploit for Penetration Testing: Beginner Class
Metasploit for Penetration Testing: Beginner Class
Georgia Weidman
 
Return oriented programming (ROP)
Return oriented programming (ROP)
Pipat Methavanitpong
 
Ricardo J. Rodríguez & Daniel Uroz - When ROP meets Turing: Automatic Generat...
Ricardo J. Rodríguez & Daniel Uroz - When ROP meets Turing: Automatic Generat...
RootedCON
 
Dynamic Binary Instrumentation
Dynamic Binary Instrumentation
Cysinfo Cyber Security Community
 
Exploiting stack overflow 101
Exploiting stack overflow 101
n|u - The Open Security Community
 
3Es of Ransomware
3Es of Ransomware
Sunil Kumar
 
Http2 Security Perspective
Http2 Security Perspective
Sunil Kumar
 

More Related Content

What's hot (20)

Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow Attack
Rob Gillen
 
2.Format Strings
2.Format Strings
phanleson
 
Buffer overflow attacks
Buffer overflow attacks
Joe McCarthy
 
Buffer overflow attacks
Buffer overflow attacks
Japneet Singh
 
How to find_vulnerability_in_software
How to find_vulnerability_in_software
sanghwan ahn
 
Buffer Overflow - Smashing the Stack
Buffer Overflow - Smashing the Stack
ironSource
 
08 - Return Oriented Programming, the chosen one
08 - Return Oriented Programming, the chosen one
Alexandre Moneger
 
Fuzzing: Finding Your Own Bugs and 0days! at Arab Security Conference
Fuzzing: Finding Your Own Bugs and 0days! at Arab Security Conference
Rodolpho Concurde
 
Buffer overflow attack
Buffer overflow attack
Krish
 
C format string vulnerability
C format string vulnerability
sluge
 
Leak kernel pointer by exploiting uninitialized uses in Linux kernel
Leak kernel pointer by exploiting uninitialized uses in Linux kernel
JinbumPark
 
Format string vunerability
Format string vunerability
nuc13us
 
Fuzzing: Finding Your Own Bugs and 0days! 1.0
Fuzzing: Finding Your Own Bugs and 0days! 1.0
Rodolpho Concurde
 
From SEH Overwrite with Egg Hunter to Get a Shell!
From SEH Overwrite with Egg Hunter to Get a Shell!
Rodolpho Concurde
 
Perl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testing
Vlatko Kosturjak
 
Metasploit for Penetration Testing: Beginner Class
Metasploit for Penetration Testing: Beginner Class
Georgia Weidman
 
Return oriented programming (ROP)
Return oriented programming (ROP)
Pipat Methavanitpong
 
Ricardo J. Rodríguez & Daniel Uroz - When ROP meets Turing: Automatic Generat...
Ricardo J. Rodríguez & Daniel Uroz - When ROP meets Turing: Automatic Generat...
RootedCON
 
Dynamic Binary Instrumentation
Dynamic Binary Instrumentation
Cysinfo Cyber Security Community
 
Exploiting stack overflow 101
Exploiting stack overflow 101
n|u - The Open Security Community
 
Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow Attack
Rob Gillen
 
2.Format Strings
2.Format Strings
phanleson
 
Buffer overflow attacks
Buffer overflow attacks
Joe McCarthy
 
Buffer overflow attacks
Buffer overflow attacks
Japneet Singh
 
How to find_vulnerability_in_software
How to find_vulnerability_in_software
sanghwan ahn
 
Buffer Overflow - Smashing the Stack
Buffer Overflow - Smashing the Stack
ironSource
 
08 - Return Oriented Programming, the chosen one
08 - Return Oriented Programming, the chosen one
Alexandre Moneger
 
Fuzzing: Finding Your Own Bugs and 0days! at Arab Security Conference
Fuzzing: Finding Your Own Bugs and 0days! at Arab Security Conference
Rodolpho Concurde
 
Buffer overflow attack
Buffer overflow attack
Krish
 
C format string vulnerability
C format string vulnerability
sluge
 
Leak kernel pointer by exploiting uninitialized uses in Linux kernel
Leak kernel pointer by exploiting uninitialized uses in Linux kernel
JinbumPark
 
Format string vunerability
Format string vunerability
nuc13us
 
Fuzzing: Finding Your Own Bugs and 0days! 1.0
Fuzzing: Finding Your Own Bugs and 0days! 1.0
Rodolpho Concurde
 
From SEH Overwrite with Egg Hunter to Get a Shell!
From SEH Overwrite with Egg Hunter to Get a Shell!
Rodolpho Concurde
 
Perl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testing
Vlatko Kosturjak
 
Metasploit for Penetration Testing: Beginner Class
Metasploit for Penetration Testing: Beginner Class
Georgia Weidman
 
Ricardo J. Rodríguez & Daniel Uroz - When ROP meets Turing: Automatic Generat...
Ricardo J. Rodríguez & Daniel Uroz - When ROP meets Turing: Automatic Generat...
RootedCON
 

Viewers also liked (9)

3Es of Ransomware
3Es of Ransomware
Sunil Kumar
 
Http2 Security Perspective
Http2 Security Perspective
Sunil Kumar
 
Security certifications
Security certifications
Manas Deep
 
Web Application Firewall
Web Application Firewall
Chandrapal Badshah
 
Secure coding in C#
Secure coding in C#
Siddharth Bezalwar
 
Owasp top 10
Owasp top 10
veerababu penugonda(Mr-IoT)
 
Beginner talk physical security - manasdeep
Beginner talk physical security - manasdeep
Manas Deep
 
Metasploit For Beginners
Metasploit For Beginners
Ramnath Shenoy
 
Network discovery - Inside out by Aakash Goel
Network discovery - Inside out by Aakash Goel
OWASP Delhi
 
3Es of Ransomware
3Es of Ransomware
Sunil Kumar
 
Http2 Security Perspective
Http2 Security Perspective
Sunil Kumar
 
Security certifications
Security certifications
Manas Deep
 
Beginner talk physical security - manasdeep
Beginner talk physical security - manasdeep
Manas Deep
 
Metasploit For Beginners
Metasploit For Beginners
Ramnath Shenoy
 
Network discovery - Inside out by Aakash Goel
Network discovery - Inside out by Aakash Goel
OWASP Delhi
 
Ad

Similar to Buffer overflow null (20)

Ceh v5 module 20 buffer overflow
Ceh v5 module 20 buffer overflow
Vi Tính Hoàng Nam
 
Buffer overflow attacks
Buffer overflow attacks
Sandun Perera
 
IRJET - Buffer Overflows Attacks & Defense
IRJET - Buffer Overflows Attacks & Defense
IRJET Journal
 
Buffer overflow
Buffer overflow
Abu Juha Ahmed Muid
 
Buffer overflow explained
Buffer overflow explained
Teja Babu
 
Stack-Based Buffer Overflows
Stack-Based Buffer Overflows
Daniel Tumser
 
Advanced Arm Exploitation
Advanced Arm Exploitation
Himanshu Khokhar Jaat
 
What
What
anity
 
Exploitation Crash Course
Exploitation Crash Course
UTD Computer Security Group
 
¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...
¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...
Software Guru
 
Buffer overflow tutorial
Buffer overflow tutorial
hughpearse
 
Buffer overflow attacks
Buffer overflow attacks
Sandun Perera
 
Buffer OverFlow
Buffer OverFlow
Rambabu Duddukuri
 
Buffer overflows
Buffer overflows
Sandun Perera
 
StackOverflow
StackOverflow
Susam Pal
 
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
ahmed8790
 
Introduction to Binary Exploitation
Introduction to Binary Exploitation
Cysinfo Cyber Security Community
 
Lecture #15: Buffer Overflow Attack (Non Malicious Attack)
Lecture #15: Buffer Overflow Attack (Non Malicious Attack)
Dr. Ramchandra Mangrulkar
 
AllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW Security
AllBits BVBA (freelancer)
 
BufferOverflow - Offensive point of View
BufferOverflow - Offensive point of View
Toe Khaing
 
Ceh v5 module 20 buffer overflow
Ceh v5 module 20 buffer overflow
Vi Tính Hoàng Nam
 
Buffer overflow attacks
Buffer overflow attacks
Sandun Perera
 
IRJET - Buffer Overflows Attacks & Defense
IRJET - Buffer Overflows Attacks & Defense
IRJET Journal
 
Buffer overflow explained
Buffer overflow explained
Teja Babu
 
Stack-Based Buffer Overflows
Stack-Based Buffer Overflows
Daniel Tumser
 
What
What
anity
 
¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...
¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...
Software Guru
 
Buffer overflow tutorial
Buffer overflow tutorial
hughpearse
 
Buffer overflow attacks
Buffer overflow attacks
Sandun Perera
 
StackOverflow
StackOverflow
Susam Pal
 
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
ahmed8790
 
Lecture #15: Buffer Overflow Attack (Non Malicious Attack)
Lecture #15: Buffer Overflow Attack (Non Malicious Attack)
Dr. Ramchandra Mangrulkar
 
AllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW Security
AllBits BVBA (freelancer)
 
BufferOverflow - Offensive point of View
BufferOverflow - Offensive point of View
Toe Khaing
 
Ad

More from nullowaspmumbai (20)

Xxe
Xxe
nullowaspmumbai
 
ELK in Security Analytics
ELK in Security Analytics
nullowaspmumbai
 
Switch security
Switch security
nullowaspmumbai
 
Radio hacking - Part 1
Radio hacking - Part 1
nullowaspmumbai
 
How I got my First CVE
How I got my First CVE
nullowaspmumbai
 
Power forensics
Power forensics
nullowaspmumbai
 
Infrastructure security & Incident Management
Infrastructure security & Incident Management
nullowaspmumbai
 
Middleware hacking
Middleware hacking
nullowaspmumbai
 
Internet censorship circumvention techniques
Internet censorship circumvention techniques
nullowaspmumbai
 
How i got my first cve
How i got my first cve
nullowaspmumbai
 
Adversarial machine learning updated
Adversarial machine learning updated
nullowaspmumbai
 
Commix
Commix
nullowaspmumbai
 
Adversarial machine learning
Adversarial machine learning
nullowaspmumbai
 
Dll Hijacking
Dll Hijacking
nullowaspmumbai
 
Abusing Target
Abusing Target
nullowaspmumbai
 
NTFS Forensics
NTFS Forensics
nullowaspmumbai
 
Drozer - An Android Application Security Tool
Drozer - An Android Application Security Tool
nullowaspmumbai
 
Middleware hacking
Middleware hacking
nullowaspmumbai
 
Ganesh naik linux_kernel_internals
Ganesh naik linux_kernel_internals
nullowaspmumbai
 
Null Mumbai Meet_Android Reverse Engineering by Samrat Das
Null Mumbai Meet_Android Reverse Engineering by Samrat Das
nullowaspmumbai
 
ELK in Security Analytics
ELK in Security Analytics
nullowaspmumbai
 
Infrastructure security & Incident Management
Infrastructure security & Incident Management
nullowaspmumbai
 
Internet censorship circumvention techniques
Internet censorship circumvention techniques
nullowaspmumbai
 
Adversarial machine learning updated
Adversarial machine learning updated
nullowaspmumbai
 
Adversarial machine learning
Adversarial machine learning
nullowaspmumbai
 
Drozer - An Android Application Security Tool
Drozer - An Android Application Security Tool
nullowaspmumbai
 
Ganesh naik linux_kernel_internals
Ganesh naik linux_kernel_internals
nullowaspmumbai
 
Null Mumbai Meet_Android Reverse Engineering by Samrat Das
Null Mumbai Meet_Android Reverse Engineering by Samrat Das
nullowaspmumbai
 

Recently uploaded (20)

How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
certivoai
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
SAP Datasphere Catalog L2 (2024-02-07).pptx
SAP Datasphere Catalog L2 (2024-02-07).pptx
HimanshuSachdeva46
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Philip Schwarz
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
Artificial Intelligence Workloads and Data Center Management
Artificial Intelligence Workloads and Data Center Management
SandeepKS52
 
What is data visualization and how data visualization tool can help.pptx
What is data visualization and how data visualization tool can help.pptx
Varsha Nayak
 
Code and No-Code Journeys: The Coverage Overlook
Code and No-Code Journeys: The Coverage Overlook
Applitools
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
certivoai
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
SAP Datasphere Catalog L2 (2024-02-07).pptx
SAP Datasphere Catalog L2 (2024-02-07).pptx
HimanshuSachdeva46
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Philip Schwarz
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
Artificial Intelligence Workloads and Data Center Management
Artificial Intelligence Workloads and Data Center Management
SandeepKS52
 
What is data visualization and how data visualization tool can help.pptx
What is data visualization and how data visualization tool can help.pptx
Varsha Nayak
 
Code and No-Code Journeys: The Coverage Overlook
Code and No-Code Journeys: The Coverage Overlook
Applitools
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 

Buffer overflow null

  • 1. Anatomy of Stack Overflow attack113 August 2016 Buffer Overflow – a Demo Bhaskar K. Divecha +91 – 98193 36001
  • 2. Anatomy of Stack Overflow attack213 August 2016 Buffer Overflow – a Demo This session : • Explains Buffer overflow in simple manner • Demos Exploitation of vulnerable program – Works on the Vulnerable C Program – Tweaks the stack (by sending data to program) – Modifies the return address in stack – Calls some other instruction
  • 3. Anatomy of Stack Overflow attack313 August 2016 Buffer Overflow – a Demo What is Buffer overflow? Buffer overflow is an anomaly where a program, while writing data to a buffer, overruns the buffer's boundary and overwrites adjacent memory locations.
  • 4. Anatomy of Stack Overflow attack413 August 2016 Buffer Overflow – a Demo What is Buffer overflow? ...contd. A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold. It can corrupt data, crash the program, or cause the execution of malicious code.
  • 5. Anatomy of Stack Overflow attack513 August 2016 Buffer Overflow – a Demo The Exploit Many memory manipulation functions in C and C++ do not perform bounds checking and can easily overwrite the allocated bounds of the buffers they operate upon. We will exploit such a vulnerable C program.
  • 6. Anatomy of Stack Overflow attack613 August 2016 Buffer Overflow – a Demo The Exploit We will exploit such a vulnerable C program by: – Tweaking the stack (by sending data to program) – Modifying the return address in stack – Calling some other instruction
  • 7. Anatomy of Stack Overflow attack713 August 2016 Buffer Overflow – a Demo The Vulnerable Program void bbFunction1(); main(int bbArgc,char *bbArgv[]) { int bbVbl = 12; printf("nValue of bbENV variable before calling bbFunction1 is : %dn",bbVbl); bbFunction1(); bbVbl = 100; printf("nValue of bbENV variable after calling bbFunction1 is : %dn",bbVbl); } void bbFunction1() { char *bbENV, bbBuff[3]="BB"; bbENV=getenv("bbENV"); strcpy(bbBuff,bbENV); printf("nThe value of Env Vbl "bbENV" is -%s-n",bbBuff); __asm { int 3 } } This programs looks quite safe for the usual programmer. .
  • 8. Anatomy of Stack Overflow attack813 August 2016 Buffer Overflow – a Demo The Result of Normal run of the program D:>set bbENV=ABC D:>bbEnvVariable.exe Value of bbENV variable before calling bbFunction1 is : 12 The value of Env Vbl "bbENV" is -ABC- Value of bbENV variable after calling bbFunction1 is : 100 D:>
  • 9. Anatomy of Stack Overflow attack913 August 2016 Buffer Overflow – a Demo The Vulnerable Program void bbFunction1(); main(int bbArgc,char *bbArgv[]) { int bbVbl = 12; printf("nValue of bbENV variable before calling bbFunction1 is : %dn",bbVbl); bbFunction1(); 00401021 bbVbl = 100; ▬► This instruction is bypassed 0040102C printf("nValue of bbENV variable after calling bbFunction1 is : %dn",bbVbl); } void bbFunction1() { char *bbENV, bbBuff[3]="BB"; bbENV=getenv("bbENV"); strcpy(bbBuff,bbENV); printf("nThe value of Env Vbl "bbENV" is -%s-n",bbBuff); __asm { int 3 } } This programs looks quite safe for the usual programmer. But in fact we can bypass certain instructions and call altogether the different instruction by crafting the Environment Variable.
  • 10. Anatomy of Stack Overflow attack1013 August 2016 Buffer Overflow – a Demo The Result of the program after the Exploit D:>set bbENV=ABCD1234, D:>bbEnvVariable Value of bbENV variable before calling bbFunction1 is : 12 The value of Env Vbl "bbENV" is -ABCD1234,- Value of bbENV variable after calling bbFunction1 is : 12 D:>
  • 11. Anatomy of Stack Overflow attack1113 August 2016 Buffer Overflow – a Demo Know the Concepts to Exploit this Program 1. Stack, it’s contents and it’s working during function calls and returns. Stack - a LIFO memory structure where all the function parameters (incl. Commandline arguments), return addresses and the local variables of the function are stored. It grows downward in memory (from higher address space to lower address space).
  • 12. Anatomy of Stack Overflow attack1213 August 2016 Buffer Overflow – a Demo Know the Concepts to Exploit this Program ... contd. 2. Registers Registers are 4 bytes or 32 bits as the binary is compiled for a 32 bit system.
  • 13. Anatomy of Stack Overflow attack1313 August 2016 Buffer Overflow – a Demo Know the Concepts to Exploit this Program ... contd. 2. Registers %eip: The Instruction pointer register stores the address of the next instruction to be executed. After every instruction execution it’s value is incremented depending upon the size of an instrution.
  • 14. Anatomy of Stack Overflow attack1413 August 2016 Buffer Overflow – a Demo Know the Concepts to Exploit this Program ... contd. 2. Registers %esp: The Stack pointer register stores the address of the top of the stack. This is the address of the last element on the stack. It points to the value in stack at the lowest memory address.
  • 15. Anatomy of Stack Overflow attack1513 August 2016 Buffer Overflow – a Demo Know the Concepts to Exploit this Program ... contd. 2. Registers %ebp: The Base pointer register usually set to %esp at the start of the function. This is done to keep tab of function parameters & local variables. Local variables are accessed by subtracting offsets from %ebp & function parameters are accessed by adding offsets to it.
  • 16. Anatomy of Stack Overflow attack1613 August 2016 Buffer Overflow – a Demo Disassembly of a Vulnerable Program ... int bbVbl = 12; printf("nValue of bbENV variable before calling bbFunction1 is : %dn",bbVbl); bbFunction1(); 00401021 bbVbl = 100; ▬► This instruction is bypassed by crafting Environment Variable 0040102C printf("nValue of bbENV variable after calling bbFunction1 is : %dn",bbVbl); } 00401004 C7 45 FC 0C 00 00 00 mov dword ptr [ebp-4],0Ch ▬► int bbVbl = 12; 0040100B 8B 45 FC mov eax,dword ptr [ebp-4] 0040100E 50 push eax 0040100F 68 00 D0 40 00 push 40D000h 00401014 E8 76 00 00 00 call 0040108F ▬► printf “BEFORE” calling bbFunction1() 00401019 83 C4 08 add esp,8 0040101C E8 1F 00 00 00 call 00401040 00401021 C7 45 FC 64 00 00 00 mov dword ptr [ebp-4],64h ▬► bbVal = 100; (BYPASSED) 00401028 8B 4D FC mov ecx,dword ptr [ebp-4] 0040102B 51 push ecx 0040102C 68 3C D0 40 00 push 40D03Ch 00401031 E8 59 00 00 00 call 0040108F ▬► printf “AFTER” calling bbFunction1()
  • 17. Anatomy of Stack Overflow attack1713 August 2016 Buffer Overflow – a Demo
  • 18. Anatomy of Stack Overflow attack1813 August 2016 Buffer Overflow – a Demo
  • 19. Anatomy of Stack Overflow attack1913 August 2016 Buffer Overflow – a Demo References While there are tons of information available on Internet, I glanced through following 2 sites: https://dhavalkapil.com/blogs/Buffer-Overflow-Exploit/ https://www.owasp.org/index.php/Buffer_Overflow
  • 20. Anatomy of Stack Overflow attack2013 August 2016 Thank You Bhaskar K. Divecha +91 – 98193 36001 Buffer Overflow – a Demo