当前位置:网站首页>Zhangxiaobai's road to penetration (7) -sql injection detailed operation steps -union joint query injection
Zhangxiaobai's road to penetration (7) -sql injection detailed operation steps -union joint query injection
2022-06-25 12:33:00 【Litbai_ zhang】
UNION Joint query injection
union brief introduction
union Operators are used to merge two or more select The result set of the statement .
ps: union Inside select Statements must have the same number of columns . Columns must also have similar data types . meanwhile , Every one of them select The order of the columns in the statement must be the same .
By default ,union The operator selects different values . If duplicate values are allowed , Please use union all
union Injection conditions
- Only the last one select Clause allows order by
- Only the last one select Clause allows limit
- as long as union The number of fields of several connected queries is the same, and there is no problem in the data type conversion of columns , You can query the results
- The injection point page has echo
union Injection process 
Here we use sqli-labs To demonstrate union The operation process of joint query vulnerability .
1.order by Determine the number of columns
order by Function is used to sort data in a column
for example order by 1 Sort the data in the first column of the database table from small to large
url Add input to
' order by 3--+
' Used to isolate strings ,- -+ Subsequent statements used to comment this line 
2.
Try again and again after step , We finally found that the table had three columns , Then let's watch the page return , Select the location where the data can be displayed , Proceed to the next injection
url Modify and add input
id=100' union select 1,2,3--+

because union By default, the query only displays the field values of the first column , So we put union The previous query statement was intentionally set to 100 Make the query error and display the value of the second segment , So we can find the location where the data is displayed .
3. Read library information
We read the database information by replacing the position of the above value
take url Of the statement 3 Replace with database()
To read the current library information
You can also query all the library names with a query statement at this location
replace content
(select schema_name from information_schema.schemata limit 0,1)
limit The function is to limit the output , Because the page can only display one row of data , So we show the data in the first row , If you want to display the data of the second row , take 0 This is 1 that will do , Modify the data in turn to get all database names . Yes SQL If you are not familiar with the sentence, you can copy it and use it directly
, This is not affected at the beginning of learning .
4. Reading table information
Again , Replace with query all table information of the library in this location
select table_name from information_schema.tables where table_schema=database() limit 0,1
The other operations are the same as those in step , To find out all table names 
5. Read column information
Same position replacement
Select column_name from information_schema.columns where table_name='users' limit 1,1
Select column_name from information_schema.columns where table_name='users' limit 2,1
After replacement, we get two key field names username,password
6. Query data
ditto , Replace data
Select group_concat(username,':',password) from users
group_concat Functions here are explained in detail , If you are interested, please have a look at concat Explanation of series functions 
边栏推荐
- Does sklearex make your sklearn machine learning model training fly fast?
- Pycaret successfully resolved the problem that 'sklearn model_ selection._ Search 'import name "\u check\u param\u grid"
- K8s, docker compose install MySQL 8.0.18
- Record a debugging when curl has no return value
- Learning notes 2022 overview | automatic graph machine learning, describing AGML methods, libraries and directions
- Dark horse shopping mall ---6 Brand, specification statistics, condition filtering, paging sorting, highlighting
- Mind mapping video
- confluence7.4. X upgrade record
- 2022 meisai topic C idea sharing + translation
- Tp6 exception handling try catch writing method
猜你喜欢

What is Flink? What can Flink do?

Dark horse shopping mall ---6 Brand, specification statistics, condition filtering, paging sorting, highlighting

ECSHOP video list_ ECSHOP uploading video, video classification, video list playing video function

一款好用的印章设计工具 --(可转为ofd文件)

Explanation of ideas and sharing of pre-processing procedures for 2021 US game D (with pre-processing data code)

Rank sum ratio comprehensive evaluation method for common models in mathematical modeling

Explain AHP in human language (very detailed principle + simple tool implementation)

揭秘GaussDB(for Redis):全面對比Codis

Time series analysis - how to use unit root test (ADF) correctly?

Flutter common commands and problems
随机推荐
What is principal component analysis? Dimension reduction of classical case analysis variables
一套自动化无纸办公系统(OA+审批流)源码:带数据字典
Huile optimization system -- sharing of secondary development source code of huile optimization app system
devsecops与devops的理解与建设
VIM common commands and shortcut keys
[on]learning dynamic and hierarchical traffic spatiotemporal features with transformer
Wait for the end of the network request in the uniapp Onshow method before executing the subsequent code content
Record a debugging when curl has no return value
Does sklearex make your sklearn machine learning model training fly fast?
Install MySQL client
A set of automated paperless office system (oa+ approval process) source code: with data dictionary
实现领域驱动设计 - 使用ABP框架 - 系列文章汇总
Zhengzheng e-commerce source code -- Zhengzheng advertising e-commerce system development source code sharing
Service charge and time setting code sharing involved in crmeb withdrawal process
Development with courtesy -- share the source code of the secondary development of the app system of the imitation shopping mall
confluence7.4. X upgrade record
R语言dplyr包filter函数过滤dataframe数据中指定数据列的内容不是(不等于指定向量中的其中一个)指定列表中的数据行
Qiantang Pingou source code -- Qiantang Pingou app system development source code sharing
2022 meisai D topic ideas sharing + translation
When MySQL queries fields in JSON format, it takes a property value of JSON data