1 can get filename is running process # pidoffilename2 can be seen through the file or tcpudp Protocol process # fuser-ntcpport3 can see the file modification time, size and other information # statfilename4 to see the loading Module # lsmod5 to see the rpc service open # rpcinfo-p6 to see if the NIC is mixed mode (promiscuousmod) # dmesg | grepeth07 to see whether the command is changed, like md5sum
1
The process where filename is running can be obtained.
# Pidof filename
2
You can see the process through the file or tcp udp protocol
# Fuser-n tcp port
3
You can view the file modification time, size, and other information.
# Stat filename
4
View the loading Module
# Lsmod
5
View rpc service opening
# Rpcinfo-p
6
Check whether the NIC is in promiscuous mod mode)
# Dmesg | grep eth0
7
Check whether the command is changed, like md5sum.
# Rpm-Vf/bin/ls
Rpm-Vf/bin/ps: No output; otherwise, a prompt such as sm5..... T/bin/su is output.
If the rpm database is modified, it is unreliable. It can only be compared through the network or the rpm database in cdrom.
Such as: rpm-Vvp ftp://mirror.site/dir/RedHat/RPMS/fileutils-3.16-10.i386.rpm
The following common commands need to be checked:
/Usr/bin/chfn
Usr/bin/chsh
/Bin/login
/Bin/ls
/Usr/bin/passwd
/Bin/ps
/Usr/bin/top
/Usr/sbin/in. rshd
/Bin/netstat
/Sbin/ifconfig
/Usr/sbin/syslogd
/Usr/sbin/inetd
/Usr/sbin/tcpd
/Usr/bin/killall
/Sbin/pidof
/Usr/bin/find
8
If you are checking the machine that has been identified as a hacker, we recommend that you:
1. dd a backup hard disk
2. mount an optical drive with commonly used tools such as static compiled programs ls ps netstat
3. Use nc to output the execution steps to a remote machine.
9
Use md5sum to save a Global File
Find/sbin-type f | xargs md5sum> 1st
Check for changes
Md5sum-c 1st | grep OK
10
To avoid excessive write operations on the attacked machine, you can:
1. Run on another machine 192.168.20.191
Nc-L-p 1234> some_audit_output.log note that L is in uppercase and can be listened permanently
2. Run on the attacked Machine
Command | nc 192.168.20.191 1234
Or
Script>/mnt/export. log
After detection, press ctrl + d to save the record.
11
Methods for searching suspicious programs through processes:
1. netstat-anp this step mainly relies on experience to record all suspicious items
2. Go to the memory directory cd/proc/3299
3. ls-la. Generally, exe can see the path of the execution file,
4. Go to the fd directory to view the file handle. At this point, you can find the executable program.
5. ps-awx: Check the suspicious process.
12
If hacker deletes the log:
1. Search for all thoroughly deleted logs, such as history and sniffer logs.
2. In the/proc/pid/fd directory, the system prompts that the file has been deleted.
L-wx ------ 1 root 64 Aug 10 :54 15->/var/log/httpd/error_log (deleted)
L-wx ------ 1 root 64 Aug 10 20:54 18->/var/log/httpd/ssl_engine_log (deleted)
L-wx ------ 1 root 64 Aug 10 20:54 19->/var/log/httpd/ssl_mutex.800 (deleted)
L-wx ------ 1 root 64 Aug 10 20:54 20->/var/log/httpd/access_log (deleted)
L-wx ------ 1 root 64 Aug 10 20:54 21->/var/log/httpd/access_log (deleted)
L-wx ------ 1 root 64 Aug 10 :54 22->/var/log/httpd/ssl_request_log (deleted)
L-wx ------ 1 root 64 Aug 10 :54 23->/var/log/httpd/ssl_mutex.800 (deleted)
Lrwx ------ 1 root 64 Aug 10 20:54 3->/var/run/httpd. mm.800.sem (deleted)
Lrwx ------ 1 root 64 Aug 10 20:54 4->/var/log/httpd/ssl_scache.sem (deleted)
3. Use the statically compiled lsof | grep deleted to check which files are deleted.
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
Gpm 1650 root 1u REG 149743/var/run/gpm208raa (deleted)
4. Obtain the inode Number of the file. The value is 149743.
5. Use sleuthkit to restore data,
Df/var: the hard disk location is sda1.
Icat/dev/sda1 149743
6. Check the recovered files carefully. Generally, traces can be found.
This makes it difficult to analyze compiled programs.
Gcc-04-edevil. c-o edevil
Strip./edevil
1. Check the file type, whether the file is statically compiled, and whether the file has been strip
2. strings: display the asicc string in the program. Use the string to search for it on google.
3. strace is used to track system calls (this does not know how to use) strace-p pid
4. gdb (not to be used)
13
Some processes are not displayed in the process, but there are traces in/proc, you can find hidden processes
Proc is a pseudo file system that provides a structured interface for/dev/kmem, allowing the system to diagnose and view every running Executable File environment.
# Ps-ef | awk '{print $2}' | sort-n | uniq> 1
# Ls/porc | sort-n | uniq> 2
# Diff 1 2
14
Emergency tool tct, which has many tools, including icat and other data recovery tools
If you have obtained evidence from the attacked machine, you can mount a hard disk or back up it to the network. The method is as follows:
A. Run nc-L-p 1234> abc. img on the network Machine
B. Run dd for broilers if =/dev/hdb5 count 20000 bs = 1024 | nc 192.168.0.1 1234-w 3
If the backup is too large, you can listen to multiple ports, execute multiple dd copies, and then merge the files into cat 2> 1.img
15
Ldd can display the dynamic library on which the executable program depends, but the indirect dependent library cannot be displayed.
[Root @ rh9bk root] # ldd/bin/ls
Libtermcap. so.2 =>/lib/libtermcap. so.2 (0x40022000)
Libc. so.6 =>/lib/tls/libc. so.6 (0x42000000)
/Lib/ld-linux.so.2 =>/lib/ld-linux.so.2 (0x40000000)
The strace tool is a debugging tool that displays all system calls during execution of a program,
[Root @ rh9bk root] # strace-eopen/bin/ls>/dev/null
Open ("/etc/ld. so. preload", O_RDONLY) =-1 ENOENT (No such file or directory)
Open ("/etc/ld. so. cache", O_RDONLY) = 3
Open ("/lib/libtermcap. so.2", O_RDONLY) = 3
Open ("/lib/tls/libc. so.6", O_RDONLY) = 3
Open ("/usr/lib/locale-archive", O_RDONLY | O_LARGEFILE) = 3
Open (".", O_RDONLY | O_NONBLOCK | O_LARGEFILE | O_DIRECTORY) = 3
Open ("/etc/mtab", O_RDONLY) = 3
Open ("/proc/meminfo", O_RDONLY) = 3
Strace-o out telnet 192.168.100.100
The meaning of the o parameter is to generate the strace output information to the out file, which can be determined at will.
When we open the out file, we will find a lot of system call Information. We are mainly concerned with the information of the open system call. open is used to open the file. Not only do we need to open the dynamic library before calling it, open is also used to read the configuration file. Therefore, you can use sed to write a simple script to output all open information in the out file.
Sed-n-e '/^ open/P' out
The output information is as follows:
Open ("/etc/ld. so. preload", O_RDONLY) =-1 ENOENT (No such file or directory)
Open ("/etc/ld. so. cache", O_RDONLY) = 3
Open ("/lib/libutil. so.1", O_RDONLY) = 3
Open ("/usr/lib/libncurses. so.5", O_RDONLY) = 3
Open ("/lib/i686/libc. so.6", O_RDONLY) = 3
Open ("/etc/resolv. conf", O_RDONLY) = 3
Open ("/etc/nsswitch. conf", O_RDONLY) = 3
Open ("/etc/ld. so. cache", O_RDONLY) = 3
Open ("/lib/libnss_files.so.2", O_RDONLY) = 3
Open ("/etc/services", O_RDONLY) = 3
Open ("/etc/host. conf", O_RDONLY) = 3
Open ("/etc/hosts", O_RDONLY) = 3
Open ("/etc/ld. so. cache", O_RDONLY) = 3
Open ("/lib/libnss_nisplus.so.2", O_RDONLY) = 3
Open ("/lib/libnsl. so.1", O_RDONLY) = 3
Open ("/var/nis/NIS_COLD_START", O_RDONLY) =-1 ENOENT (No such file or directory)
Open ("/etc/ld. so. cache", O_RDONLY) = 3
Open ("/lib/libnss_dns.so.2", O_RDONLY) = 3
Open ("/lib/libresolv. so.2", O_RDONLY) = 3
Open ("/etc/services", O_RDONLY) = 3
Open ("/root/. telnetrc", O_RDONLY) =-1 ENOENT (No such file or directory)
Open ("/usr/share/terminfo/l/linux", O_RDONLY) = 4
The output shows several libraries that cannot be displayed by ldd.
/Lib/libnss_dns.so.2,
/Lib/libresolv. so.2,
/Lib/libnsl. so.1,
/Lib/libnss_nisplus.so.2,
/Lib/libnss_files.so.2
Strace-o aa-ff-p PID will generate multiple files starting with the aa name
Grep open aa * | grep-v-e No-e null-e denied | grep WR view the file information of the open call.
16
To send logs to the log host, follow these steps:
A. vi/etc/syslog. conf *. * @ 192.168.20.163 send all logs to 192.168.20.163
B. service syslog restart
C. Install kiwisyslogd on 192.168.20.163
D. log on remotely and enter the wrong password. You can see an alarm immediately on the log host. You can also observe the tcpdump port 514.
17
If you know that the hacker is intruded by 0927, then:
Touch-t 09270000/tmp/
Find/\ (-newer/tmp/a-o-cnewer/tmp/a \)-l
In this way, the files changed and created on that day are listed.
18
Full disk Replication
Dd if =/dev/sda of =/dev/sdb bs = 1024
Partition replication tested
Dd if =/dev/sda1 of =/abc bs = 1024 this is saved in the root partition. Use mount to check that it is sda2.
Start another linux
Input: mount/dev/sda2/mnt
Here we can see the abc file, input: mount aa/tmp-o loop
Here we can see the image file content.
19 find
Find the file with the specified character (the binary file can also be found in the test, which is the content after strings)
Find/tmp-type f-exec grep "no exist" {}\;-print
Find/etc/rc. d-name '* crond'-exec file {};
Find/etc/rc. d. Run the file command to view the properties of all files ending with crond. Note: there is a space between exec and file, and a space between file and {}, file and; is a space,; Is a whole.
20
The kill-SIGSEGV process number will generate a core file, which can be viewed by strings. A c program can be used to re-build its executable program, and study/unix/will save an article. The test does not produce a core. The reason is unknown.