├── IDAPython-7x_cheatsheet_en.svg ├── IDAPython-7x_cheatsheet_web_en.png ├── IDAPython_cheatsheet_en.svg ├── IDAPython_cheatsheet_web_en.png ├── README.md ├── cheatsheet_logo.png ├── debugger_hooks └── breakpoints.py ├── listing ├── disasm_transform.py └── function_arguments.py ├── misc ├── parse_gdt.py └── parse_idt.py ├── types ├── apply_types.py ├── enums.py └── errno.h └── xrefs └── simple_xrefs.py /IDAPython-7x_cheatsheet_web_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inforion/idapython-cheatsheet/355ffd1f6e1045cb1db37ea8f0db795d11a293dd/IDAPython-7x_cheatsheet_web_en.png -------------------------------------------------------------------------------- /IDAPython_cheatsheet_web_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inforion/idapython-cheatsheet/355ffd1f6e1045cb1db37ea8f0db795d11a293dd/IDAPython_cheatsheet_web_en.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # idapython-cheatsheet 2 | ![cheatsheet.png](cheatsheet_logo.png) 3 | 4 | Cheatsheets and example scripts for IDAPython (7.x and 6.x). 5 | 6 | It looks like this: 7 | 8 | ![IDAPython-7.x](IDAPython-7x_cheatsheet_web_en.png) 9 | 10 | ## Printable versions 11 | 12 | ### PDF 13 | - [English (IDA 6.x and 7.x)](https://github.com/inforion/idapython-cheatsheet/releases/download/pdf/IDAPython_cheat_sheet_.6x_7x._ENG.pdf) 14 | - [Russian (IDA 6.x and 7.x)](https://github.com/inforion/idapython-cheatsheet/releases/download/pdf/IDAPython_cheat_sheet_.6x_7x._RUS.pdf) 15 | 16 | 17 | ### IDAPython 7.x (PNG) 18 | 19 | - [IDAPython 7.x cheatsheet (English)](https://github.com/inforion/idapython-cheatsheet/releases/download/7.x/IDAPython-7.x_cheatsheet_print_en.png) 20 | - [IDAPython 7.x cheatsheet (Russian)](https://github.com/inforion/idapython-cheatsheet/releases/download/7.x/IDAPython-7.x_cheatsheet_print_ru.png) 21 | 22 | ### IDAPython 6.x (PNG) 23 | 24 | - [IDAPython 6.x cheatsheet (English)](https://github.com/inforion/idapython-cheatsheet/releases/download/v1.0/IDAPython_cheatsheet_print_en.png) 25 | - [IDAPython 6.x cheatsheet (Russian)](https://github.com/inforion/idapython-cheatsheet/releases/download/v1.0/IDAPython_cheatsheet_print_ru.png) 26 | 27 | ## Tips & triks & examples 28 | 29 | ### Debugger Hooks 30 | - Work with breakpoints [source code](https://github.com/inforion/idapython-cheatsheet/blob/master/debugger_hooks/breakpoints.py) 31 | 32 | ### Listing 33 | - Simple transformations in disassembler view [source code](https://github.com/inforion/idapython-cheatsheet/blob/master/listing/disasm_transform.py) 34 | - Make comment to function, using it's argument [source code](https://github.com/inforion/idapython-cheatsheet/blob/master/listing/function_arguments.py) 35 | 36 | ### Types 37 | - Apply types to functions and data [source code](https://github.com/inforion/idapython-cheatsheet/blob/master/types/apply_types.py) 38 | - Work with enums [source code](https://github.com/inforion/idapython-cheatsheet/blob/master/types/enums.py) 39 | 40 | ### Xrefs 41 | - Add simple code and data cross-references [source code](https://github.com/inforion/idapython-cheatsheet/blob/master/xrefs/simple_xrefs.py) 42 | 43 | ### Miscellaneous 44 | - Parsing Global Descriptor Table (GDT, x86) [source code](https://github.com/inforion/idapython-cheatsheet/blob/master/misc/parse_gdt.py) 45 | - Parsing Interrupt Descriptor Table (IDT, x86) [source code](https://github.com/inforion/idapython-cheatsheet/blob/master/misc/parse_idt.py) 46 | 47 | ## Links 48 | 49 | - ["The Beginner's Guide to IDAPython" by Alexander Hanel](https://leanpub.com/IDAPython-Book) 50 | - ["Introduction to IDAPython" by Ero Carrera](https://github.com/cyphunk/sectk/blob/master/docs/Software_RE/Ero-Introduction%20to%20IDAPython.pdf) 51 | - [IDAPyHelper - script that helps writing IDAPython scripts and plugins](https://github.com/patois/IDAPyHelper) 52 | -------------------------------------------------------------------------------- /cheatsheet_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inforion/idapython-cheatsheet/355ffd1f6e1045cb1db37ea8f0db795d11a293dd/cheatsheet_logo.png -------------------------------------------------------------------------------- /debugger_hooks/breakpoints.py: -------------------------------------------------------------------------------- 1 | ''' Short IDAPython functions to work with breakpoints 2 | ''' 3 | 4 | def set_python_bpt(ea, cond): 5 | ''' Set conditional breakpoint with Python function 6 | 7 | Usage: 8 | set_python_bpt(0x08000688, 'view_regs()') 9 | ''' 10 | idaapi.add_bpt(ea, 4, BPT_DEFAULT) 11 | bpt = idaapi.bpt_t() 12 | idaapi.get_bpt(ea, bpt) 13 | bpt.elang = 'Python' 14 | bpt.condition = cond 15 | idaapi.update_bpt(bpt) 16 | 17 | -------------------------------------------------------------------------------- /listing/disasm_transform.py: -------------------------------------------------------------------------------- 1 | ''' Short and simple transformations in disassembler view 2 | ''' 3 | 4 | def make_offsets32(start_ea, end_ea): 5 | ''' Transform data to offsets (using 32-bit length) ''' 6 | for addr in range(start_ea, end_ea, 4): 7 | OpOff(addr, 0, 0) 8 | 9 | 10 | def make_dwords(start_ea, end_ea): 11 | ''' Transform data to dwords in hex (using 32-bit length) ''' 12 | for addr in range(start_ea, end_ea, 4): 13 | OpHex(addr, 0) 14 | 15 | -------------------------------------------------------------------------------- /listing/function_arguments.py: -------------------------------------------------------------------------------- 1 | ''' Make comment to function, using it's argument (using x86 mnemonics) 2 | ''' 3 | 4 | def get_function_arg_value(addr): 5 | ''' Find first function argument as an argument to PUSH before function call 6 | From command `PUSH 0x138` it will return integer value 312 (0x138) 7 | From command `PUSH EBX` it will return integer value 3 (as EBX is 3-rd register) 8 | ''' 9 | while True: 10 | addr = PrevHead(addr) 11 | if GetMnem(addr) == "push": 12 | break 13 | res = GetOperandValue(addr, 0) 14 | return addr, res 15 | 16 | 17 | def get_function_arg(addr): 18 | ''' Find first function argument as an argument to PUSH before function call 19 | From command `PUSH 0x138` it will return string value '0x138' 20 | From command `PUSH EBX` it will return string value 'EBX' 21 | ''' 22 | while True: 23 | addr = PrevHead(addr) 24 | if GetMnem(addr) == "push": 25 | break 26 | res = GetOpnd(addr, 0) 27 | return addr, res 28 | 29 | 30 | def comment_func(func_ea): 31 | ''' Make comment to function 32 | ''' 33 | i = 0 34 | for x in XrefsTo(func_ea, flags=0): 35 | addr, val = get_function_arg_value(x.frm) 36 | MakeComm(x.frm, "func_name(0x%08x)" % val) 37 | -------------------------------------------------------------------------------- /misc/parse_gdt.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Script for parsing Global Descriptor Table (x86) inside IDA Pro database 3 | 4 | https://wiki.osdev.org/Global_Descriptor_Table 5 | ''' 6 | 7 | from struct import pack, unpack 8 | 9 | 10 | def parse_access_byte(acc): 11 | pr = (acc & 0x80) >> 7 12 | privl = (acc & 0x60) >> 5 13 | ex = (acc & 0x8) >> 3 14 | dc = (acc & 0x4) >> 2 15 | rw = (acc & 0x2) >> 1 16 | ac = (acc & 0x1) 17 | res = " Access: Pr {:b} Privl {:02x} Ex {:b} DC {:b} RW {:b} Ac {:b}".format(pr, privl, ex, dc, rw, ac) 18 | return res 19 | 20 | 21 | def parse_GDT_record(bytes): 22 | limit_0_15, base_0_15 = unpack("HH", bytes[:4]) 23 | base_16_23, acc, flags_limit, base_24_31 = unpack("BBBB", bytes[4:]) 24 | base = pack("HBB", base_0_15, base_16_23, base_24_31) 25 | base = unpack("> 7 21 | dpl = (type_attr & 0x60) >> 5 22 | s = (type_attr & 0x10) >> 4 23 | gt = (type_attr & 0x0F) 24 | res = " cType --> Pr {:b}, Privl {:02x}, Storage {:b}, Gate: {}".format(p, dpl, s, 25 | GATE_TYPE.get(gt, "None")) 26 | return res 27 | 28 | 29 | def parse_IDT_record(bytes): 30 | offset_0_15, selector = unpack("HH", bytes[:4]) 31 | zero, type_attr, offset_16_31 = unpack("BBH", bytes[4:]) 32 | offset = pack("HH", offset_0_15, offset_16_31) 33 | offset = unpack("