-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathCommandInjection.cs
More file actions
38 lines (32 loc) · 1 KB
/
CommandInjection.cs
File metadata and controls
38 lines (32 loc) · 1 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
using System;
namespace System.Web.UI.WebControls
{
public class TextBox
{
public string Text { get; set; }
public string InnerHtml { get; set; }
}
}
namespace Test
{
using System.Web.UI.WebControls;
using System.Web;
using System.Diagnostics;
class CommandInjection
{
TextBox categoryTextBox;
public void WebCommandInjection()
{
// BAD: Reading from textbox, then using that in the arguments and file name
string userInput = categoryTextBox.Text;
Process.Start("foo.exe" + userInput, "/c " + userInput);
ProcessStartInfo startInfo = new ProcessStartInfo(userInput, userInput);
Process.Start(startInfo);
ProcessStartInfo startInfoProps = new ProcessStartInfo();
startInfoProps.FileName = userInput;
startInfoProps.Arguments = userInput;
startInfoProps.WorkingDirectory = userInput;
Process.Start(startInfoProps);
}
}
}