def scan(patt,start=0,end=0):
pattern = patt
if start:
addr = start
else:
addr = MinEA()
if end:
addr1 = end
else:
addr1 = MaxEA()
l = []
# for i in range(addr,MaxEA()):
for i in range(addr,addr1):
addr = idc.FindBinary(addr, SEARCH_DOWN|SEARCH_NEXT, pattern)
if addr != idc.BADADDR:
l.append(addr)
return l
def patch_nop(l,pos,count):
for addr in l:
for n in xrange(count/2):
PatchWord(addr+pos+2*n,0x9090)
if count/2:
PatchByte(addr+pos+count-1,0x90)
def search_junk(s,pos,length,name,start=MinEA(),end=MaxEA()):
l = scan(s)
c = len(l)
# length = len(s.replace(' ',''))/2
while c:
patch_nop(l,pos,length)
print "[*]Find %s %d places,and patched."%(name,c)
l = scan(s)
c = len(l)