菜鸟IDA python调试脚本
2015-08-12 21:24
771 查看
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"
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"
相关文章推荐
- 菜鸟Dump Memory python 脚本
- 元组 列表 集合 字典 python
- python的nltk中文使用和学习资料汇总帮你入门提高
- 用PDB库调试Python程序
- Python+NLTK自然语言处理学习(一):环境搭建
- 《head first python》——文件与异常
- python中的map、filter、reduce函数
- python函数——根据经纬度计算距离公式的错误及修正
- python项目的运行步骤(以飞转为例,较完整)
- python 环境安装
- Python进阶 函数式编程
- bottle(python的一个小的服务器框架)的源码阅读(一)
- 第一课python
- 【Python】[高级特性]切片,迭代,列表生成式,生成器,迭代器
- 【Python】[函数式编程]高阶函数,返回函数,装饰器,偏函数
- Python新式类和旧式类的区别
- python之路-------第4章、介绍python对象类型
- 安装python软件找不到setuptools的解决方案
- 安装python软件找不到setuptools的解决方案
- python中socket发送也研究了半天