-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathGlobal.asax.cs
More file actions
71 lines (61 loc) · 2.15 KB
/
Global.asax.cs
File metadata and controls
71 lines (61 loc) · 2.15 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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
namespace SerializedPayloadGenerator
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
public static bool ValidateInput(string data)
{
if (!String.IsNullOrEmpty(data))
{
if (data.IndexOf('&') > -1 ||
data.IndexOf('|') > -1)
return false;
}
return true;
}
public static string executeCommand(string filename, string commandlineArgument, bool base64 = false)
{
string Output = string.Empty;
System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
//strCommand is path and file name of command to run
pProcess.StartInfo.FileName = filename;
//strCommandParameters are parameters to pass to program
pProcess.StartInfo.Arguments = commandlineArgument;
pProcess.StartInfo.UseShellExecute = false;
//Set output of program to be written to process output stream
pProcess.StartInfo.RedirectStandardOutput = true;
//Start the process
pProcess.Start();
if (base64)
{
using (var ms = new MemoryStream())
{
pProcess.StandardOutput.BaseStream.CopyTo(ms);
Output = System.Convert.ToBase64String(ms.ToArray());
}
}
else
{
Output = pProcess.StandardOutput.ReadToEnd();
}
//Wait for process to finish
pProcess.WaitForExit();
return Output;
}
}
}