Linux服务器被攻击,检查方法 您所在的位置:网站首页 怎么对服务器进行攻击 Linux服务器被攻击,检查方法

Linux服务器被攻击,检查方法

2024-06-16 05:23| 来源: 网络整理| 查看: 265

一、检查系统密码文件,查看文件修改日期

# ls -l /etc/passwd

二、查看 passwd 文件中有哪些特权用户

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

三、查看系统里有没有空口令帐户

# awk -F: 'length($2)==0 {print $1}' /etc/shadow

四、检查系统守护进程

# cat /etc/xinetd.conf | grep -v "^#" #这个进程在centos7以上没有了

五、检查网络连接和监听端口

# netstat –an # netstat –rn # ifconfig –a

六、查看正常情况下登录到本机的所有用户的历史记录

# last

七、检查系统中的 core 文件

# find / -name core -exec ls -l {} \;

八、检查系统文件完整性

# rpm -Vf /bin/ls # rpm -Vf /usr/sbin/sshd # rpm -Vf /sbin/ifconfig # rpm -Vf /usr/sbin/lsof # md5sum –b 文件名 # md5sum –t 文件名

九、查找是否有后门

# cat /etc/crontab # ls /var/spool/cron/ ; crontab -l #查看定时任务是否被修改 # cat /etc/rc.d/rc.local # ls /etc/rc.d # ls /etc/rc3.d # find / -type f -perm 4000 #查看是否为管理员增加或者修改

十、查看临时目录是否存在攻击者入侵时留下的残余文件

#tail -n 100 ~/.bash_history | more #是否存在.c .py .sh为后缀的文件或者2进制elf文件 ls -la /tmp ls -la /var/tmp find / -name \*.elf | xargs ls -l

十一、在web目录下运行

#查看是否有木马 grep -r "getRuntime" ./ #运行的时候被连接或者被任何程序调用 find . -type f -name "*.jsp" | xargs grep -i "getRuntime" #返回ip地址字符串 find . -type f -name "*.jsp" | xargs grep -i "getHostAddress" #创建WshShell对象可以运行程序、操作注册表、创建快捷方式、访问系统文件夹、管理环境变量 find . -type f -name "*.jsp" | xargs grep -i "wscript.shell" #gethostbyname()返回对应于给定主机名的包含主机名字和地址信息的hostent结构指针 find . -type f -name "*.jsp" | xargs grep -i "gethostbyname" #调用系统命令提权 find . -type f -name "*.jsp" | xargs grep -i "bash" #Jsp木马默认名字 find . -type f -name "*.jsp" | xargs grep -i "jspspy" #检查是否有非授权访问管理日志 find . -type f -name "*.jsp" | xargs grep -i "getParameter" #要进中间件所在日志目录运行命令 fgrep –R "admin_index.jsp" 20170702.log > log.txt #递归地读取每个目录下的所有文件 #查看是否出现对应的记录 fgrep –R "and1=1" *.log > log.txt fgrep –R "select " *.log > log.txt fgrep –R "union " *.log > log.txt fgrep –R "../../" *.log > log.txt fgrep –R "Runtime" *.log > log.txt fgrep –R "passwd" *.log > log.txt #查看是否有shell攻击 fgrep –R "uname -a" *.log > log.txt fgrep –R "id" *.log > log.txt fgrep –R "ifconifg" *.log> log.txt fgrep –R "ls -l" *.log > log.txt

十二、安装chrootkit,检查是否有rootkit rootkit是入侵者经常使用的工具,这类工具可以隐秘、令用户不易察觉的建立了一条能够总能够入侵系统或者说对系统进行实时控制的途径。

yum install -y glibc-static mkdir chrootkit cd chrootkit/ wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz tar zxvf chkrootkit.tar.gz cd chkrootkit-0.52/ make sense #编译 ./chkrootkit #检测命令,若出现INFECTED那就要小心了(./chkrootkit | grep INFECTED)

检测脚本,放到定时任务里面即可

#!/bin/bash #sript name:chkrootkit.sh TOOLKITSPATH=/usr/local MAILUSER=root@localhost file_chkrootkit_log=chkrootkitcron.log servername=`hostname` date=`date +%Y-%m-%d` cd ${TOOLKITSPATH}/chkrootkit ./chkrootkit > ${file_chkrootkit_log} [ ! -z "$(grep INFECTED ${file_chkrootkit_log})" ] && \ grep INFECTED ${file_chkrootkit_log} | mail -s "[chkrootkit] report in ${servername} ${date}" ${MAILUSER}

备注:登录的时候提示信息在 /etc/motd 文件里面

十三、bash shell 漏洞 1、测试代码,有问题的

[root@localhost ~]# env x='() { :;}; echo vulnerable' bash -c "echo this is a test" vulnerable this is a test

2、修复(下面是参考网上的东西,不知道效果怎么样)

[root@localhost ~]# yum -y install yum-downloadonly [root@localhost ~]# yum -y install bash-4.1.2-33.el6_7.1.x86_64.rpm

3、重新测试

[root@localhost ~]# env x='() { :;}; echo vulnerable' bash -c "echo this is a test" this is a test #备注 当我们输入 env x='() { :;}; echo vulnerable'; bash -c "echo this is a test" 又可以出来不一样的效果

十四、完成后做了如下措施

修改了root账号密码 修改了sshd默认端口 修改Nginx用户nologin 发现系统服务器存在bash严重漏洞、破壳漏洞(Shellshock)并修复


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有