数据提取:以Hitcon-Training LAB1为例 | IDApython
ea=here()
print hex(ea),idc.GetDisasm(ea)
ch=idc.GetDisasm(ea)
print ch[-9:]
ea=here()
print hex(ea),idc.GetDisasm(ea)
ch=idc.GetDisasm(ea)
print ch[-9:]
print hex(ea+7),idc.GetDisasm(ea+7)
ch=idc.GetDisasm(ea+7)
print ch[-9:]
#脚本的制约条件:锁定.text的具体定位,只能在类似数组结构的开头
ea=here()
test=''
for i in range(12):
ch=idc.GetDisasm(ea+i*7)
test+=('0x'+ch[-9:]).rstrip('h')
test+=','
#print test
#print type(ch)
la=idc.GetDisasm(ea+12*7)
org=la[-3:]
num='0x'+org.rstrip('h')
test+=num
#print test
l=test.split(',')
#print l
list=[int(x.lstrip('0x'),16) for x in l]
#print list
str=""
for i in list:
str+=chr(i%0x100)
str+=chr(int(i%0x10000/0x100))
str+=chr(int(i%0x1000000/0x10000))
str+=chr(int((i%0x100000000/0x1000000)))
#str+=chr(0x3f)
print(str)
ea=here()
print ea,idc.GetDisasm(ea)
l=[]
#数据的提取,大致分为两种类型
for n in range(49):
i=idc.GetDisasm(ea+n*4)
if(i[-1:]=='h'): #可以已结尾是否是h作为判断标志对数据进行提取
cn=int("0x"+i[-3:-1],16)
else:
cn=int(i[-1:],10)
l.append(cn)
print l
#脚本的制约条件:锁定.text的具体定位,只能在类似数组结构的开头
ea=here()
test=''
for i in range(12):
ch=idc.GetDisasm(ea+i*7)
test+=('0x'+ch[-9:]).rstrip('h')
test+=','
#print test
#print type(ch)
la=idc.GetDisasm(ea+12*7)
org=la[-3:]
num='0x'+org.rstrip('h')
test+=num
#print test
l=test.split(',')
#print l
list=[int(x.lstrip('0x'),16) for x in l]
#print list
str=""
for i in list:
str+=chr(i%0x100)
str+=chr(int(i%0x10000/0x100))
str+=chr(int(i%0x1000000/0x10000))
str+=chr(int((i%0x100000000/0x1000000)))
#str+=chr(0x3f)
##print(str)
#ea=here()
#print ea,idc.GetDisasm(ea)
l=[]
#数据的提取,大致分为两种类型
for n in range(49):
i=idc.GetDisasm(ea+90+n*4)
if(i[-1:]=='h'): #可以已结尾是否是h作为判断标志对数据进行提取
cn=int("0x"+i[-3:-1],16)
else:
cn=int(i[-1:],10)
l.append(cn)
##print l
flag=""
for i in range(49):
flag+=chr(ord(str[i])^l[i])
print flag
上述两个地址的差值是用来计算两组数据的偏移的,用来具体的数据提取。
来源:freebuf.com 2021-04-20 18:20:05 by: zer01s
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持一下吧
请登录后发表评论
注册