Skip to content

Instantly share code, notes, and snippets.

@dperezmavro
Created August 30, 2014 14:00
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dperezmavro/e778ba259cc91f315eed 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, SegEnd(seg_ea)):
if isCode(GetFlags(head)):
mnem = GetMnem(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:
HideArea(h[0],h[0]+h[1],'','','',0)
print 'Done hidding...'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment