Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试使用sql语句存储文本时受到sql注入攻击_C#_Sql - Fatal编程技术网

C# 尝试使用sql语句存储文本时受到sql注入攻击

C# 尝试使用sql语句存储文本时受到sql注入攻击,c#,sql,C#,Sql,我在数据库表中有一个text类型的列。此列可以包含sql语句。 当我尝试将此文本插入sql server时,我收到了来自机器上的反病毒软件instaleld的sql注入攻击 我如何逃逸文本,以防防病毒捕获它 一个示例文本是: "*By supplying a malformed @scriptfile parameter an attacker can run arbitrary commands: use master declare @cmd nvarchar(4000) exec sp_M

我在数据库表中有一个text类型的列。此列可以包含sql语句。 当我尝试将此文本插入sql server时,我收到了来自机器上的反病毒软件instaleld的sql注入攻击

我如何逃逸文本,以防防病毒捕获它

一个示例文本是:

"*By supplying a malformed @scriptfile parameter an attacker can run arbitrary
commands:
use master
declare @cmd nvarchar(4000)
exec sp_MScopyscriptfile N'c:\autoexec.bat" c:\cp.txt&echo hello >
c:\ccc.bbb & echo "hello',@cmd OUTPUT
print @cmd
The above query will copy the autoexec.bat file to cp.txt but also echo hello to a file called ccc.bbb.* "

在将文本存储到数据库之前,我会尝试以某种方式对其进行编码。像Rot13这样简单的东西应该可以做到这一点。

使用参数


所有主要的RDBMS都在C#中提供了它们。

现在插入它的代码是什么?我想他使用的是参数,但SQL server上运行的某些东西阻止了它(尽管我可能在这里的行间读得有点太多)我正在使用sqlbulkcopy插入数据表。该字符串是包含sql语句的合法字符串,但反病毒软件认为我正在进行sql注入攻击。