I try to test a shellcode in FreeBSD 9 32bits running in VirtualBox, it's a simple shellcode that execute the classic execve("/bin/sh"). The tools I'm using are: nasm(1) and gcc(1).
Before nothing I want to say what is already tried:
So, I hope some one can illuminate my path (my lonely path...path...path..).
Here is the assembler code of the shellcode (intel's format):
and the C code to test the shellcode:
Before nothing I want to say what is already tried:
- Change the value of kern.elf32.nxstack=1 (and nothing happen).
- Compile the code with "-z execstack" option (and nothing happen).
- Compile the code with "-mpreferred-stack-boundary=2" (I'm not sure why, and again nothing happen).
So, I hope some one can illuminate my path (my lonely path...path...path..).
Here is the assembler code of the shellcode (intel's format):
Code:
shellcode.s
BITS 32
xor eax,eax
push eax
push '//sh'
push '/bin'
mov ebx,esp
push eax
push ebx
push ebx
push eax
mov al,0x3b
int 0x80
and the C code to test the shellcode:
Code:
char shellcode[]=
"\x31\xC0\x50\x68\x2F\x2F\x73\x68\x68\x2F\x62\x69\x6E\x89\xE3\x50"
"\x53\x53\x50\xB0\x3B\xCD\x80";
int main()
{
int *ret;
ret=(int *)&ret=2;
(*ret)=(int)shellcode;
return 0;
}