应急响应-LINUX

入侵思路排查

1.账号安全

2.历史命令

3.异常端口

4.异常进程

5.开机启动项

6.检查定时任务

7.检查服务

8.检查异常文件

9.检查日志

账号安全

/etc/passwd    账号文件
/etc/shadow    密码文件

查看当前登录用户

who   tty为本地登录   pts为远程登录

应急响应-LINUX_第1张图片

w    查看系统信息,想知道某一时刻用户的行为

uptime    查看登录多久,多少用户

查询特权用户uid

awk -F: '$3==0{print $1}' /etc/passwd

 查询可以远程登录的帐号信息

awk '/\$1|\$6/{print $1}' /etc/shadow

除root帐号外,其他帐号是否存在sudo权限。 

more /etc/sudoers | grep -v "^#\|^$" | grep "ALL=(ALL)"

删除或禁用可疑账号

usermod -L user 禁用帐号,帐号无法登录,/etc/shadow第二栏为!开头
userdel user 删除user用户
userdel -r user 将删除user用户,并且将/home目录下的user目录一并删除

查看历史命令

history

如果历史命令被清除就查看存储历史命令的文件

cat .bash_history >> 1.txt

异常端口

netstat -anplt          查看所有端口和进程id

pa aux  | grep pid号    查看pid所对应的详细进程

kill -9   pid  号        有异常的就杀了

检查自启项

more /etc/rc.local /etc/rc.d/rc[0~6].d ls -l /etc/rc.d/rc3.d

检查定时任务

Linux的计划任务是crontab

crontab -l  -u 用户名        列出该用户写的计划任务
more /etc/cron.daily/*

检查自启动服务

chkconfig --list

检查异常文件

find /opt -iname "*" -atime 1 -type f

检查日志

/var/log/

应急响应-LINUX_第2张图片

1、定位有多少IP在爆破主机的root帐号:
grep "Failed password for root" /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr
| more
定位有哪些IP在爆破:
grep "Failed password" /var/log/secure|grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4]
[0-9]|[01]?[0-9][0-9]?)"|uniq -c
爆破用户名字典是什么?
grep "Failed password" /var/log/secure|perl -e 'while($_=<>){ /for(.*?) from/; print
"$1\n";}'|uniq -c|sort -nr
2、登录成功的IP有哪些:
grep "Accepted " /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr | more
登录成功的日期、用户名、IP:
grep "Accepted " /var/log/secure | awk '{print $1,$2,$3,$9,$11}'
3、增加一个用户kali日志:
Jul 10 00:12:15 localhost useradd[2382]: new group: name=kali, GID=1001
Jul 10 00:12:15 localhost useradd[2382]: new user: name=kali, UID=1001, GID=1001,
home=/home/kali
, shell=/bin/bash
Jul 10 00:12:58 localhost passwd: pam_unix(passwd:chauthtok): password changed for kali
#grep "useradd" /var/log/secure
4、删除用户kali日志:
Jul 10 00:14:17 localhost userdel[2393]: delete user 'kali'
Jul 10 00:14:17 localhost userdel[2393]: removed group 'kali' owned by 'kali'
Jul 10 00:14:17 localhost userdel[2393]: removed shadow group 'kali' owned by 'kali'
# grep "userdel" /var/log/secure
5、su切换用户:
Jul 10 00:38:13 localhost su: pam_unix(su-l:session): session opened for user good by
root(uid=0)
sudo授权执行:
sudo -l
Jul 10 00:43:09 localhost sudo: good : TTY=pts/4 ; PWD=/home/good ; USER=root ;
COMMAND=/sbin/shutdown -r now

 

你可能感兴趣的:(应急响应,linux,服务器,运维)