About hooking

26
About Hoooo0oooking pyutic

Transcript of About hooking

Page 1: About hooking

About Hoooo0oooking

pyutic

Page 2: About hooking

What is hooking?

PUSH 1

PUSH 2

PUSH 3

PUSH 4

Page 3: About hooking

What is hooking?

PUSH 1

PUSH 2

PUSH 3

PUSH 4

Log([ESP])

Page 4: About hooking

What we can do

Page 5: About hooking

Assembly Code -Before-

Page 6: About hooking

Assembly Code -After-

Page 7: About hooking

Assembly Code -Solution-

PUSH 1

JMP

PUSH 3

PUSH 4

PUSH 2

LOG([ESP])

JMP

Page 8: About hooking

How to insert code?

Read/WriteProcessMemory

DLL Injection

etc

Page 9: About hooking

Read/WriteProcessMemory

Write *other* process memory

Page 10: About hooking

Read/WriteProcessMemory

But, Where is free space for my codes?

Page 11: About hooking

DLL InjectionInject my DLL

Page 12: About hooking

What is DLL? -Processes-

a.exe b.exe c.exe

Page 13: About hooking

What is DLL? -Processes-

a.exe b.exe c.exe

Page 14: About hooking

What is DLL? -Processes-

a.exe

a.exe

A.dll

B.dll

C.dll

b.exe

b.exe

A.dll

B.dll

C.dll

c.exe

c.exe

A.dll

B.dll

C.dll

Page 15: About hooking

DLL Injection

a.exe

a.exe

A.dll

B.dll

C.dll

Page 16: About hooking

DLL Injection

a.exe

a.exe

A.dll

B.dll

C.dll

MyDll.dll

Page 17: About hooking

DLL Injection -Merit-

Edit memory by using pointer

Doesn’t need to write codes

Code can be developed by using ‘C’

Page 18: About hooking

How to inject DLL?

DLL is generally can be loaded by calling ‘LoadLibrary’

How to?

CreateRemoteThread

Page 19: About hooking

How to inject DLL? -CreateRemoteThread-

Create *other* process’s thread

Thread function is ‘LoadLibrary’

But Where is DLL name?

VirtualAllocEx

Page 20: About hooking

How to inject DLL? -VirtualAllocEx-

Malloc other process's memory

After mallocing, Write DLL name by using WriteProcessMemory

Page 21: About hooking

How to inject DLL?

VirtualAllocEx

CreateRemoteThread

LoadLibrary(in target)

???

PROFIT!

Page 22: About hooking

Code Implementation -DllMain()-

Page 23: About hooking

Code Implementation -penguin()-

Page 24: About hooking

Code Implementation -insertJMP()-

Page 25: About hooking

Code Implementation -hookedFunction()-

Page 26: About hooking

Thanks !