我可以从SELECT语句的SQL注入攻击? [英] Can I get SQL injection attack from SELECT statement?

查看:383
本文介绍了我可以从SELECT语句的SQL注入攻击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

2的问题实际上是:

我知道我必须使用存储过程尽可能的,但我想知道下面请。

I know i must use Stored Procedures as much as Possible, but i would like to know the following please.

?答:我可以从一个SELECT语句,如(从MyTable的选择*)SQL注入攻击

A: Can i get a SQL Injection attack from a SELECT statement such as (Select * from MyTable) ?

乙:
另外,我可以得到一个SQL注入攻击,当我使用SqlDataSource在ASP.NET?

B: Also, can i get a SQL Injection attack when I use the SQLDataSource in ASP.NET?

推荐答案

要回答你的问题。

答:是,你可以向变更后承受参数的任何查询 SQL注入攻击如果您不使用所提供的方法,通过你的平台(甚至调用存储过程并通过SQL调用这样做)。

A: Yes, you can get an SQL Injection attack from any query that takes parameters (even calling stored procedures if you are not using the provided methods by your platform and doing it via SQL calls).

有人问我,甚至可以通过使用存储过程来提供的注入如何做出了表率。我见过开发那些使用存储过程的应用程序,但这种方式:

I was asked to provide an example of how an injection can be made even by using stored procedure. I've seen applications developed that do use stored procedures, but in this way:

// C# - DON'T DO THIS!
String regionName = assignedSomewhereElse();
SQLCommand sqlCmd = DatabaseConnection.CreateCommand();
SQLCommand sqlCmd.CommandText =
    String.Format("EXECUTE sp_InsertNewRegion '{0}'", regionName);

sqlCmd.ExecuteNonQuery();

显然,这是不调用存储过程的方式。你应该用你的平台的抽象或参数化查询。

Obviously, this is not the way to call a stored procedure. You should use your platform's abstractions or parametrized queries.

乙: 的SqlDataSource 是用于数据库的抽象层。它会为你创建的SQL查询,并自动以prevent注射它们进行消毒。

B: SQLDataSource is an abstraction layer for your database. It will create the SQL queries for you and automatically sanitize them in order to prevent injection.

为了避免注射,或者:


  • 净化你的输入

  • 使用您的平台提供的抽象层。

  • 使用参数化查询。

这篇关于我可以从SELECT语句的SQL注入攻击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆