1: //Process command execution vulnerability
2: Process aProcess = new Process();
3: aProcess.StartInfo.FileName = "someapp.exe";
4: aProcess.StartInfo.Arguments = TextBox1.Text; // source & sink
5: aProcess.Start();
6:
7: //File canonicalization vulnerability
8: File.Create(TextBox2.Text);
9:
10: //Exception information vulnerability
11: protected void Button4_Click(object sender, EventArgs e)
12: {
13: string connectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;";
14: SqlConnection myConnection = null;
15: try
16: {
17: myConnection = new SqlConnection(connectionString);
18: myConnection.Open();
19: }
20: catch (SqlException myEx)
21: {
22: DoSomethingWithException(myEx);
23: }
24: catch
25: {
26: Label2.Text = "This is just test, so fine";
27: }
28: finally
29: {
30: myConnection.Close();
31: }
32: }
33:
34: protected void DoSomethingWithException(SqlException myEx)
35: {
36: string x = "Exception Info: " + myEx.Message; //Exception information vulnerable code
37:
38: }
39:
40: //LDAP injection vulnerability
41: protected void Button7_Click(object sender, EventArgs e)
42: {
43: DirectorySearcher searcher = new DirectorySearcher();
44: string filter = TextBox5.Text;
45: LDAP_InjectionMethod( searcher, filter );
46: }
47:
48: protected void LDAP_InjectionMethod( DirectorySearcher searcher, string filter )
49: {
50: string filterEx = filter + " Random Garbage";
51: searcher.Filter = filterEx;
52: }
53:
54: //Xpath injection vulnerability
55: protected void Button6_Click(object sender, EventArgs e)
56: {
57: XmlDocument doc = new XmlDocument();
58: XmlNode node = doc.CreateElement("Settings");
59: node.SelectSingleNode(TextBox4.Text);
60: }
61:
62: //SQL injection vulnerability
63: string connString = System.Configuration.ConfigurationManager.AppSettings.Get("connString");
64: SqlConnection myConnection = new SqlConnection(connString); //1 SQL Injection vulnerability exists here
65: SqlCommand myNaiveCommand = new SqlCommand("SELECT COUNT(*) FROM Users WHERE UserName='" + txbUsername.Text + "' AND Password='" + txbPassword + "'");
66:
67: //Redirection to user controlled site
68: string x = TextBox3.Text;
69: Response.Redirect(x); //1 Redirect vulnerabilty exists here
70:
71: //XSS vulnerability
72: string userName = txbUsername.Text;