gpt4 book ai didi

linux - GCC 汇编语言编译器错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:14:00 26 4
gpt4 key购买 nike

void main()
{
__asm__
(
"jmp 0x2a
popl %esi
movl %esi, 0x8(%esi)
movb $0x0, 0x7(%esi)
movl $0x0, 0xc(%esi)
movl $0xb, %eax
movl %esi, %ebx
leal 0x8(%esi), %ecx
leal 0xc(%esi), %edx
int $0x80
movl $0x1, %eax
movl $0x0, %ebx
int $0x80
call -0x2f
.string \"/bin/sh\"
");
}

我遵循了shellcode 教程,但是当我用gcc shellcodeasm.c 编译它时,出现以下错误:

shellcodeasm.c: In function ‘main’:
shellcodeasm.c:5:4: warning: missing terminating " character [enabled by default]
"jmp 0x2a
^
shellcodeasm.c:5:4: error: missing terminating " character
shellcodeasm.c:6:4: error: expected string literal before ‘popl’
popl %esi
^
shellcodeasm.c:19:4: error: stray ‘\’ in program
.string \"/bin/sh\"
^
shellcodeasm.c:19:13: warning: missing terminating " character [enabled by default]
.string \"/bin/sh\"
^
shellcodeasm.c:19:4: error: missing terminating " character
.string \"/bin/sh\"
^
shellcodeasm.c:20:4: warning: missing terminating " character [enabled by default]
");
^
shellcodeasm.c:20:4: error: missing terminating " character

我是这方面的新手。

最佳答案

虽然我已经确定这是另一个问题的重复,但您可以通过在内联汇编的每一行的开头和结尾放置一个引号并在每个字符串的末尾嵌入一个换行符来解决这个问题:

void main()
{
__asm__
(
"jmp 0x2a\n"
"popl %esi\n"
"movl %esi, 0x8(%esi)\n"
"movb $0x0, 0x7(%esi)\n"
"movl $0x0, 0xc(%esi)\n"
"movl $0xb, %eax\n"
"movl %esi, %ebx\n"
"leal 0x8(%esi), %ecx\n"
"leal 0xc(%esi), %edx\n"
"int $0x80\n"
"movl $0x1, %eax\n"
"movl $0x0, %ebx\n"
"int $0x80\n"
"call -0x2f\n"
".string \"/bin/sh\"\n"
);
}

关于linux - GCC 汇编语言编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33076898/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com