当前位置:网站首页>What is SQL injection
What is SQL injection
2022-07-02 08:27:00 【Defeat of Fujiwara Qianhua】
What is? sql Inject ?
Since you will read this article , It shows that you are the same as me when writing this article , It's a safe little white . No matter what reason you want to know “ What is? sql Inject ”, I hope this article will give you some harvest as much as possible .
Two popular concepts
SQL Injection means web The application does not filter or judge the legitimacy of the data entered by the user , The parameter passed in by the front end is that the attacker can control , And the parameters are brought into the query of the database , An attacker can construct a malicious sql Statement to implement Responsibility for database Intentional operation .
Or to say
Through the sql Command insert into Web Submit the form or enter the query string of the domain name or page request , Finally, cheat the server to execute malicious SQL command
If you have some basic knowledge of development , It will be easy to understand SQL The concept of injection , Broadly speaking , When you dynamically request the server , There will be a process of data interaction . Above, PHP link MySQL Source code , Can be any SQL Inject into the shooting range to check . in general ,SQL Injection is a controllable variable , Brought into the database for query .(2021.9.30 Add )
When you browse some web pages , They mostly provide a query function , For example, you open a video website , You can search “xxxx”, To get the video you want . Something like this happened during this period : You press enter , A with the keywords you enter HTTP The request is sent to the server , Business logic layer Web The server parses your request through the script engine , Dynamically construct sql sentence , And ask for DBMS, perform SQL sentence .DBMS return SQL The execution result is given to Web Server,Web Server Encapsulate the page into HTML Format response to browser , Browser parsing HTML, Present the content to you .
To understand the above paragraph , You need a little network 、 Knowledge of database and middleware . Now? , You just need to package the knowledge you don't understand into a black box , This black box provides some required functions .
that ,sql Inject , It happens in dynamic construction SQL sentence , And return the execution result to Web Server This process of . Because the data entered by the user is not filtered , The maliciously constructed parameters are brought into DBMS The query , Realize the malicious operation of the database .
SQL How does injection happen ?
If you understand the above words , You would say , Oh , This is it. SQL Injection . When I think about it , You still find that you don't understand “ What is? SQL Inject ”. Next , You may need a little knowledge of databases , especially MySQL.
MySQL There is a system library information_schema, It stores all the relevant information of the database .
This library can be used for a complete injection . The following is the general process :
Guess the database :
select schema_name frominformation_schemata
select database()
Guess the data table of a library select table_name from information_schema.tables where table_schema=‘xxxx’
Guess all the columns of a table select column_name from information_schema.columns where table_name=‘xxxxx’
Get the contents of a column
select **** from *****
To begin our SQL Inject :
You'd better try it in the database you downloaded .
Suppose there is a student table , You want to check the student whose name is Zhang San , You would write like this :
select * from student where name = ' Zhang San ';
Maybe in the front-end interface , You just entered a “ Zhang San “, There is a variable for the browser to get your input $input in , Pass this variable to the script engine , The script engine does not do any processing , Directly construct a line with your input value dynamically SQL sentence , such as :
$sql = "select * from student where name = 'input'";
$result = mysql_query($sql);
The above code is PHP Language operation on Database , I don't know why I can do this ? You can learn ODBC or JDBC, Now? , It's just a black box . adopt mysql_query() This function ,$sql The statement of variable is passed MySQL Database execution . Everything is so perfect . however , If you type in
Zhang San ' // Just one more single quotation mark
Then the above statement will become
$sql = "select * from student where name = ' Zhang San ''";
It is equivalent to the following query in the database :
select * from student where name = ' Zhang San '';
The single quotation mark you entered , Close the single quotation mark of the previous original statement , There are more single quotation marks behind it , An error at this time .
What's the use of that ? This is so useful . Because you can close the previous clause , Then you can splice all the legal statements constructed by yourself , And add one at the end “ --+” Note the complex content behind , such as
select * from student where name = ' Zhang San ' union select 1,2,x,x --+
Come down here , You may really understand “ What is? SQL Inject ”
边栏推荐
- 链表经典面试题(反转链表,中间节点,倒数第k个节点,合并分割链表,删除重复节点)
- install.img制作方式
- 力扣每日一题刷题总结:字符串篇(持续更新)
- Find and rfind methods in string
- Global and Chinese market of tillage finishing machines 2022-2028: Research Report on technology, participants, trends, market size and share
- C语言实现XML生成解析库(XML扩展)
- File upload and download performance test based on the locust framework
- Data reverse attack under federated learning -- gradinversion
- Simple implementation scheme of transcoding and streaming (I)
- cve_ 2019_ 0708_ bluekeep_ Rce vulnerability recurrence
猜你喜欢

Valin cable: BI application promotes enterprise digital transformation

类和对象(类和类的实例化,this,static关键字,封装)

Use C language to receive JSON strings

File upload and download performance test based on the locust framework

双向链表的实现(双向链表与单向链表的简单区别联系和实现)

Several methods of image enhancement and matlab code

Animation synchronization of CarSim real-time simulation

Using transformer for object detection and semantic segmentation
![[dynamic planning] p4170: coloring (interval DP)](/img/52/76f8baebb19fe10db91c74fec9a697.jpg)
[dynamic planning] p4170: coloring (interval DP)

Carsim-路面3D形状文件参数介绍
随机推荐
St-link connection error invalid ROM table of STM32 difficult and miscellaneous diseases
Using transformer for object detection and semantic segmentation
Method recursion (Fibonacci sequence, frog jumping steps, tower of Hanoi problem)
[untitled]
Vs code configuration problem
OpenCV3 6.3 用滤波器进行缩减像素采样
Use Matplotlib to draw a preliminary chart
樂理基礎(簡述)
Makefile基本原理
【无标题】
Use C language to receive JSON strings
My VIM profile
高中数学必修一
Carsim-路面3D形状文件参数介绍
SQL operation database syntax
OpenCV常用方法出处链接(持续更新)
Smart agriculture solutions smart agriculture system development
Backup, recovery and repair of XFS file system
How to wrap qstring strings
Introduction to parameters of CarSim pavement 3D shape file
