菜鸟IDA python调试脚本

IDA动态调试下断点 还是比较费劲的,写个脚本可能更好一些
import idc
import idaapi
import struct

#idaapi.dbg_write_memory(ea,buf)
idaapi.enable_extlang_python(1)
md={}
add=0
size=0
index=0
cross_refs=0
findname=["MZ","PE"]
for func in findname:
         addr=LocByName(func)
         if addr!=BADADDR:
             cross_refs=CodeRefsTo(addr,0)
             print "got it"
         for ref in range(cross_refs):
             print "%08x"% ref
             SetColor(ref,CiC_ITEM,0x0000ff)
def createfile():
         global md
     #print "code %d  \ninput %d" % (GetRegValue("eax") ,GetRegValue("edi"))
     ea1=GetRegValue("esp")+4
         buf=""
        
     a=idc.Dword(ea1)
         
     #print "s%x\n" % a
         for i in range(50):
          k=idc.Byte(a+i)
          buf=buf+chr(k)
         print "filename  ___%s_____\n" % buf
     #SetRegValue(0x11113333,"edx")
         md[ea1]=buf
         
     return 1
print "start"
def readfile():
  global add, size,index
  index=index+1
  if GetRegValue("eip")==0x20095280:
     add=Dword(GetRegValue("esp")+8)
     size=Dword(GetRegValue("esp")+12)
  if GetRegValue("eip")==0x20095338:
     b=""
     for i in range(size) :
         b=b+chr(Byte(add+i))
     v="%d" %index
     file0=r"c:\hk"+v+"dat"
     file1=r"c:\hk"+v+"dat"
     f1=open(file0,"wb")
     f1.write(b)
     f1.close()
     f1=open(file1,"w")
     f1.write(b)
     f1.close()
  return 1
ea=0x7c00 #fopen
idc.AddBpt(ea)
idc.SetBptAttr(ea,  BPTATTR_FLAGS, GetBptAttr(ea, BPTATTR_FLAGS)&0xfffe)
idc.SetBptCnd(ea, 'createfile()')

ea=0x20001000 #fopen
idc.AddBpt(ea)
idc.SetBptAttr(ea,  BPTATTR_FLAGS, GetBptAttr(ea, BPTATTR_FLAGS)&0xfffe)
idc.SetBptCnd(ea, 'createfile()')  

ea=0x20095960 #fopen
idc.AddBpt(ea)
idc.SetBptAttr(ea,  BPTATTR_FLAGS, GetBptAttr(ea, BPTATTR_FLAGS)&0xfffe)
idc.SetBptCnd(ea, 'createfile()')

ea=0x20095280 #fopen
idc.AddBpt(ea)
idc.SetBptAttr(ea,  BPTATTR_FLAGS, GetBptAttr(ea, BPTATTR_FLAGS)&0xfffe)
idc.SetBptCnd(ea, 'readfile()')


ea=0x20095338 #fopen
idc.AddBpt(ea)
idc.SetBptAttr(ea,  BPTATTR_FLAGS, GetBptAttr(ea, BPTATTR_FLAGS)&0xfffe)
idc.SetBptCnd(ea, 'readfile()')


print "end"
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值