smashing the stack for fun and profit

21
SMASHING THE STACK FOR FUN AND PROFIT PRESENTED BY MD. MASUDUR RAHMAN MSSE 0404 IIT, DU

Upload: university-of-dhaka

Post on 13-Apr-2017

132 views

Category:

Education


4 download

TRANSCRIPT

Page 1: Smashing the stack for fun and profit

SMASHING THE STACK FOR FUN AND PROFIT

PRESENTED BYMD. MASUDUR RAHMAN

MSSE 0404IIT, DU

Page 2: Smashing the stack for fun and profit

2Outline

1. Problem specification of stack overflow2. Memory structure3. Stack overflow with examples4. Code Injection5. Discussion

Page 3: Smashing the stack for fun and profit

3Research Problem

How could a stack be smashed? What Buffer Overflows are How Buffer Overflow exploit works

Page 4: Smashing the stack for fun and profit

4Process Memory Organization (1/3)

Page 5: Smashing the stack for fun and profit

5Process Memory Organization (2/3)

Page 6: Smashing the stack for fun and profit

6Process Memory Organization (3/3)

Page 7: Smashing the stack for fun and profit

7Structure of a Stack

Manage Control flow

Page 8: Smashing the stack for fun and profit

8Stack Operation

Push Procedure prolog/enter/link

Pop Procedure epilog/leave/unlink

Page 9: Smashing the stack for fun and profit

9Stack Operation with Example

Page 10: Smashing the stack for fun and profit

10Stack Overflow

Page 11: Smashing the stack for fun and profit

11Stack Overflow Example

Page 12: Smashing the stack for fun and profit

12Injecting Shell Code

Shell Code in C

Page 13: Smashing the stack for fun and profit

13Injecting Shell Code

Page 14: Smashing the stack for fun and profit

14Injecting Shell Code

Page 15: Smashing the stack for fun and profit

15Another Example of Exploit

Page 16: Smashing the stack for fun and profit

16NOP Padding

Page 17: Smashing the stack for fun and profit

17Problem with Small Buffer

Can’t hold Shell Code Return address points to another instead of shell code

Solution Use Environment variable

Page 18: Smashing the stack for fun and profit

18Vulnerable Code

No built-in bound checking Functions: strcat(); strcpy(); gets(); etc

Page 19: Smashing the stack for fun and profit

19Discussion

How to prevent stack overflow attack using bound checking?

Bound Checking when taking input from outside/untrusted source

Avoid vulnerable functions

Page 20: Smashing the stack for fun and profit

20

Page 21: Smashing the stack for fun and profit

21Question Set

1. Explain stack overflow with proper example.2. What is NOP? Why attackers use NOP instruction?3. Explain the problem with small buffer size an attacker

faces to exploit the buffer? Provide a solution for it?