Skip to content

Instantly share code, notes, and snippets.

@JusticeRage
Forked from dperezmavro/nop-hidder
Last active November 24, 2023 00:53
Show Gist options
  • Save JusticeRage/795badf81fe59454963a06070d132b06 to your computer and use it in GitHub Desktop.
Save JusticeRage/795badf81fe59454963a06070d132b06 to your computer and use it in GitHub Desktop.
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