Saturday, March 30, 2019

What is shellcode

Simply shellcode is opcode in machine language.
This can be extract from low level languages such as assembly, c
Lets say there is a c file which do something called dosomething.c

gcc -o dosomething.o dosomething.c

When execute shellcode.o it will do something. We need to get machine code of this process.

C:\Users\Ali\Desktop>objdump -D shellcode.o

Now we can see machine code and asm instructions. Using this we can build the shellcode.

00000000 <.text>:
   0:   31 c0                   xor    %eax,%eax
   2:   50                      push   %eax
   3:   b8 41 41 41 64          mov    $0x64414141,%eax
   8:   c1 e8 08                shr    $0x8,%eax
   b:   c1 e8 08                shr    $0x8,%eax
   e:   c1 e8 08                shr    $0x8,%eax