-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathSqlInjectionSqlite.cs
More file actions
42 lines (35 loc) · 1.22 KB
/
SqlInjectionSqlite.cs
File metadata and controls
42 lines (35 loc) · 1.22 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
using System;
namespace TestSqlite
{
using System.Data;
using System.Data.SQLite;
using System.Web.UI.WebControls;
class SqlInjection
{
private string connectionString;
public TextBox untrustedData;
public void InjectUntrustedData()
{
// BAD: untrusted data is not sanitized.
SQLiteCommand cmd = new SQLiteCommand(untrustedData.Text);
// BAD: untrusted data is not sanitized.
using (var connection = new SQLiteConnection(connectionString))
{
cmd = new SQLiteCommand(untrustedData.Text, connection);
}
SQLiteDataAdapter adapter;
DataSet result;
// BAD: untrusted data is not sanitized.
using (var connection = new SQLiteConnection(connectionString))
{
adapter = new SQLiteDataAdapter(untrustedData.Text, connection);
result = new DataSet();
adapter.Fill(result);
}
// BAD: untrusted data is not sanitized.
adapter = new SQLiteDataAdapter(untrustedData.Text, connectionString);
result = new DataSet();
adapter.Fill(result);
}
}
}