我正在嘗試編寫一個(gè)故意易受命令注入攻擊的頁面。這是針對培訓(xùn)環(huán)境的。這是我到目前為止的代碼: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(); }看到正常的域查詢請求時(shí),它似乎運(yùn)行良好。但是,當(dāng)它看到這樣的請求時(shí):http://localhost:50159/Home/CommandInjection?domain=www.google.com+%26+dir 它返回一個(gè)空白。我期望的是它將返回域查找的結(jié)果,然后返回dir命令的輸出。C#
2 回答

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