菜鸟Dump Memory python 脚本

直接用就行,改改地址啥的

from idaapi import *
from idc import *
import struct
def dump_memory(filename,start_add,size):
    fd=open(filename,"wb")
    for i in range(0,size,4):
        ea=start_add+i
        buf=idaapi.dbg_read_memory(ea,4)
        fd.write(buf)
    fd.close()
def write_memory(memoryfile,linefile,start_add):
    fd=open(memoryfile,'rb')
    fd2=open(linefile,'r')
    lines=fd2.readlines()
    for i in lines:
        pos=int(i[0:len(i)-2],16)
        ea=start_add+pos
        fd.seek(pos)
        buf=fd.read(1)
        buf=idaapi.dbg_write_memory(ea,buf)      
    fd2.close()
    fd.close()
def write_all_memory(memoryfile,start_add):
    fd=open(memoryfile,'rb')
    fd.seek(0,2)
    pos=fd.tell()
    fd.seek(0,0)
    for i in range(pos):
        ea=start_add+i
        buf=fd.read(1)
        buf=idaapi.dbg_write_memory(ea,buf)      
    fd.close()
def write_pwd():
    ea=0x3f6eee
    idaapi.dbg_write_memory(ea,struct.pack('=H',0x0035))
    ea=ea+2
    idaapi.dbg_write_memory(ea,struct.pack('=H',0x0031))
    ea=ea+2
    idaapi.dbg_write_memory(ea,struct.pack('=H',0x0032))
    ea=ea+2
    idaapi.dbg_write_memory(ea,struct.pack('=H',0x0035))
    ea=ea+2
    idaapi.dbg_write_memory(ea,struct.pack('=H',0x0031))
    ea=ea+2
    idaapi.dbg_write_memory(ea,struct.pack('=H',0x0032))
    ea=ea+2
    idaapi.dbg_write_memory(ea,struct.pack('=H',0x0035))
    ea=ea+2
    idaapi.dbg_write_memory(ea,struct.pack('=H',0x0031))
    ea=ea+2
    idaapi.dbg_write_memory(ea,struct.pack('=H',0x0032))
filename='memory'
linefile='result_compare.txt'
start=0x7c00
size=0x300000
#dump_memory(filename,start,size)
write_memory(filename,linefile,start)
#write_all_memory(filename,start)
#print idaapi.dbg_get_registers()
#write_pwd()
print "run_ok"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值