当前位置:网站首页>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 ”
边栏推荐
- [untitled]
- Web安全--核心防御机制
- c语言自定义类型——结构体,位段(匿名结构体,结构体的自引用,结构体的内存对齐)
- c语言将字符串中的空格替换成%20
- 力扣每日一题刷题总结:链表篇(持续更新)
- Matlab - autres
- Carla-ue4editor import Roadrunner map file (nanny level tutorial)
- Matlab other
- Global and Chinese market of electric cheese grinder 2022-2028: Research Report on technology, participants, trends, market size and share
- 顺序表基本功能函数的实现
猜你喜欢
樂理基礎(簡述)
Method recursion (Fibonacci sequence, frog jumping steps, tower of Hanoi problem)
11月24号,我们为“满月”庆祝
Using transformer for object detection and semantic segmentation
TCP/IP—传输层
Animation synchronization of CarSim real-time simulation
HCIA—应用层
使用Matplotlib绘制图表初步
Simple implementation scheme of transcoding and streaming (I)
STM32疑难杂症之ST-LINK Connection error INVALID ROM TABLE
随机推荐
Carsim-問題Failed to start Solver: PATH_ID_OBJ(X) was set to Y; no corresponding value of XXXXX?
Use C language to receive JSON strings
Deep understanding of JVM
Longest isometric subsequence
Carsim 学习心得-粗略翻译1
Learn to write article format
Real world anti sample attack against semantic segmentation
Implementation of bidirectional linked list (simple difference, connection and implementation between bidirectional linked list and unidirectional linked list)
Use of opencv3 6.2 low pass filter
Global and Chinese market of recovery equipment 2022-2028: Research Report on technology, participants, trends, market size and share
SQLyog远程连接centos7系统下的MySQL数据库
Principes fondamentaux de la théorie musicale (brève introduction)
Opencv common method source link (continuous update)
How to build the alliance chain? How much is the development of the alliance chain
Array and string processing, common status codes, differences between PHP and JS (JS)
MySQL optimization
cve_ 2019_ 0708_ bluekeep_ Rce vulnerability recurrence
Global and Chinese markets for conventional rubber track 2022-2028: Research Report on technology, participants, trends, market size and share
Makefile基本原理
Jz-061-serialized binary tree