c - 助记符中的无效字符 '\'

标签 c linux gcc assembly shellcode

我是 asm/shellcode 新手,在编译 ParrotOS 中作为模板包含的示例 shellcode 时遇到了问题。

我浏览了以下主题,但无法解决我的问题:

Assembly error: invalid character '$' in mnemonic

Invalid character (0xe2) in mnemonic

我尝试使用 as 命令代替 gcc,但是我遇到了同样的错误。

char code[] = 

    "\xe9\x1e\x00\x00\x00"  //          jmp    8048083 <MESSAGE>
    "\xb8\x04\x00\x00\x00"  //          mov    $0x4,%eax
    "\xbb\x01\x00\x00\x00"  //          mov    $0x1,%ebx
    "\x59"                  //          pop    %ecx
    "\xba\x0f\x00\x00\x00"  //          mov    $0xf,%edx
    "\xcd\x80"              //          int    $0x80
    "\xb8\x01\x00\x00\x00"  //          mov    $0x1,%eax
    "\xbb\x00\x00\x00\x00"  //          mov    $0x0,%ebx
    "\xcd\x80"              //          int    $0x80
    "\xe8\xdd\xff\xff\xff"  //          call   8048065 <GOBACK>
    "give me a bottle of rum!\r\n";     // OR       "\x48\x65\x6c\x6c\x6f\x2c\x20\x57"
                            //          "\x6f\x72\x6c\x64\x21\x0d\x0a"


int main(int argc, char **argv)
{
    (*(void(*)())code)();

    return 0;
}
gcc shellcode.s

shellcode.s: Assembler messages:
shellcode.s:1: Error: no such instruction: `char code[]='
shellcode.s:3: Error: invalid character '\' in mnemonic
shellcode.s:4: Error: invalid character '\' in mnemonic
shellcode.s:5: Error: invalid character '\' in mnemonic
shellcode.s:6: Error: invalid character '\' in mnemonic
shellcode.s:7: Error: invalid character '\' in mnemonic
shellcode.s:8: Error: invalid character '\' in mnemonic
shellcode.s:9: Error: invalid character '\' in mnemonic
shellcode.s:10: Error: invalid character '\' in mnemonic
shellcode.s:11: Error: invalid character '\' in mnemonic
shellcode.s:12: Error: invalid character '\' in mnemonic
shellcode.s:13: Error: no such instruction: `give me a bottle of rum!\r\n"'
shellcode.s:17: Error: junk `(int argc,char **argv)' after expression
shellcode.s:17: Error: operand size mismatch for `int'
shellcode.s:18: Error: no such instruction: `{'
shellcode.s:19: Error: junk at end of line, first unrecognized character is `('
shellcode.s:21: Error: no such instruction: `return 0'
shellcode.s:22: Error: junk at end of line, first unrecognized character is `}'

最佳答案

这是 C 代码,但它有一个 .s 扩展名,表示汇编。将文件重命名为 shellcode.c

关于c - 助记符中的无效字符 '\',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60394371/

相关文章:

c - 为什么 cross gcc 调用 native 'as' ?

c - C中不同类型的静态

c - 如果 C 试图扫描整数变量中的字符会发生什么

c++ - 在 for 循环中反转?

c - 访问 C 文件中的汇编宏函数/指令

linux - Qemu 卡在从硬盘启动

c - c中的迭代目录遍历

C:如何通过函数调用获取数组或二维数组的最后一个元素值

android - 如何在 Android 上使用 framebuffer 进行绘图?

python - psutil 总是返回 pid 存在