SlideShare a Scribd company logo
1 of 20
Exploiting
Memory Overflows
Action Plan

System Organization Basics
Memory Organization Basics
Buffer Overflow Basics
Demo
Heap Overflow Basics
Demo
System Organization Basics


   CPU




  System Bus          Memory
    A/D/C




I/O Devices
Numbering Systems

      Binary: 11011
       Octal: 33
    Decimal: 27
 Hexadecimal: 1B
Data Representations
                 Bit: 1 bit (0/1)
             Nibble: 4 bits (0-15)
                Byte: 8 bits (0-255)
                Word: 16 bits (0-65535)
Double Word(DWORD):          32 bits (0-4294967295)
 Quad Word(QWORD):       64 bits
                       (0-18446744073709551615)

     0 10110000 01001011101100 1 0 1 0 0 1 0 1 0
                  33,373               148        10

               16bits WORD         8bits BYTE    4bits
                                                NIBBLE

                       32bits DWORD
                       1,881,526,604
15                Memory Organization
14                       Basics
13
                   0 1 1 0 1 1 0 1    0 0 1 0 0 0 0 0
12

11                      MSB                LSB

10                 Little Endian       Big Endian

 9                     0x46                 0x69

 8                     0x1D                 0xAB

 7                     0xAB                 0x1D

 6   0x461DAB69
     0x461DAB69        0x69                 0x46

 5

 4                     0x6D                 0x20

 3    0x6D20           0x20                 0x6D

 2

 1     0x2A
       0x2A           0x2A                  0x2A
                  Intel x86, x86_64       Motorola
EAX – Accumulator, used for default operands and results
    EBX – Base, used to store pointers to data
C
    ECX – Counter, used to count up or down
P
    EDX – Data, used as an I/O pointer
U
    ESP – Stack Pointer, points to the top of the stack frame
    EBP – Base Pointer, points to the base of the stack frame
R
    ESI – Source Index, points to the source for data
E
    EDI – Destination Index, points to the data destination
G
I   Flag – Provides result for the latest operation
S
    EIP – Instruction Pointer, points to the next instruction
T
E   CS – Code Segment, points to the source of code segment
R   DS – Data Segment, points to the source of data segment
S   SS – Stack Segment, points to the source of stack segment
    CS – Extra Segment, points to the source of extra segment
.
                                              .HIGH
                   Segment Size: 0x100
S
E        0x400   EDX, EBX, ESI, EDI
    ES
G                                     0x400

M
E
                      ESP, EBP
N   SS   0x300
                                      0x300
T
A
T        0x200   EDX, EBX, ESI, EDI
    DS
I                                     0x200

O
N
         0x100          EIP
    CS                                0x100
                                              . LOW
                                              .
56
                                  Buffer Overflow Basics
52

48
                                            Stack Operations
44

40                                       PUSH – Subtract 4 from
36   1A   EBP                     ESP     ESP and put new value
                                             at that address
32   CF

28   09
     AC                                    POP – Add 4 to ESP
24
            direction...
            Stack grows in this
20                                        OPER     EBP     ESP
16                                      PUSH 1A    36          36
12                                      PUSH CF    36          32
 8                                      PUSH 09    36          28
 4                                         POP     36          32
 0                                      PUSH AC    36          28
Function Calls and Stack
HIGH




                                                       direction...
                                                       Stack grows in this
      main()   main()   main()   main()       main()


               fun1()   fun1()   fun1()


                        fun2()




LOW    1        2        3         4            5

  main() -> fun1() -> fun2() > fun1()     > main()
56
                        Stack Organization for
52
                            Function Calls
48   local_var1   EBP
44      arg2
40     arg1             int fun (int arg1, int arg2){
36   RETN ADDR    ESP     int lvar1 = arg1 + arg2;
      OLD EBP           }
32

28     lvar1            int main () {
24                        int local_var1;
20
                          fun (arg1, arg2);
                        }
16

12

 8

 4

 0
56
                        Stack Organization for
52
                            Function Calls
48     x=18       EBP
44      6
40       3
                            int add (int a, int b) {
36     RA=999     ESP         int c = a + b;
32   OLD EBP=48             }
28     c=9
                            int main () {
24                            int x = 18;
20                            add (3, 6);
16
                            }
12

 8

 4

 0
220                       Buffer Overflow Example
216
           x=6
212
        &argv[1]
208                          int vuln (char *argv) {
         RA=999                char buf[80];
204
      OLD EBP=212   EBP        int a = 9;
200
                               strcpy (buf, argv);
                             }

                             int main (int argc,
                                        char **argv) {
                               int x = 6;
       buf[80]                 vuln (argv[1]);
120
         a=9        ESP      }
116
112

108

104
220                       Buffer Overflow Example
216
          x=6                int vuln (char *argv) {
212
       &argv[1]                char buf[80];
208                            int a = 9;
        RA=999                 strcpy (buf, argv);
204
      OLD EBP=212   EBP      }
200
         AAAA
                             int main (int argc,
                                        char **argv) {
         ...                   int x = 6;
                               vuln (argv[1]);
                             }
         AAAA
120
         a=9        ESP
116
112
                          python -c 'print “A”*80'
108

104
220                    Buffer Overflow Example
216
        x=6               int vuln (char *argv) {
212
      &argv[1]              char buf[80];
208                         int a = 9;
       RA=999               strcpy (buf, argv);
204
        AAAA     EBP      }
200
        AAAA
                          int main (int argc,
                                     char **argv) {
        ...                 int x = 6;
                            vuln (argv[1]);
                          }
        AAAA
120
        a=9      ESP
116
112
                       python -c 'print “A”*84'
108

104
220                    Buffer Overflow Example
216
        x=6               int vuln (char *argv) {
212
      &argv[1]              char buf[80];
208                         int a = 9;
        AAAA                strcpy (buf, argv);
204
        AAAA     EBP      }
200
        AAAA
                          int main (int argc,
                                     char **argv) {
        ...                 int x = 6;
                            vuln (argv[1]);
                          }
        AAAA
120
        a=9      ESP
116
112
                       python -c 'print “A”*88'
108

104
So, you can overflow a buffer...
             now what?


      Sky is the limit...!


       Well, not really :)

     Let's just dig deep and
see what exactly the scope of such
        a vulnerability is
220                 EIP                  220

216              41414141                216
        x=6      SIGSEGV         x=6
212                                      212
      &argv[1]                &argv[1]
208                                      208
      41414141   RTN ADDR     00000120
204                                      204
      41414141                90909090
200                 EBP                  200
      41414141                6851C931
                              D0FF77C2
        ...                   93C7B854
                              90909090
      41414141                90909090
120                 ESP                  120
        a=9                      a=9
116                                      116
112                  EIP                 112

108               00000120               108

104
                 GAME OVER!              104
Finally, its time to witness
    some live action...!
That’s all folks!!!

Ready with your questions?
 Start firing them, now...

More Related Content

What's hot

Class 17: Golden Sneezewort
Class 17: Golden SneezewortClass 17: Golden Sneezewort
Class 17: Golden SneezewortDavid Evans
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimizationg3_nittala
 
Beyond tf idf why, what & how
Beyond tf idf why, what & howBeyond tf idf why, what & how
Beyond tf idf why, what & howlucenerevolution
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorerithion
 
June 2011 solution
June 2011 solutionJune 2011 solution
June 2011 solutionleroy walker
 
C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)Yuki Tamura
 
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...aferrandini
 
New SPL Features in PHP 5.3 (TEK-X)
New SPL Features in PHP 5.3 (TEK-X)New SPL Features in PHP 5.3 (TEK-X)
New SPL Features in PHP 5.3 (TEK-X)Matthew Turland
 
«Отладка в Python 3.6: Быстрее, Выше, Сильнее» Елизавета Шашкова, JetBrains
«Отладка в Python 3.6: Быстрее, Выше, Сильнее» Елизавета Шашкова, JetBrains«Отладка в Python 3.6: Быстрее, Выше, Сильнее» Елизавета Шашкова, JetBrains
«Отладка в Python 3.6: Быстрее, Выше, Сильнее» Елизавета Шашкова, JetBrainsit-people
 
TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.lnikolaeva
 
エンタープライズ・クラウドと 並列・分散・非同期処理
エンタープライズ・クラウドと 並列・分散・非同期処理エンタープライズ・クラウドと 並列・分散・非同期処理
エンタープライズ・クラウドと 並列・分散・非同期処理maruyama097
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)jeffz
 
The Ring programming language version 1.5.3 book - Part 87 of 184
The Ring programming language version 1.5.3 book - Part 87 of 184The Ring programming language version 1.5.3 book - Part 87 of 184
The Ring programming language version 1.5.3 book - Part 87 of 184Mahmoud Samir Fayed
 
Pwning in c++ (basic)
Pwning in c++ (basic)Pwning in c++ (basic)
Pwning in c++ (basic)Angel Boy
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101Ankur Gupta
 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programmingjeffz
 

What's hot (20)

Class 17: Golden Sneezewort
Class 17: Golden SneezewortClass 17: Golden Sneezewort
Class 17: Golden Sneezewort
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimization
 
Java Beagle
Java BeagleJava Beagle
Java Beagle
 
Beyond tf idf why, what & how
Beyond tf idf why, what & howBeyond tf idf why, what & how
Beyond tf idf why, what & how
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operator
 
Breaking the wall
Breaking the wallBreaking the wall
Breaking the wall
 
Regexp Master
Regexp MasterRegexp Master
Regexp Master
 
June 2011 solution
June 2011 solutionJune 2011 solution
June 2011 solution
 
C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)
 
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...
 
New SPL Features in PHP 5.3 (TEK-X)
New SPL Features in PHP 5.3 (TEK-X)New SPL Features in PHP 5.3 (TEK-X)
New SPL Features in PHP 5.3 (TEK-X)
 
«Отладка в Python 3.6: Быстрее, Выше, Сильнее» Елизавета Шашкова, JetBrains
«Отладка в Python 3.6: Быстрее, Выше, Сильнее» Елизавета Шашкова, JetBrains«Отладка в Python 3.6: Быстрее, Выше, Сильнее» Елизавета Шашкова, JetBrains
«Отладка в Python 3.6: Быстрее, Выше, Сильнее» Елизавета Шашкова, JetBrains
 
TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.
 
エンタープライズ・クラウドと 並列・分散・非同期処理
エンタープライズ・クラウドと 並列・分散・非同期処理エンタープライズ・クラウドと 並列・分散・非同期処理
エンタープライズ・クラウドと 並列・分散・非同期処理
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)
 
Virtual Machine Constructions for Dummies
Virtual Machine Constructions for DummiesVirtual Machine Constructions for Dummies
Virtual Machine Constructions for Dummies
 
The Ring programming language version 1.5.3 book - Part 87 of 184
The Ring programming language version 1.5.3 book - Part 87 of 184The Ring programming language version 1.5.3 book - Part 87 of 184
The Ring programming language version 1.5.3 book - Part 87 of 184
 
Pwning in c++ (basic)
Pwning in c++ (basic)Pwning in c++ (basic)
Pwning in c++ (basic)
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101
 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programming
 

Similar to Emo-Exploitation

Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performanceDuoyi Wu
 
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -Wataru Kani
 
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsReverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsAsuka Nakajima
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engineDuoyi Wu
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADDharmalingam Ganesan
 
Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughterQuinn Wilton
 
Exploit exercises.com stack-overflows
Exploit exercises.com stack-overflowsExploit exercises.com stack-overflows
Exploit exercises.com stack-overflowscommiebstrd
 
How the stack works(1)
How the stack works(1)How the stack works(1)
How the stack works(1)keithrozario
 
Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019
Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019 Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019
Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019 corehard_by
 
プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話tatsunori ishikawa
 
The forgotten art of assembly
The forgotten art of assemblyThe forgotten art of assembly
The forgotten art of assemblyMarian Marinov
 
Kernel Recipes 2014 - x86 instruction encoding and the nasty hacks we do in t...
Kernel Recipes 2014 - x86 instruction encoding and the nasty hacks we do in t...Kernel Recipes 2014 - x86 instruction encoding and the nasty hacks we do in t...
Kernel Recipes 2014 - x86 instruction encoding and the nasty hacks we do in t...Anne Nicolas
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64FFRI, Inc.
 
Devirtualizing FinSpy
Devirtualizing FinSpyDevirtualizing FinSpy
Devirtualizing FinSpyjduart
 

Similar to Emo-Exploitation (20)

Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
 
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
 
The Stack and Buffer Overflows
The Stack and Buffer OverflowsThe Stack and Buffer Overflows
The Stack and Buffer Overflows
 
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsReverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engine
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
 
Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughter
 
Mona cheatsheet
Mona cheatsheetMona cheatsheet
Mona cheatsheet
 
Exploit exercises.com stack-overflows
Exploit exercises.com stack-overflowsExploit exercises.com stack-overflows
Exploit exercises.com stack-overflows
 
How the stack works(1)
How the stack works(1)How the stack works(1)
How the stack works(1)
 
Protecting C++
Protecting C++Protecting C++
Protecting C++
 
Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019
Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019 Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019
Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019
 
Lec06
Lec06Lec06
Lec06
 
Advance ROP Attacks
Advance ROP AttacksAdvance ROP Attacks
Advance ROP Attacks
 
プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話
 
The forgotten art of assembly
The forgotten art of assemblyThe forgotten art of assembly
The forgotten art of assembly
 
Kernel Recipes 2014 - x86 instruction encoding and the nasty hacks we do in t...
Kernel Recipes 2014 - x86 instruction encoding and the nasty hacks we do in t...Kernel Recipes 2014 - x86 instruction encoding and the nasty hacks we do in t...
Kernel Recipes 2014 - x86 instruction encoding and the nasty hacks we do in t...
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64
 
Devirtualizing FinSpy
Devirtualizing FinSpyDevirtualizing FinSpy
Devirtualizing FinSpy
 
The walking 0xDEAD
The walking 0xDEADThe walking 0xDEAD
The walking 0xDEAD
 

Recently uploaded

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 

Recently uploaded (20)

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

Emo-Exploitation

  • 2. Action Plan System Organization Basics Memory Organization Basics Buffer Overflow Basics Demo Heap Overflow Basics Demo
  • 3. System Organization Basics CPU System Bus Memory A/D/C I/O Devices
  • 4. Numbering Systems Binary: 11011 Octal: 33 Decimal: 27 Hexadecimal: 1B
  • 5. Data Representations Bit: 1 bit (0/1) Nibble: 4 bits (0-15) Byte: 8 bits (0-255) Word: 16 bits (0-65535) Double Word(DWORD): 32 bits (0-4294967295) Quad Word(QWORD): 64 bits (0-18446744073709551615) 0 10110000 01001011101100 1 0 1 0 0 1 0 1 0 33,373 148 10 16bits WORD 8bits BYTE 4bits NIBBLE 32bits DWORD 1,881,526,604
  • 6. 15 Memory Organization 14 Basics 13 0 1 1 0 1 1 0 1 0 0 1 0 0 0 0 0 12 11 MSB LSB 10 Little Endian Big Endian 9 0x46 0x69 8 0x1D 0xAB 7 0xAB 0x1D 6 0x461DAB69 0x461DAB69 0x69 0x46 5 4 0x6D 0x20 3 0x6D20 0x20 0x6D 2 1 0x2A 0x2A 0x2A 0x2A Intel x86, x86_64 Motorola
  • 7. EAX – Accumulator, used for default operands and results EBX – Base, used to store pointers to data C ECX – Counter, used to count up or down P EDX – Data, used as an I/O pointer U ESP – Stack Pointer, points to the top of the stack frame EBP – Base Pointer, points to the base of the stack frame R ESI – Source Index, points to the source for data E EDI – Destination Index, points to the data destination G I Flag – Provides result for the latest operation S EIP – Instruction Pointer, points to the next instruction T E CS – Code Segment, points to the source of code segment R DS – Data Segment, points to the source of data segment S SS – Stack Segment, points to the source of stack segment CS – Extra Segment, points to the source of extra segment
  • 8. . .HIGH Segment Size: 0x100 S E 0x400 EDX, EBX, ESI, EDI ES G 0x400 M E ESP, EBP N SS 0x300 0x300 T A T 0x200 EDX, EBX, ESI, EDI DS I 0x200 O N 0x100 EIP CS 0x100 . LOW .
  • 9. 56 Buffer Overflow Basics 52 48 Stack Operations 44 40 PUSH – Subtract 4 from 36 1A EBP ESP ESP and put new value at that address 32 CF 28 09 AC POP – Add 4 to ESP 24 direction... Stack grows in this 20 OPER EBP ESP 16 PUSH 1A 36 36 12 PUSH CF 36 32 8 PUSH 09 36 28 4 POP 36 32 0 PUSH AC 36 28
  • 10. Function Calls and Stack HIGH direction... Stack grows in this main() main() main() main() main() fun1() fun1() fun1() fun2() LOW 1 2 3 4 5 main() -> fun1() -> fun2() > fun1() > main()
  • 11. 56 Stack Organization for 52 Function Calls 48 local_var1 EBP 44 arg2 40 arg1 int fun (int arg1, int arg2){ 36 RETN ADDR ESP int lvar1 = arg1 + arg2; OLD EBP } 32 28 lvar1 int main () { 24 int local_var1; 20 fun (arg1, arg2); } 16 12 8 4 0
  • 12. 56 Stack Organization for 52 Function Calls 48 x=18 EBP 44 6 40 3 int add (int a, int b) { 36 RA=999 ESP int c = a + b; 32 OLD EBP=48 } 28 c=9 int main () { 24 int x = 18; 20 add (3, 6); 16 } 12 8 4 0
  • 13. 220 Buffer Overflow Example 216 x=6 212 &argv[1] 208 int vuln (char *argv) { RA=999 char buf[80]; 204 OLD EBP=212 EBP int a = 9; 200 strcpy (buf, argv); } int main (int argc, char **argv) { int x = 6; buf[80] vuln (argv[1]); 120 a=9 ESP } 116 112 108 104
  • 14. 220 Buffer Overflow Example 216 x=6 int vuln (char *argv) { 212 &argv[1] char buf[80]; 208 int a = 9; RA=999 strcpy (buf, argv); 204 OLD EBP=212 EBP } 200 AAAA int main (int argc, char **argv) { ... int x = 6; vuln (argv[1]); } AAAA 120 a=9 ESP 116 112 python -c 'print “A”*80' 108 104
  • 15. 220 Buffer Overflow Example 216 x=6 int vuln (char *argv) { 212 &argv[1] char buf[80]; 208 int a = 9; RA=999 strcpy (buf, argv); 204 AAAA EBP } 200 AAAA int main (int argc, char **argv) { ... int x = 6; vuln (argv[1]); } AAAA 120 a=9 ESP 116 112 python -c 'print “A”*84' 108 104
  • 16. 220 Buffer Overflow Example 216 x=6 int vuln (char *argv) { 212 &argv[1] char buf[80]; 208 int a = 9; AAAA strcpy (buf, argv); 204 AAAA EBP } 200 AAAA int main (int argc, char **argv) { ... int x = 6; vuln (argv[1]); } AAAA 120 a=9 ESP 116 112 python -c 'print “A”*88' 108 104
  • 17. So, you can overflow a buffer... now what? Sky is the limit...! Well, not really :) Let's just dig deep and see what exactly the scope of such a vulnerability is
  • 18. 220 EIP 220 216 41414141 216 x=6 SIGSEGV x=6 212 212 &argv[1] &argv[1] 208 208 41414141 RTN ADDR 00000120 204 204 41414141 90909090 200 EBP 200 41414141 6851C931 D0FF77C2 ... 93C7B854 90909090 41414141 90909090 120 ESP 120 a=9 a=9 116 116 112 EIP 112 108 00000120 108 104 GAME OVER! 104
  • 19. Finally, its time to witness some live action...!
  • 20. That’s all folks!!! Ready with your questions? Start firing them, now...