Search code examples
scanfshellcode

Insert shell code


I got a small question.

Say I have the following code inside a console application :

printf("Enter name: ");

scanf("%s", &name);

I would like to exploit this vulnerability and enter the following shell code (MessageboxA):

6A 00 68 04 21 2F 01 68 0C 21 2F 01 6A 00 FF 15 B0 20 2F 01

How can I enter my shell code (Hex values) through the console ?

If I enter the input as is, it treats the numbers as chars and not as hex values.

Thanks a lot.


Solution

  • You could use as stdin a file with the desired content or use the echo command.

    Suppose your shell code is AA BB CC DD (obviously this is not a valid shellcode):

    echo -e "\xAA\xBB\xCC\xDD" | prog