本文介绍了如何在gdb中直接运行组装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用呼叫
来运行的C函数,但如何组装,甚至壳$ C $运行C直接?
I can use call
to run c functions ,but how to run assembly or even shell code directly?
推荐答案
要执行shell code,你可以直接编辑功能的内容:
To execute shell code, you can edit a function's contents directly:
(gdb) b foo
Breakpoint 1 at 0x400608
(gdb) run
Breakpoint 1, 0x0000000000400608 in foo ()
(gdb) x/16bx foo
0x400604 <foo>: 0x55 0x48 0x89 0xe5 0x53 0x48 0x81 0xec
(gdb) set ((unsigned char *)foo)[6] = 0x85
(gdb) x/16bx foo
0x400604 <foo>: 0x55 0x48 0x89 0xe5 0x53 0x48 0x85 0xec
(gdb) cont
我不知道如何从 GDB
执行运算codeS,但你肯定可以做任何你想要的寄存器。例如,而不是 MOV%RBX,%RAX
您可以使用设置$ RAX = $ RBX
:
I don't know how to execute opcodes from within gdb
, but you can certainly do whatever you want with registers. For instance, instead of mov %rbx, %rax
you can use set $rax = $rbx
:
(gdb) p $rax
$1 = 3671197290184
(gdb) set $rax = $rbx
(gdb) p $rax
$2 = 0
(gdb)
这篇关于如何在gdb中直接运行组装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!