Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An IDA python script that hides long sequences of nops to make the tree more readable.
from idautils import *
from idc import *
mnemonics = dict()
hides = []
in_nop_sled = 0
curr_pos = 0
sled_len = 0
for seg_ea in Segments():
for head in Heads(seg_ea, get_segm_end(seg_ea)):
if is_code(get_full_flags(head)):
mnem = print_insn_mnem(head)
if mnem == 'nop':
sled_len += 1
if in_nop_sled == 0:
curr_pos = head
in_nop_sled = 1
else :
if in_nop_sled == 1 :
in_nop_sled = 0
hides.append([curr_pos,sled_len])
curr_pos = 0
sled_len = 0
for h in hides:
if h[1] > 1:
add_hidden_range(h[0],h[0]+h[1],'[NOPs]','','',0xFFFFFF)
print('Done hidding...')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment