Inn*_*wit 2 c linux assembly gcc shellcode
我是 asm/shellcode 新手,我在编译 ParrotOS 中作为模板包含的示例 shellcode 时遇到了麻烦。
我浏览了以下主题,但它无法解决我的问题:
我尝试使用ascommand 而不是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;
}
Run Code Online (Sandbox Code Playgroud)
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 `}'
Run Code Online (Sandbox Code Playgroud)
默认情况下,gcc 根据扩展名决定编译文件的语言。
根据其内容正确重命名文件是正确的做法(正如已经建议的那样)
如果由于某种原因您无法重命名文件,您还可以gcc使用以下-x选项强制编译具有给定(支持)语言的任何扩展名的文件:
gcc -x c shellcode.s
Run Code Online (Sandbox Code Playgroud)
此开关设置语言但不设置默认链接选项。尝试gcc使用 C++ 文件创建可执行文件失败,因为gcc默认情况下链接驱动程序不会添加 C++ 库。