Immunity Debugger & Python(office97~2003)

49
Beistlab 장장장 ([email protected])

Transcript of Immunity Debugger & Python(office97~2003)

Page 1: Immunity Debugger & Python(office97~2003)

Beistlab장민창 ([email protected])

Page 2: Immunity Debugger & Python(office97~2003)

Immunity Debugger’s summary & feature

Structure & Instruction of Immunity Debugger’s Python Script

How to use Python Script

Practice & Etc

Page 3: Immunity Debugger & Python(office97~2003)
Page 4: Immunity Debugger & Python(office97~2003)

Simple, understandable interface

Robust and powerful scripting language for automating intelligent debugging

Lightweight and fast debugging to prevent corruption during complex analysis

Connectivity to fuzzers and exploit development tools

Page 5: Immunity Debugger & Python(office97~2003)
Page 6: Immunity Debugger & Python(office97~2003)

Easy visualization of debugee context, which reminds of Olly Debugger

The capability of creating function graphs

Easier to learn complex commands

Page 7: Immunity Debugger & Python(office97~2003)
Page 8: Immunity Debugger & Python(office97~2003)
Page 9: Immunity Debugger & Python(office97~2003)

Immunity Debugger’s Command line plug-in has a simple interface

We can debug remotely from another computer using remote Command line server

Examples - A 401000, XOR EAX, EAX - Assemble at address

Page 10: Immunity Debugger & Python(office97~2003)

Immunity Debugger’s Python API includes many useful utilities and function

We can do the most of things that we can think of with Python Script

Familiar and easy to learn

Open source

Page 11: Immunity Debugger & Python(office97~2003)
Page 12: Immunity Debugger & Python(office97~2003)

Basic Frame

Page 13: Immunity Debugger & Python(office97~2003)
Page 14: Immunity Debugger & Python(office97~2003)

PyCommands -Immunity Debugger\PyCommands

PyHooks -Immunity Debugger\PyHooks

PyScripts -Immunity Debugger\PyScripts

Page 15: Immunity Debugger & Python(office97~2003)

PyCommands - Can be executed from the command bar and main toolbar - If the PyCommand needs extra argument

Example - !scanpe - Detect a Packer/Cryptor of Main module,

also scan just EntryPoint

Page 16: Immunity Debugger & Python(office97~2003)
Page 17: Immunity Debugger & Python(office97~2003)

PyHooks - Python Hooks that are loaded at startup, they look exactly as a python plug-in,

only that they are placed inside PyHooks- directory

Example - myhook = imm.AccessViolationHook() - myhook.disable() << - myhook.add()

Page 18: Immunity Debugger & Python(office97~2003)

PyScripts - PyScripts are called when ALT+F3 or the PyScript icon located at main toolbar are pressed

Page 19: Immunity Debugger & Python(office97~2003)
Page 20: Immunity Debugger & Python(office97~2003)

We need knowledges about Immunity Debugger’s API and Python

Immunity Debugger API - http://debugger.immunityinc.com/update/ Documentation/ref

Page 21: Immunity Debugger & Python(office97~2003)

Display BreakPoint Assemble/Disasm Memory Flow Fetch Information Search Hook Misc

Page 22: Immunity Debugger & Python(office97~2003)

Display API - Used for making visual effects on

Immunity Debugger

Example - Error(msg) - setStatusBar(msg)

Page 23: Immunity Debugger & Python(office97~2003)

BreakPoint API - Used for setting up BreakPoint

Example - setBreakpoint(address) - disableBreakpoint(address) - setMemBreakpoint(address, type, size)

Page 24: Immunity Debugger & Python(office97~2003)
Page 25: Immunity Debugger & Python(office97~2003)

Memory API - Used for reading and writing values from the Memory address

Example - readMemory(address, size) - writeMemory(address, buffer)

Page 26: Immunity Debugger & Python(office97~2003)
Page 27: Immunity Debugger & Python(office97~2003)

Flow API - Used for executing and stepping (Run/StepOver/StepIn)

Example - Run(address) - StepOver(address) - StepIn(address)

Page 28: Immunity Debugger & Python(office97~2003)

Search API - Used for searching about code

Example - Search(buffer) - searchCommands(cmd) - searchCommandsOnModule(address,

cmd)

Page 29: Immunity Debugger & Python(office97~2003)
Page 30: Immunity Debugger & Python(office97~2003)

PyCommands - Can be executed from the command bar and main toolbar

Example - bpxep - hidedebug - searchcode - packets

Page 31: Immunity Debugger & Python(office97~2003)

bpxep - Sets a breakpoint on EP of main module

Page 32: Immunity Debugger & Python(office97~2003)

hidedebug - Used for patch a lot of anti-debugging

trick (Anti-Debug, Anti-Process-finding, Anti-Window-finding)

Page 33: Immunity Debugger & Python(office97~2003)
Page 34: Immunity Debugger & Python(office97~2003)

Example - IsDebuggerPresent

Page 35: Immunity Debugger & Python(office97~2003)
Page 36: Immunity Debugger & Python(office97~2003)

hidedebug.py Line 225 ~ 237

Page 37: Immunity Debugger & Python(office97~2003)

Original -IsDebuggerPresent

I = 1

I = 2

I = 3

I = 4

Page 38: Immunity Debugger & Python(office97~2003)
Page 39: Immunity Debugger & Python(office97~2003)

patch.py - Used for patch a IsDebuggerPresent

Page 40: Immunity Debugger & Python(office97~2003)

packets - Creates a table that displays packets received on the network.

Page 41: Immunity Debugger & Python(office97~2003)

127.0.0.1:5555

Page 42: Immunity Debugger & Python(office97~2003)
Page 43: Immunity Debugger & Python(office97~2003)

Forking & Finding Mine - Target file : system32\winmine.exe - Using API : readMemory, writeMemory -

Page 44: Immunity Debugger & Python(office97~2003)
Page 45: Immunity Debugger & Python(office97~2003)

0x01005340 ~0x0100548A

Size = 0x14A

0x01005340 ~0x0100556F

Size = 0x22F

0x01005340 ~0x0100557F

Size = 0x23F

0x01005340 ~0x0100567F

Size = 0x33F

Page 46: Immunity Debugger & Python(office97~2003)

mine_finder.py

Page 47: Immunity Debugger & Python(office97~2003)
Page 48: Immunity Debugger & Python(office97~2003)

Thank you - IsDebuggerPresent.exe http://zesrever.xstone.org/9 - Winmine.exe Microsoft Windows

Page 49: Immunity Debugger & Python(office97~2003)

Thank you - IsDebuggerPresent.exe http://zesrever.xstone.org/9 - Winmine.exe Microsoft Windows