Skip to content

Instantly share code, notes, and snippets.

import idaapi
import idc
import inspect
def selection_is_valid(selection, ea):
"""If the cursor is not at the beginning or the end of our selection, assume that
something bad has gone wrong and bail out instead of turning a lot of important
things into dwords.
"""
if not (ea == selection[1] or ea == selection[2]-1):
import re
import binascii
import sys
def convert_hex(input_file, output_file):
""" input: list containing raw lines of hex
output: continuous binary data
"""
last_addr = None
for line in input_file:
@bNull
bNull / gist:7684598
Created November 27, 2013 23:01
python hexdump
def hexdump(src, length=16, sep='.'):
"""Modified from: https://gist.github.com/7h3rAm/5603718
"""
FILTER = ''.join([(len(repr(chr(x))) == 3) and chr(x) or sep for x in range(256)])
lines = []
for c in xrange(0, len(src), length):
chars = src[c:c+length]
hex = ' '.join(["%02x" % ord(x) for x in chars])
if len(hex) > 24:
hex = "%s %s" % (hex[:24], hex[24:])
@bNull
bNull / gist:6003874
Last active August 1, 2021 07:43
IDA Python script that will allow you to highlight a range of bytes and turn it into dwords (for manually fixing up tables or whatever).
# hotkey_utils.py - bNull
#
# Some useful shortcuts for binding to hotkeys. Current output/hotkeys:
#
# [+] Bound make_dwords to Ctrl-Alt-D
# [+] Bound make_cstrings to Ctrl-Alt-A
# [+] Bound make_offset to Ctrl-Alt-O
import idaapi
import idc