SlideShare ist ein Scribd-Unternehmen logo
1 von 15
 Pushing data more than the capacity of a
buffer
 buffer overflow, or buffer overrun, is an
anomaly where a program, while writing data
to a buffer, overruns the buffer's boundary
and overwrites adjacent memory.
 For example:
- strcpy(target_buffer, large_string)
- printf(str_ptr)
 Stack overflow
 Heap overflow
 Of By One overflow
 Function pointers
 Integer overflow
 Format string overflow
 Unicode overflow
 WebApplications written in PHP, C#,VB,
VB.NET,ASP.NET, Ruby-on-rails, server-side
javascript and JSP are managed applications,
and are not succeptable to memory corruption
vulnerabilities such as stack buffer overflows or
heap buffer overflows caused by bad web-
application code
 Buffer overflows tend to be the preserve of
C/C++ applications, although other less common
native languages such as Dephi and Fortran are
also susceptible(unmanaged code)
 For example, the following program declares a
buffer that is 256 bytes long. However, the
program attempts to fill it with 512 bytes of the
letter “A” (0x41).
int i;
void function(void)
{
char buffer[256]; // create a buffer
for(i=0;i<512;i++) // iterate 512 times
buffer[i]=‘A’; // copy the letterA
}
 Here is a sample program with a heap overflow.The program
dynamically allocates memory for two buffers. One buffer is filled with
“A”s.The other one is taken in from the command line. If one types too
many characters on the command line, an overflow will occur.
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(int argc, char **argv)
{
char *buffer = (char *) malloc(16);
char *input = (char *) malloc(16);
strcpy(buffer,"AAAAAAAAAAAAAAA");
// Use a non-bounds checked function
strcpy(input,argv[1]);
printf(“%s”,buffer);
}
 The C language starts array indices at zero, which is not always intuitive
for beginning programmers
 This often leads to off-by-one errors in code that fills a buffer
#include <stdio.h>
int i;
void vuln(char *foobar)
{
char buffer [512];
for (i=0;i<=512;i++)
buffer[i]=foobar[i];
}
void main(int argc, char *argv[])
{
if (argc==2)
vuln(argv[1]);
}
How much damage could a one-byte exploit cause?
Another second generation overflow involves function pointers.A function pointer
occurs mainly when callbacks occur. If, in memory, a function pointer follows a buffer,
there is the possibility to overwrite the function pointer if the buffer is unchecked.
Here is a simple example of such code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int CallBack(const char *szTemp)
{
printf(“CallBack(%s)n”, szTemp);
Return 0;
}
void main(int argc, char **argv)
{
static char buffer[16];
static int (*funcptr)(const char *szTemp);
funcptr = (int (*)(const char *szTemp))CallBack;
strcpy(buffer, argv[1]); // unchecked buffer
(int)(*funcptr)(argv[2]);
}
 Format string vulnerabilities occur due to sloppy coding by
software engineers. A variety of C language functions allow
printing the characters to files, buffers, and the screen.These
functions not only place values on the screen, but can format them
as well.
 Many C library functions produce formatted output using format
strings (e.g. printf, fprintf, wprintf, sprintf, etc.)
 These functions permit strings that have no format control to be
printed (unfortunately):
char buffer[13] = “Hello, world!”;
printf(buffer); /* Bad programmer! */
printf(“%s”, buffer); /* Correct coding style */
 The non-standard approach creates the possibility that an attacker
will pass a format string rather than a string to print, which can be
used to write to memory
void vuln(char buffer[256]) {
printf(buffer); /* Bad; good:
printf(“%s”,buffer) */
}
int main(int argc, char *argv[]) {
char buffer[256] = “”; /* allocate buffer */
if (2 == argc)
strncpy(buffer, argv[1], 255);
/* copy command line */
vuln(buffer);
return 0;
}
 If the user passes %X on the command line, then printf() will receive a
pointer to a string with “%X” in it on the stack
 Printf() will see the %X and assume there is another parameter above it
on the stack
 Whatever is above it on the stack will be printed in hexadecimal
 Use only the good form of printf(); never use
printf(buffer) for any function in the printf family
 Review loop bounds for off-by-one errors
 Avoid unsafe C functions (e.g. strcpy(), strcat(),
sprintf(), gets(), scanf()) and learn how to use
alternatives (e.g. strncpy(), strncat(), snprintf())
 Insert bounds checking code
 Avoid unsafe programming languages (C, C++)
and use more modern, safe languages wherever
possible (Java, Ada, C# in managed mode)
Canaries or canary words are known values that are placed between a
buffer and control data on the stack to monitor buffer overflows.
When the buffer overflows, the first data to be corrupted will be the
canary, and a failed verification of the canary data is therefore an alert
of an overflow, which can then be handled, for example, by
invalidating the corrupted data
 Terminator canaries-Terminator Canaries use the observation that
most buffer overflow attacks are based on certain string
operations which end at terminators.The reaction to this
observation is that the canaries are built of NULL terminators, CR,
LF, and -1.The undesirable result is that the canary is known. Even
with the protection, an attacker could potentially overwrite the
canary with its known value, and control information with
mismatched values, thus passing the canary check code, this latter
being executed soon before the specific processor return-from-call
instruction.
 Random canaries are randomly generated, usually from an entropy-gathering daemon, in order to
prevent an attacker from knowing their value. Usually, it is not logically possible or plausible to read the
canary for exploiting; the canary is a secure value known only by those who need to know it—the buffer
overflow protection code in this case. Normally, a random canary is generated at program initialization,
and stored in a global variable.This variable is usually padded by unmapped pages, so that attempting to
read it using any kinds of tricks that exploit bugs to read off RAM cause a segmentation fault,
terminating the program. It may still be possible to read the canary, if the attacker knows where it is, or
can get the program to read from the stack.
 RandomXOR canaries-Random XOR Canaries are Random Canaries that are XOR scrambled using all or
part of the control data. In this way, once the canary or the control data is clobbered, the canary value is
wrong. Random XOR Canaries have the same vulnerabilities as Random Canaries, except that the 'read
from stack' method of getting the canary is a bit more complicated.The attacker must get the canary,
the algorithm, and the control data to generate the original canary for re-encoding into the canary he
needs to use to spoof the protection. In addition, Random XOR Canaries can protect against a certain
type of attack involving overflowing a buffer in a structure into a pointer to change the pointer to point
at a piece of control data. Because of the XOR encoding, the canary will be wrong if the control data or
return value is changed. Because of the pointer, the control data or return value can be changed without
overflowing over the canary.
1. The Ping of death(изпращане на прекалено голям ping пакет, който
довеждаше до buffer overflow). Позволява да се сринат различни
операционни системи, чрез изпращане на деформиран „пинг“ пакет от
всяко място в интернет.
2. The Morris (Internet worm of November 2, 1988) worm spread in part by
exploiting a stack buffer overflow in the Unix finger server. [6]
3. TheWitty worm (2004) spread by exploiting a stack buffer overflow in the
Internet Security Systems BlackICE Desktop Agent.The Witty worm is a
computer worm that attacks the firewall and other computer security products
written by a particular company, Internet Security Systems (ISS) now IBM
Internet Security Systems.[7]
4. The Slammer worm (January 25, 2003) spread by exploiting a stack buffer
overflow in Microsoft's SQL server. [8]
5. The Blaster worm spread by exploiting a stack buffer overflow in Microsoft
DCOM service.The BlasterWorm (also known as Lovsan, Lovesan or MSBlast)
was a computer worm that spread on computers running the Microsoft
operating systemsWindows XP and Windows 2000, duringAugust 2003. [9]
6. TheTwilight hack was made for theWii by giving a lengthy character name for
the horse ('Epona') inThe Legend of Zelda:Twilight Princess.This caused a stack
buffer overflow, allowing arbitrary code to be run on an unmodified system.[10]
1. http://en.wikipedia.org/wiki/Buffer_overflow
2. http://en.wikipedia.org/wiki/Stack_buffer_overflow
3. http://en.wikipedia.org/wiki/Heap_overflow
4. http://en.wikipedia.org/wiki/Buffer_overflow_protect
ion
5. Blended Attacks Exploits,Vulnerabilities and
Buffer-OverflowTechniques in ComputerViruses-
By Eric Chien and Péter Ször
6. http://en.wikipedia.org/wiki/Morris_worm
7. http://en.wikipedia.org/wiki/Witty_worm
8. http://en.wikipedia.org/wiki/SQL_Slammer
9. http://en.wikipedia.org/wiki/Blaster_worm
10. http://en.wikipedia.org/wiki/Twilight_hack

Weitere ähnliche Inhalte

Was ist angesagt?

The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016Frans Rosén
 
Application Security - Your Success Depends on it
Application Security - Your Success Depends on itApplication Security - Your Success Depends on it
Application Security - Your Success Depends on itWSO2
 
6 buffer overflows
6   buffer overflows6   buffer overflows
6 buffer overflowsdrewz lin
 
Got Your PW - 一場入門資安的微旅行
Got Your PW - 一場入門資安的微旅行Got Your PW - 一場入門資安的微旅行
Got Your PW - 一場入門資安的微旅行Allen Chou
 
Computer & internet Security
Computer & internet SecurityComputer & internet Security
Computer & internet SecurityGerard Lamusse
 
Web Application Penetration Testing
Web Application Penetration Testing Web Application Penetration Testing
Web Application Penetration Testing Priyanka Aash
 
Web application attacks
Web application attacksWeb application attacks
Web application attackshruth
 
OWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesOWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesSoftware Guru
 
Malware Classification and Analysis
Malware Classification and AnalysisMalware Classification and Analysis
Malware Classification and AnalysisPrashant Chopra
 
Social engineering
Social engineeringSocial engineering
Social engineeringRobert Hood
 
Format String Attack
Format String AttackFormat String Attack
Format String AttackMayur Mallya
 
Password Cracking
Password CrackingPassword Cracking
Password CrackingSagar Verma
 
OWASP API Security Top 10 - API World
OWASP API Security Top 10 - API WorldOWASP API Security Top 10 - API World
OWASP API Security Top 10 - API World42Crunch
 

Was ist angesagt? (20)

The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
 
Web security
Web securityWeb security
Web security
 
Ethical hacking
Ethical hacking Ethical hacking
Ethical hacking
 
Application Security - Your Success Depends on it
Application Security - Your Success Depends on itApplication Security - Your Success Depends on it
Application Security - Your Success Depends on it
 
6 buffer overflows
6   buffer overflows6   buffer overflows
6 buffer overflows
 
Got Your PW - 一場入門資安的微旅行
Got Your PW - 一場入門資安的微旅行Got Your PW - 一場入門資安的微旅行
Got Your PW - 一場入門資安的微旅行
 
hacking
hackinghacking
hacking
 
Computer & internet Security
Computer & internet SecurityComputer & internet Security
Computer & internet Security
 
Web Application Penetration Testing
Web Application Penetration Testing Web Application Penetration Testing
Web Application Penetration Testing
 
Web application attacks
Web application attacksWeb application attacks
Web application attacks
 
OWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesOWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application Vulnerabilities
 
Malware Classification and Analysis
Malware Classification and AnalysisMalware Classification and Analysis
Malware Classification and Analysis
 
Secure Coding for Java
Secure Coding for JavaSecure Coding for Java
Secure Coding for Java
 
Social engineering
Social engineeringSocial engineering
Social engineering
 
Format String Attack
Format String AttackFormat String Attack
Format String Attack
 
Types of cyber attacks
Types of cyber attacksTypes of cyber attacks
Types of cyber attacks
 
DDOS Attack
DDOS Attack DDOS Attack
DDOS Attack
 
Password Cracking
Password CrackingPassword Cracking
Password Cracking
 
Password craking techniques
Password craking techniques Password craking techniques
Password craking techniques
 
OWASP API Security Top 10 - API World
OWASP API Security Top 10 - API WorldOWASP API Security Top 10 - API World
OWASP API Security Top 10 - API World
 

Andere mochten auch

Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacksSandun Perera
 
Buffer Overflow exploitation
Buffer Overflow exploitationBuffer Overflow exploitation
Buffer Overflow exploitationZakaria SMAHI
 
An Introduction of SQL Injection, Buffer Overflow & Wireless Attack
An Introduction of SQL Injection, Buffer Overflow & Wireless AttackAn Introduction of SQL Injection, Buffer Overflow & Wireless Attack
An Introduction of SQL Injection, Buffer Overflow & Wireless AttackTechSecIT
 
Buffer Overflow Countermeasures, DEP, Security Assessment
Buffer Overflow Countermeasures, DEP, Security AssessmentBuffer Overflow Countermeasures, DEP, Security Assessment
Buffer Overflow Countermeasures, DEP, Security AssessmentAmar Myana
 
Buffer Overflow by SecArmour
 Buffer Overflow by SecArmour Buffer Overflow by SecArmour
Buffer Overflow by SecArmourSec Armour
 
Buffer Overflows
Buffer OverflowsBuffer Overflows
Buffer OverflowsSumit Kumar
 
Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow AttackAnatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow AttackRob Gillen
 
Presentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasuresPresentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasurestharindunew
 
Virus (Trojan Horse and Salami Attack)
Virus (Trojan Horse and Salami Attack)Virus (Trojan Horse and Salami Attack)
Virus (Trojan Horse and Salami Attack)Abdulkarim Zakaria
 
Presentation Virus (salami attack and trojan horse)
Presentation Virus (salami attack and trojan horse)Presentation Virus (salami attack and trojan horse)
Presentation Virus (salami attack and trojan horse)siti zulaikha
 
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor ExtensionsConnect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensionsstable|kernel
 
How to create a jQuery Modal Window
How to create a jQuery Modal WindowHow to create a jQuery Modal Window
How to create a jQuery Modal WindowLikno Software
 
Purchasing power parity a unit root, cointegration and var analysis in emergi...
Purchasing power parity a unit root, cointegration and var analysis in emergi...Purchasing power parity a unit root, cointegration and var analysis in emergi...
Purchasing power parity a unit root, cointegration and var analysis in emergi...Giwrgos Loukopoulos
 
EQUITY MARKET INTEGRATION IN SELECTED MARKETS: EVIDENCE FROM UNIT ROOT AND CO...
EQUITY MARKET INTEGRATION IN SELECTED MARKETS: EVIDENCE FROM UNIT ROOT AND CO...EQUITY MARKET INTEGRATION IN SELECTED MARKETS: EVIDENCE FROM UNIT ROOT AND CO...
EQUITY MARKET INTEGRATION IN SELECTED MARKETS: EVIDENCE FROM UNIT ROOT AND CO...akjsk10
 

Andere mochten auch (20)

Buffer Overflow
Buffer OverflowBuffer Overflow
Buffer Overflow
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
Buffer Overflow exploitation
Buffer Overflow exploitationBuffer Overflow exploitation
Buffer Overflow exploitation
 
An Introduction of SQL Injection, Buffer Overflow & Wireless Attack
An Introduction of SQL Injection, Buffer Overflow & Wireless AttackAn Introduction of SQL Injection, Buffer Overflow & Wireless Attack
An Introduction of SQL Injection, Buffer Overflow & Wireless Attack
 
Buffer Overflow Countermeasures, DEP, Security Assessment
Buffer Overflow Countermeasures, DEP, Security AssessmentBuffer Overflow Countermeasures, DEP, Security Assessment
Buffer Overflow Countermeasures, DEP, Security Assessment
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
 
Buffer Overflow by SecArmour
 Buffer Overflow by SecArmour Buffer Overflow by SecArmour
Buffer Overflow by SecArmour
 
Buffer Overflows
Buffer OverflowsBuffer Overflows
Buffer Overflows
 
Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow AttackAnatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow Attack
 
How2heap
How2heap How2heap
How2heap
 
Presentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasuresPresentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasures
 
Virus (Trojan Horse and Salami Attack)
Virus (Trojan Horse and Salami Attack)Virus (Trojan Horse and Salami Attack)
Virus (Trojan Horse and Salami Attack)
 
Presentation Virus (salami attack and trojan horse)
Presentation Virus (salami attack and trojan horse)Presentation Virus (salami attack and trojan horse)
Presentation Virus (salami attack and trojan horse)
 
Problem tree analysis
Problem tree analysisProblem tree analysis
Problem tree analysis
 
Lampiran unit root test
Lampiran unit root testLampiran unit root test
Lampiran unit root test
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor ExtensionsConnect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
 
How to create a jQuery Modal Window
How to create a jQuery Modal WindowHow to create a jQuery Modal Window
How to create a jQuery Modal Window
 
Purchasing power parity a unit root, cointegration and var analysis in emergi...
Purchasing power parity a unit root, cointegration and var analysis in emergi...Purchasing power parity a unit root, cointegration and var analysis in emergi...
Purchasing power parity a unit root, cointegration and var analysis in emergi...
 
EQUITY MARKET INTEGRATION IN SELECTED MARKETS: EVIDENCE FROM UNIT ROOT AND CO...
EQUITY MARKET INTEGRATION IN SELECTED MARKETS: EVIDENCE FROM UNIT ROOT AND CO...EQUITY MARKET INTEGRATION IN SELECTED MARKETS: EVIDENCE FROM UNIT ROOT AND CO...
EQUITY MARKET INTEGRATION IN SELECTED MARKETS: EVIDENCE FROM UNIT ROOT AND CO...
 

Ähnlich wie Buffer overflow

2.Format Strings
2.Format Strings2.Format Strings
2.Format Stringsphanleson
 
BufferOverflow - Offensive point of View
BufferOverflow - Offensive point of ViewBufferOverflow - Offensive point of View
BufferOverflow - Offensive point of ViewToe Khaing
 
1Buttercup On Network-based Detection of Polymorphic B.docx
 1Buttercup On Network-based Detection of Polymorphic B.docx 1Buttercup On Network-based Detection of Polymorphic B.docx
1Buttercup On Network-based Detection of Polymorphic B.docxaryan532920
 
What
WhatWhat
Whatanity
 
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...sanghwan ahn
 
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!NETWAYS
 
Fuzzing: Finding Your Own Bugs and 0days! 2.0
Fuzzing: Finding Your Own Bugs and 0days! 2.0Fuzzing: Finding Your Own Bugs and 0days! 2.0
Fuzzing: Finding Your Own Bugs and 0days! 2.0Rodolpho Concurde
 
Control hijacking
Control hijackingControl hijacking
Control hijackingG Prachi
 
Report on hacking blind
Report on hacking blindReport on hacking blind
Report on hacking blindNikitaAndhale
 
Linux binary analysis and exploitation
Linux binary analysis and exploitationLinux binary analysis and exploitation
Linux binary analysis and exploitationDharmalingam Ganesan
 
Secure programming - Computer and Network Security
Secure programming - Computer and Network SecuritySecure programming - Computer and Network Security
Secure programming - Computer and Network Securityssuser30902e
 
Mitigating overflows using defense in-depth. What can your compiler do for you?
Mitigating overflows using defense in-depth. What can your compiler do for you?Mitigating overflows using defense in-depth. What can your compiler do for you?
Mitigating overflows using defense in-depth. What can your compiler do for you?Javier Tallón
 
Valgrind debugger Tutorial
Valgrind debugger TutorialValgrind debugger Tutorial
Valgrind debugger TutorialAnurag Tomar
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Vincenzo Iozzo
 
Common mistakes in C programming
Common mistakes in C programmingCommon mistakes in C programming
Common mistakes in C programmingLarion
 
20101017 program analysis_for_security_livshits_lecture03_security
20101017 program analysis_for_security_livshits_lecture03_security20101017 program analysis_for_security_livshits_lecture03_security
20101017 program analysis_for_security_livshits_lecture03_securityComputer Science Club
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorialhughpearse
 
Golf teamlearnerlecture
Golf teamlearnerlectureGolf teamlearnerlecture
Golf teamlearnerlecturekairistiona
 
C format string vulnerability
C format string vulnerabilityC format string vulnerability
C format string vulnerabilitysluge
 

Ähnlich wie Buffer overflow (20)

2.Format Strings
2.Format Strings2.Format Strings
2.Format Strings
 
BufferOverflow - Offensive point of View
BufferOverflow - Offensive point of ViewBufferOverflow - Offensive point of View
BufferOverflow - Offensive point of View
 
1Buttercup On Network-based Detection of Polymorphic B.docx
 1Buttercup On Network-based Detection of Polymorphic B.docx 1Buttercup On Network-based Detection of Polymorphic B.docx
1Buttercup On Network-based Detection of Polymorphic B.docx
 
Rust Hack
Rust HackRust Hack
Rust Hack
 
What
WhatWhat
What
 
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
 
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
 
Fuzzing: Finding Your Own Bugs and 0days! 2.0
Fuzzing: Finding Your Own Bugs and 0days! 2.0Fuzzing: Finding Your Own Bugs and 0days! 2.0
Fuzzing: Finding Your Own Bugs and 0days! 2.0
 
Control hijacking
Control hijackingControl hijacking
Control hijacking
 
Report on hacking blind
Report on hacking blindReport on hacking blind
Report on hacking blind
 
Linux binary analysis and exploitation
Linux binary analysis and exploitationLinux binary analysis and exploitation
Linux binary analysis and exploitation
 
Secure programming - Computer and Network Security
Secure programming - Computer and Network SecuritySecure programming - Computer and Network Security
Secure programming - Computer and Network Security
 
Mitigating overflows using defense in-depth. What can your compiler do for you?
Mitigating overflows using defense in-depth. What can your compiler do for you?Mitigating overflows using defense in-depth. What can your compiler do for you?
Mitigating overflows using defense in-depth. What can your compiler do for you?
 
Valgrind debugger Tutorial
Valgrind debugger TutorialValgrind debugger Tutorial
Valgrind debugger Tutorial
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
 
Common mistakes in C programming
Common mistakes in C programmingCommon mistakes in C programming
Common mistakes in C programming
 
20101017 program analysis_for_security_livshits_lecture03_security
20101017 program analysis_for_security_livshits_lecture03_security20101017 program analysis_for_security_livshits_lecture03_security
20101017 program analysis_for_security_livshits_lecture03_security
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorial
 
Golf teamlearnerlecture
Golf teamlearnerlectureGolf teamlearnerlecture
Golf teamlearnerlecture
 
C format string vulnerability
C format string vulnerabilityC format string vulnerability
C format string vulnerability
 

Kürzlich hochgeladen

Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 

Kürzlich hochgeladen (20)

Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 

Buffer overflow

  • 1.
  • 2.  Pushing data more than the capacity of a buffer  buffer overflow, or buffer overrun, is an anomaly where a program, while writing data to a buffer, overruns the buffer's boundary and overwrites adjacent memory.  For example: - strcpy(target_buffer, large_string) - printf(str_ptr)
  • 3.  Stack overflow  Heap overflow  Of By One overflow  Function pointers  Integer overflow  Format string overflow  Unicode overflow
  • 4.  WebApplications written in PHP, C#,VB, VB.NET,ASP.NET, Ruby-on-rails, server-side javascript and JSP are managed applications, and are not succeptable to memory corruption vulnerabilities such as stack buffer overflows or heap buffer overflows caused by bad web- application code  Buffer overflows tend to be the preserve of C/C++ applications, although other less common native languages such as Dephi and Fortran are also susceptible(unmanaged code)
  • 5.  For example, the following program declares a buffer that is 256 bytes long. However, the program attempts to fill it with 512 bytes of the letter “A” (0x41). int i; void function(void) { char buffer[256]; // create a buffer for(i=0;i<512;i++) // iterate 512 times buffer[i]=‘A’; // copy the letterA }
  • 6.  Here is a sample program with a heap overflow.The program dynamically allocates memory for two buffers. One buffer is filled with “A”s.The other one is taken in from the command line. If one types too many characters on the command line, an overflow will occur. #include <stdio.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void main(int argc, char **argv) { char *buffer = (char *) malloc(16); char *input = (char *) malloc(16); strcpy(buffer,"AAAAAAAAAAAAAAA"); // Use a non-bounds checked function strcpy(input,argv[1]); printf(“%s”,buffer); }
  • 7.  The C language starts array indices at zero, which is not always intuitive for beginning programmers  This often leads to off-by-one errors in code that fills a buffer #include <stdio.h> int i; void vuln(char *foobar) { char buffer [512]; for (i=0;i<=512;i++) buffer[i]=foobar[i]; } void main(int argc, char *argv[]) { if (argc==2) vuln(argv[1]); } How much damage could a one-byte exploit cause?
  • 8. Another second generation overflow involves function pointers.A function pointer occurs mainly when callbacks occur. If, in memory, a function pointer follows a buffer, there is the possibility to overwrite the function pointer if the buffer is unchecked. Here is a simple example of such code: #include <stdio.h> #include <stdlib.h> #include <string.h> int CallBack(const char *szTemp) { printf(“CallBack(%s)n”, szTemp); Return 0; } void main(int argc, char **argv) { static char buffer[16]; static int (*funcptr)(const char *szTemp); funcptr = (int (*)(const char *szTemp))CallBack; strcpy(buffer, argv[1]); // unchecked buffer (int)(*funcptr)(argv[2]); }
  • 9.  Format string vulnerabilities occur due to sloppy coding by software engineers. A variety of C language functions allow printing the characters to files, buffers, and the screen.These functions not only place values on the screen, but can format them as well.  Many C library functions produce formatted output using format strings (e.g. printf, fprintf, wprintf, sprintf, etc.)  These functions permit strings that have no format control to be printed (unfortunately): char buffer[13] = “Hello, world!”; printf(buffer); /* Bad programmer! */ printf(“%s”, buffer); /* Correct coding style */  The non-standard approach creates the possibility that an attacker will pass a format string rather than a string to print, which can be used to write to memory
  • 10. void vuln(char buffer[256]) { printf(buffer); /* Bad; good: printf(“%s”,buffer) */ } int main(int argc, char *argv[]) { char buffer[256] = “”; /* allocate buffer */ if (2 == argc) strncpy(buffer, argv[1], 255); /* copy command line */ vuln(buffer); return 0; }  If the user passes %X on the command line, then printf() will receive a pointer to a string with “%X” in it on the stack  Printf() will see the %X and assume there is another parameter above it on the stack  Whatever is above it on the stack will be printed in hexadecimal
  • 11.  Use only the good form of printf(); never use printf(buffer) for any function in the printf family  Review loop bounds for off-by-one errors  Avoid unsafe C functions (e.g. strcpy(), strcat(), sprintf(), gets(), scanf()) and learn how to use alternatives (e.g. strncpy(), strncat(), snprintf())  Insert bounds checking code  Avoid unsafe programming languages (C, C++) and use more modern, safe languages wherever possible (Java, Ada, C# in managed mode)
  • 12. Canaries or canary words are known values that are placed between a buffer and control data on the stack to monitor buffer overflows. When the buffer overflows, the first data to be corrupted will be the canary, and a failed verification of the canary data is therefore an alert of an overflow, which can then be handled, for example, by invalidating the corrupted data  Terminator canaries-Terminator Canaries use the observation that most buffer overflow attacks are based on certain string operations which end at terminators.The reaction to this observation is that the canaries are built of NULL terminators, CR, LF, and -1.The undesirable result is that the canary is known. Even with the protection, an attacker could potentially overwrite the canary with its known value, and control information with mismatched values, thus passing the canary check code, this latter being executed soon before the specific processor return-from-call instruction.
  • 13.  Random canaries are randomly generated, usually from an entropy-gathering daemon, in order to prevent an attacker from knowing their value. Usually, it is not logically possible or plausible to read the canary for exploiting; the canary is a secure value known only by those who need to know it—the buffer overflow protection code in this case. Normally, a random canary is generated at program initialization, and stored in a global variable.This variable is usually padded by unmapped pages, so that attempting to read it using any kinds of tricks that exploit bugs to read off RAM cause a segmentation fault, terminating the program. It may still be possible to read the canary, if the attacker knows where it is, or can get the program to read from the stack.  RandomXOR canaries-Random XOR Canaries are Random Canaries that are XOR scrambled using all or part of the control data. In this way, once the canary or the control data is clobbered, the canary value is wrong. Random XOR Canaries have the same vulnerabilities as Random Canaries, except that the 'read from stack' method of getting the canary is a bit more complicated.The attacker must get the canary, the algorithm, and the control data to generate the original canary for re-encoding into the canary he needs to use to spoof the protection. In addition, Random XOR Canaries can protect against a certain type of attack involving overflowing a buffer in a structure into a pointer to change the pointer to point at a piece of control data. Because of the XOR encoding, the canary will be wrong if the control data or return value is changed. Because of the pointer, the control data or return value can be changed without overflowing over the canary.
  • 14. 1. The Ping of death(изпращане на прекалено голям ping пакет, който довеждаше до buffer overflow). Позволява да се сринат различни операционни системи, чрез изпращане на деформиран „пинг“ пакет от всяко място в интернет. 2. The Morris (Internet worm of November 2, 1988) worm spread in part by exploiting a stack buffer overflow in the Unix finger server. [6] 3. TheWitty worm (2004) spread by exploiting a stack buffer overflow in the Internet Security Systems BlackICE Desktop Agent.The Witty worm is a computer worm that attacks the firewall and other computer security products written by a particular company, Internet Security Systems (ISS) now IBM Internet Security Systems.[7] 4. The Slammer worm (January 25, 2003) spread by exploiting a stack buffer overflow in Microsoft's SQL server. [8] 5. The Blaster worm spread by exploiting a stack buffer overflow in Microsoft DCOM service.The BlasterWorm (also known as Lovsan, Lovesan or MSBlast) was a computer worm that spread on computers running the Microsoft operating systemsWindows XP and Windows 2000, duringAugust 2003. [9] 6. TheTwilight hack was made for theWii by giving a lengthy character name for the horse ('Epona') inThe Legend of Zelda:Twilight Princess.This caused a stack buffer overflow, allowing arbitrary code to be run on an unmodified system.[10]
  • 15. 1. http://en.wikipedia.org/wiki/Buffer_overflow 2. http://en.wikipedia.org/wiki/Stack_buffer_overflow 3. http://en.wikipedia.org/wiki/Heap_overflow 4. http://en.wikipedia.org/wiki/Buffer_overflow_protect ion 5. Blended Attacks Exploits,Vulnerabilities and Buffer-OverflowTechniques in ComputerViruses- By Eric Chien and Péter Ször 6. http://en.wikipedia.org/wiki/Morris_worm 7. http://en.wikipedia.org/wiki/Witty_worm 8. http://en.wikipedia.org/wiki/SQL_Slammer 9. http://en.wikipedia.org/wiki/Blaster_worm 10. http://en.wikipedia.org/wiki/Twilight_hack