pydbg 可以做好多事情,这里我把自己常用的一些代码写上来;
方便找到进程并加载
findpid=True
print "Finding ...\n"
while findpid:
for i in dbg.enumerate_processes():
if i[1]=='stark.exe':
dbg.attach(i[0])
findpid=False
print "Find The Piroc\n"
设置函数短点(软),并在回掉函数中打印出当前堆栈的24字节:
def msghandle(dbg):
offser=0
while 1:
print "%08x" % int(dbg.context.Esp+offser)
offser+=4
if offser==24:break
return DBG_CONTINUE
msg=dbg.func_resolve('user32','MessageBoxA')
dbg.bp_set(msg,handler=msg_crashbin)
cash_bing显示,略过第一次错误:
if dbg.dbg.u.Exception.dwFirstChance:
return DBG_EXCEPTION_NOT_HANDLED
crash_bin = utils.crash_binning.crash_binning()
crash_bin.record_crash(dbg)
print crash_bin.crash_synopsis()
return DBG_EXCEPTION_NOT_HANDLED
进程快照:
#创建快照
dbg.suspend_all_threads()
dbg.process_snapshot()
dbg.resume_all_threads()
还原快照
dbg.suspend_all_threads()
dbg.process_restore()
dbg.resume_all_threads()