zoukankan      html  css  js  c++  java
  • linux服务器被攻击处理过程

    开始排查

    首先检查日志,以前做过安全运维,所以写过类似于检查命令和工具,开始一一排查。

    #查看是否为管理员增加或者修改
    find / -type f -perm 4000
    #显示文件中查看是否存在系统以外的文件
    rpm -Vf /bin/ls
    rpm -Vf /usr/sbin/sshd
    rpm -Vf /sbin/ifconfig
    rpm -Vf /usr/sbin/lsof
    #检查系统是否有elf文件被替换
    #在web目录下运行
    grep -r "getRuntime" ./
    #查看是否有木马
    find . -type f -name "*.jsp" | xargs grep -i  "getRuntime"
    #运行的时候被连接或者被任何程序调用
    find . -type f -name "*.jsp" | xargs grep -i  "getHostAddress"
    #返回ip地址字符串
    find . -type f -name "*.jsp" | xargs grep -i  "wscript.shell"
    #创建WshShell对象可以运行程序、操作注册表、创建快捷方式、访问系统文件夹、管理环境变量
    find . -type f -name "*.jsp" | xargs grep -i  "gethostbyname"
    #gethostbyname()返回对应于给定主机名的包含主机名字和地址信息的hostent结构指针
    find . -type f -name "*.jsp" | xargs grep -i  "bash"
    #调用系统命令提权
    find . -type f -name "*.jsp" | xargs grep -i  "jspspy"
    #Jsp木马默认名字
    find . -type f -name "*.jsp" | xargs grep -i  "getParameter"
    fgrep - R "admin_index.jsp" 20120702.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
    #查看是否出现对应的记录
    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
    #查看是否有shell攻击
    #以root权限执行
    cat /var/log/secure
    #查看是否存在非授权的管理信息
    tail -n 10  /var/log/secure
    last cat /var/log/wtmp
    cat /var/log/sulog
    #查看是否有非授权的su命令
    cat /var/log/cron
    #查看计划任务是否正常
    tail -n 100 ~./bash_history | more
    查看临时目录是否存在攻击者入侵时留下的残余文件
    ls -la /tmp
    ls -la /var/tmp
    #如果存在.c .py .sh为后缀的文件或者2进制elf文件。

    发现像目前最流行的bash shell 漏洞,测试一下,果然存在漏洞。

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

    修复升级命令

    yum -y install yum-downloadonly

    yum -y install bash-4.1.2-33.el6_7.1.x86_64.rpm 

    [root@mall tmp]# yum -y install bash-4.1.2-33.el6_7.1.x86_64.rpm 

    已加载插件:fastestmirror, security

    设置安装进程

    诊断 bash-4.1.2-33.el6_7.1.x86_64.rpm: bash-4.1.2-33.el6_7.1.x86_64

    bash-4.1.2-33.el6_7.1.x86_64.rpm 将作为 bash-4.1.2-15.el6_4.x86_64 的更新

    Loading mirror speeds from cached hostfile

     * base: ftp.sjtu.edu.cn

     * extras: mirrors.skyshe.cn

     * updates: ftp.sjtu.edu.cn

    解决依赖关系

    --> 执行事务检查

    ---> Package bash.x86_64 0:4.1.2-15.el6_4 will be 升级

    ---> Package bash.x86_64 0:4.1.2-33.el6_7.1 will be an update

    --> 完成依赖关系计算

    依赖关系解决

    ================================

    总文件大小:3.0 M

    下载软件包:

    运行 rpm_check_debug 

    执行事务测试

    事务测试成功

    执行事务

      正在升级   : bash-4.1.2-33.el6_7.1.x86_64

      清理      : bash-4.1.2-15.el6_4.x86_64

      Verifying  : bash-4.1.2-33.el6_7.1.x86_64

      Verifying  : bash-4.1.2-15.el6_4.x86_64

    更新完毕:

      bash.x86_64 0:4.1.2-33.el6_7.1

    完毕!

    重新测试

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

    this is a test

    完成后做了如下措施

    1. 修改了系统账号密码;

    2. 修改了sshd端口为2220;

    3. 修改nginx用户nologin;

    4. 发现系统服务器存在bash严重漏洞 破壳漏洞(Shellshock)并修复;

    5. 更新完成后后面没有发现被入侵或者服务器自动宕机现象。

    漏洞被利用过程

    我发送GET请求–>目标服务器cgi路径

    目标服务器解析这个get请求,碰到UserAgent后面的参数,Bash解释器就执行了后面的命令。

    Shellshock介绍

    Shellshock,又称Bashdoor,是在Unix中广泛使用的Bash shell中的一个安全漏洞,首次于2014年9月24日公开。许多互联网守护进程,如网页服务器,使用bash来处理某些命令,从而允许攻击者在易受攻击的Bash版本上执行任意代码。这可使攻击者在未授权的情况下访问计算机系统。

  • 相关阅读:
    pgspider sqlite mysql docker 镜像
    pgspider docker 镜像
    pgspider基于pg 的高性能数据可视化sql 集群引擎
    diesel rust orm 框架试用
    golang 条件编译
    Performance Profiling Zeebe
    bazel 学习一 简单java 项目运行
    一个好用node http keeplive agnet
    gox 简单灵活的golang 跨平台编译工具
    mailhog 作为smtp server mock工具
  • 原文地址:https://www.cnblogs.com/IPYQ/p/5574765.html
Copyright © 2011-2022 走看看