在sql中防止sql注入_在SQL中使用注入

在sql中防止sql注入

In the previous article, we have learned to retrieve (and update) database data, using AND/OR Operator in SQL. In this article, we are going to discuss what is injection, how we can use injection in SQL? So, in this article, we will learn the use of injection in SQL queries.

在上一篇文章中,我们学习了使用SQL中的AND / OR运算符检索(和更新)数据库数据。 在本文中,我们将讨论什么是注入如何在SQL中使用注入 ? 因此,在本文中,我们将学习在SQL查询中使用注入

Basically, SQL injection is a method where mischievous users can inject SQL commands into an SQL statement, via web page input. Injected SQL commands can alter the SQL statement and finding the middle ground the security of a web application.

基本上,SQL注入是一种调皮的用户可以通过网页输入将SQL命令注入到SQL语句中的方法。 注入SQL命令可以更改SQL语句,并找到Web应用程序安全性的中间点。

Injection is used to create an SQL statement to select a user by using their own user id.

注入用于创建SQL语句,以通过使用其自己的用户ID选择用户。

In place of entering "wrong" input, the user can enter some "smart" input

代替输入“错误”输入,用户可以输入一些“智能”输入

Example: User_ID = 15028 (OR) 1=1

示例: User_ID = 15028(OR)1 = 1

Let's Take an Example to understand this concept:

让我们以一个例子来理解这个概念:

  1. Select * from student where student-id = 15028 or 1=1

    从学生编号= 15028或1 = 1的学生中选择*

  2. Select student_name, course, branch from student where student_id=15032 or 1=1

    从student_id = 15032或1 = 1的学生中选择student_name,课程,分支

Explanations of this two injection queries based on 1=1:

这两个基于1 = 1的注入查询的说明:

In the first SQL statement, all rows from the student table are shown whether student-id is 15028 and where 1=1 always remains true. Similarly, in second SQL statement student_name, course, branch is returned where 1=1 is always true.

在第一个SQL语句中,显示出学生表中的所有行,无论学生ID是15028,还是始终为1 = 1。 同样,在第二条SQL语句student_name中,当然会返回branch,其中1 = 1始终为true。

Select * from student where Name ="" or ""="" AND Pass ="" or ""=""

从学生中选择*,其中姓名=“”或“” =“”并通过=“”或“” =“”

Explanation of this injection query based on "" ="":

基于“” =“”的注入查询的说明:

By this SQL statement student or any usernames and passwords in a database can access by anyone by simply inserting " or ""=" into the student or any username or password; where”” =”” is always true.

通过此SQL语句,任何人都可以通过简单地在学生或任何用户名或密码中插入“或” =,任何人都可以访问该数据库中的学生或用户名和密码; 其中“” =“”始终为真。

SELECT * FROM Department; DROP TABLE Student

SELECT * FROM Department; 滴桌学生

Explanation of this injection query based on batch:

基于批处理的此注入查询的说明:

This SQL statement does complete two task first retrieve all the rows data on the screen in the department table and then drop or delete the student table.

该SQL语句确实完成了两项任务,首先在部门表中检索屏幕上所有行数据,然后删除或删除学生表。

Conclusion:

结论:

In this article, we have learned the different concept of injection. We have learned injection based on 1=1, "" = "", batched injection. Mostly hacker uses this concept for access all the rows, username and password from the database. I hope you understand the concept; in the next article, We will learn more new things in SQL. Have a nice day! Happy Learning!

在本文中,我们了解了注入的不同概念。 我们已经学习了基于1 = 1的批量注射的注射。 通常,黑客使用此概念来访问数据库中的所有行,用户名和密码。 希望您理解这个概念; 在下一篇文章中,我们将学习更多有关SQL的新知识。 祝你今天愉快! 学习愉快!

翻译自: https://www.includehelp.com/sql/use-of-injection-in-sql.aspx

在sql中防止sql注入

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值