SlideShare a Scribd company logo
ART OF EXPLOIT WRITING
                         Ashfaq Ansari
   Security Researcher & Penetration Tester

                 Founder Of: HackSys Team
                    http://hacksys.vfreaks.com/


          null Meet @Bangalore – 19th Jan 2013
Buffer Overflow
• Writing more data into a buffer than the
  allocated size.

• Two types:
   – Stack Overflow
    corrupt the execution stack by writing past the
    end of an array (aka. smashing the stack/
    stack overflow)

  – Heap Overflow
    corrupt the heap
Process Memory Organization
                  • Fixed by the program
  Text            • Read-only
          Text
  Data
                  • Initialized & Uninitialized Data
                  • Static variables are stored here
  Heap    Data

                  • Local variables for functions
                  • Return address and local stack pointer
          Stack
  Stack
The Stack - We Must Know Him
       • Stack is LIFO – Last In First
LIFO     Out
       • PUSH & POP operation
                                         Buffer 2


       • Dynamically allocate local
                                         Buffer 1
Used     variables used in functions
       • Pass parameters to
         functions, etc.                  SFP
                                          RET
       • Stack Pointer (SP) points         a
Info     to the top of the stack
       • Contains return address
         and local stack pointer
                                            b
                                            c
x86 General Purpose Register
Fuzzing
Overview

     • Black Box software testing technique,
       which helps in finding implementation
 1     bugs using malformed /semi-malformed
       data injection in an automated fashion




 2   • Lazy mans tool
The Stack - Overflow

Buffer   • Overwritten by A’s &   AAAA
           B’s                    AAAA
1&2                               AAAA

                                  BBBB
 SFP     • Overwritten by C’s     BBBB
                                  CCCC
                                  DDDD
                                  AAAA
         • Return Overwritten
 RET       by D’s                 AAAA
                                  AAAA
Bad Characters

x00          x0a        x0d
       NULL          n          r
DEMO
Work Hard Toward Mastery

                                                   Achieve
                                                   Mastery
Exploits Worked On




                                        Get
                                     Experienced


                      Get Familiar



                                     Time Spent
Art of Exploit Writing

More Related Content

PDF
Practical Cocoapods
PDF
Combining the strength of erlang and Ruby
ODP
Un tesoro nascosto nella linea di comando
PDF
2 buffer overflows
PDF
ARM procedure calling conventions and recursion
ODP
Emo-Exploitation
PDF
Presentation buffer overflow attacks and theircountermeasures
PDF
Basic buffer overflow part1
Practical Cocoapods
Combining the strength of erlang and Ruby
Un tesoro nascosto nella linea di comando
2 buffer overflows
ARM procedure calling conventions and recursion
Emo-Exploitation
Presentation buffer overflow attacks and theircountermeasures
Basic buffer overflow part1

Similar to Art of Exploit Writing (20)

PPTX
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
PPTX
Stack-Based Buffer Overflows
PDF
StackOverflow
PDF
Writing Efficient Code Feb 08
PPTX
Buffer overflow – Smashing The Stack
PPT
Software Exploitation Techniques by Amit Malik
DOC
C Languagel Classroom Training
ODP
Local Exploits
PPT
C for Microcontrollers
PDF
Writing exploits
PDF
PDF
Smashing The Stack
PDF
Fuzzing - Part 1
ODP
Interview questions slide deck
ODP
Exploiting Memory Overflows
PPTX
Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)
PDF
Buffer Overflow - Smashing the Stack
PPTX
Light And Dark Side Of Code Instrumentation
PPT
PDF
PPU Optimisation Lesson
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
Stack-Based Buffer Overflows
StackOverflow
Writing Efficient Code Feb 08
Buffer overflow – Smashing The Stack
Software Exploitation Techniques by Amit Malik
C Languagel Classroom Training
Local Exploits
C for Microcontrollers
Writing exploits
Smashing The Stack
Fuzzing - Part 1
Interview questions slide deck
Exploiting Memory Overflows
Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)
Buffer Overflow - Smashing the Stack
Light And Dark Side Of Code Instrumentation
PPU Optimisation Lesson
Ad

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
Ad

Art of Exploit Writing

  • 1. ART OF EXPLOIT WRITING Ashfaq Ansari Security Researcher & Penetration Tester Founder Of: HackSys Team http://hacksys.vfreaks.com/ null Meet @Bangalore – 19th Jan 2013
  • 2. Buffer Overflow • Writing more data into a buffer than the allocated size. • Two types: – Stack Overflow corrupt the execution stack by writing past the end of an array (aka. smashing the stack/ stack overflow) – Heap Overflow corrupt the heap
  • 3. Process Memory Organization • Fixed by the program Text • Read-only Text Data • Initialized & Uninitialized Data • Static variables are stored here Heap Data • Local variables for functions • Return address and local stack pointer Stack Stack
  • 4. The Stack - We Must Know Him • Stack is LIFO – Last In First LIFO Out • PUSH & POP operation Buffer 2 • Dynamically allocate local Buffer 1 Used variables used in functions • Pass parameters to functions, etc. SFP RET • Stack Pointer (SP) points a Info to the top of the stack • Contains return address and local stack pointer b c
  • 7. Overview • Black Box software testing technique, which helps in finding implementation 1 bugs using malformed /semi-malformed data injection in an automated fashion 2 • Lazy mans tool
  • 8. The Stack - Overflow Buffer • Overwritten by A’s & AAAA B’s AAAA 1&2 AAAA BBBB SFP • Overwritten by C’s BBBB CCCC DDDD AAAA • Return Overwritten RET by D’s AAAA AAAA
  • 9. Bad Characters x00 x0a x0d NULL n r
  • 10. DEMO
  • 11. Work Hard Toward Mastery Achieve Mastery Exploits Worked On Get Experienced Get Familiar Time Spent