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

Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answersdalebeck957
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 

Recently uploaded (20)

Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 

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...