我正在嘗試編寫一個故意易受命令注入攻擊的頁面。這是針對培訓環境的。這是我到目前為止的代碼:public ActionResult CommandInjection() { string domain = Request.QueryString["domain"]; ViewBag.Domain = domain; ProcessStartInfo psi = new ProcessStartInfo("nslookup.exe", domain) { UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true }; var proc = Process.Start(psi); string result = proc.StandardOutput.ReadToEnd(); ViewBag.Msg = "This page is vulnerable to Command Injection"; ViewBag.Result = result; return View(); }看到正常的域查詢請求時,它似乎運行良好。但是,當它看到這樣的請求時:http://localhost:50159/Home/CommandInjection?domain=www.google.com+%26+dir 它返回一個空白。我期望的是它將返回域查找的結果,然后返回dir命令的輸出。C#
2 回答

慕運維8079593
TA貢獻1876條經驗 獲得超5個贊
在這種情況下,用腳拍自己的腳不是那么容易,但是您可以像這樣:
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe", "/c \"nslookup.exe " + domain + "\"")
{
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true
};
- 2 回答
- 0 關注
- 144 瀏覽
添加回答
舉報
0/150
提交
取消