内联汇编错误,阻止 gcc 编译尝试
你好,所以。
我尝试使用 gcc 编译一些代码,但我的尝试遭到了挫败。任何更熟悉这个主题的人都可以帮助我,也许我缺少一些东西。
我正在 Linux Kitchen 2.6.28-15-generic #49-Ubuntu SMP Tue Aug 18 19:25:34 UTC 2009 x86_64 GNU/Linux 上编译此代码。
int
main(void)
{
__asm__(
"xorq %rdx,%rdx"
"movq $0x68732f6e69622fff, %rdx"
"shr $0x8, %rbx"
"push %rbx"
"movq %rsp,%rdi"
"xorq %rax,%rax"
"pushq %rax"
"pushq %rdi"
"movq %rsp,%rsi"
"mov $0x3b, %al"
"syscall"
"pushq $0x1"
"pop %rdi"
"pushq $0x3c"
"pop %rax"
"syscall"
);
return 0;
}
返回的错误是:
$ gcc -o shellcode shellcode.c
shellcode.c: Assembler messages:
shellcode.c:4: Error: bad register name `%rdxmovq $0x68732f6e69622fff'
谢谢大家。
Greetings, SO.
I have some code which I've made attempts at compiling using gcc, but my attempts have been thwarted. Could anyone more versed assist me with the subject, perhaps there's something I'm missing.
I'm compiling this code on Linux Kitchen 2.6.28-15-generic #49-Ubuntu SMP Tue Aug 18 19:25:34 UTC 2009 x86_64 GNU/Linux.
int
main(void)
{
__asm__(
"xorq %rdx,%rdx"
"movq $0x68732f6e69622fff, %rdx"
"shr $0x8, %rbx"
"push %rbx"
"movq %rsp,%rdi"
"xorq %rax,%rax"
"pushq %rax"
"pushq %rdi"
"movq %rsp,%rsi"
"mov $0x3b, %al"
"syscall"
"pushq $0x1"
"pop %rdi"
"pushq $0x3c"
"pop %rax"
"syscall"
);
return 0;
}
The error that is returned is:
$ gcc -o shellcode shellcode.c
shellcode.c: Assembler messages:
shellcode.c:4: Error: bad register name `%rdxmovq $0x68732f6e69622fff'
Thanks, everyone.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将换行符 (
\n
) 放入引用的内联程序集中。否则,它认为这确实是
所以前两行(依此类推)应该更像这样:
You need to put newlines (
\n
) into your quoted inline assembly. Otherwise, it thinks thatis really
So the first two lines (and so on) should be more like this: