MyGems
MyGems
pwntools gdb 调试脚本
attach_dbg_pie(io,brk_pts=[],syms={},init_cmd=[])
brk_pts
(断点)和 syms
(符号)的地址是低12位,可以在IDA中查看。
init_cmd
:gdb脚本,多行组成的列表。
from pwn import *
def attach_dbg_pie(io,brk_pts=[],syms={},init_cmd=[]):
context.log_level='debug'
context.terminal=['tmux','splitw','-h']
elf_base=io.libs()[io.cwd+io.argv[0].strip('.')]
cmd = ['b *'+hex(each+elf_base) for each in brk_pts] \
+ ['set $'+sym+'='+str(syms[sym]+elf_base) for sym in syms]
cmd='\n'.join(cmd)+'\n'
cmd += '\n'.join(init_cmd)+'\n'
gdb.attach(io,cmd)
def attach_dbg(io,brk_pts=[],syms={},init_cmd=''):
context.log_level='debug'
context.terminal=['tmux','splitw','-h']
cmd = ['b *'+hex(each) for each in brk_pts] \
+ ['set $'+sym+'='+str(syms[sym]) for sym in syms]
cmd='\n'.join(cmd)+'\n'
cmd += '\n'.join(init_cmd)+'\n'
gdb.attach(io,cmd)
def testing():
io=process("./babyheap")
attach_dbg(io,[0x102,0x200,0x2000])
io.interactive()
if __name__=='__main__':
testing()
效果
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论。
文章标题:MyGems
本文作者:枫云李
发布时间:2020-04-23, 13:41:24
最后更新:2020-04-23, 13:51:56
原始链接:https://primelyw.github.io/2020/04/23/MyGems/版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。