0

I have been researching shellcodes lately, but before I dive into reverse shells and other malicious exploits I want to gain a more benign understanding.

I found this tutorial which makes a message box appear. The code has been included below, which I have tried to use in Visual Studio C++.

char shellcode[] = "\x31\xd2\xb2\x30\x64\x8b\x12\x8b\x52\x0c\x8b\x52\x1c\x8b\x42"
"\x08\x8b\x72\x20\x8b\x12\x80\x7e\x0c\x33\x75\xf2\x89\xc7\x03"
"\x78\x3c\x8b\x57\x78\x01\xc2\x8b\x7a\x20\x01\xc7\x31\xed\x8b"
"\x34\xaf\x01\xc6\x45\x81\x3e\x46\x61\x74\x61\x75\xf2\x81\x7e"
"\x08\x45\x78\x69\x74\x75\xe9\x8b\x7a\x24\x01\xc7\x66\x8b\x2c"
"\x6f\x8b\x7a\x1c\x01\xc7\x8b\x7c\xaf\xfc\x01\xc7\x68\x79\x74"
"\x65\x01\x68\x6b\x65\x6e\x42\x68\x20\x42\x72\x6f\x89\xe1\xfe"
"\x49\x0b\x31\xc0\x51\x50\xff\xd7";


int main(int argc, char **argv)
{
    int (*f)();
    f = (int (*)())shellcode;
    (int)(*f)();
}

Could someone please help me resolve this error at compile time?

Error 1 error C2440: 'type cast' : cannot convert from 'char [114]' to 'int (__cdecl *)(void)' removed_path 18 1

RTXGamer
  • 3,215
  • 6
  • 20
  • 29
plagiarism
  • 13
  • 6
  • Compile it as C code not as C++. – kaylum Oct 24 '21 at 22:35
  • 1
    Even if it does compile, it may not work depending on system security settings (NOEXECUTE protection, where data cannot be executed). – 1201ProgramAlarm Oct 24 '21 at 22:40
  • Related to problems executing after you compile as `c` code instead of `c++` :[https://stackoverflow.com/questions/20028892/how-to-execute-x86-commands-from-data-buffer](https://stackoverflow.com/questions/20028892/how-to-execute-x86-commands-from-data-buffer) – drescherjm Oct 24 '21 at 23:00
  • It compiles now, as a C console application. However, no message box appears... – plagiarism Oct 24 '21 at 23:00
  • Are you using windows 7 or Windows XP or some older OS? I expect Windows 10 to prevent this from working. However I could be wrong. – drescherjm Oct 24 '21 at 23:02
  • @drescherjm Windows 10. – plagiarism Oct 24 '21 at 23:03

0 Answers0