-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotnet
50 lines (46 loc) · 1.37 KB
/
dotnet
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
using System;
using System.Data.SqlClient;
class Program
{
static void Main()
{
string userInput = "someUserInput"; // Simulate user input
string query = "SELECT * FROM Users WHERE Username = '" + userInput + "'"; // SQL Injection vulnerability
using (SqlConnection conn = new SqlConnection("your_connection_string"))
{
SqlCommand cmd = new SqlCommand(query, conn);
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader["Username"].ToString());
}
}
}
}
class Program
{
static void Main()
{
string userInput = "someUserInput"; // Simulate user input
string response = "<html><body>Hello, " + userInput + "</body></html>"; // XSS vulnerability
HttpContext.Current.Response.Write(response);
}
}
class User
{
public string Name { get; set; }
}
class Program
{
static void Main()
{
byte[] data = File.ReadAllBytes("user_data.dat"); // Deserialize user data from file
BinaryFormatter formatter = new BinaryFormatter();
using (MemoryStream stream = new MemoryStream(data))
{
User user = (User)formatter.Deserialize(stream); // Insecure deserialization vulnerability
Console.WriteLine(user.Name);
}
}
}