SQLi Labs Lesson27 & Lesson27a
来源:互联网 发布:ubuntu系统默认字体 编辑:程序博客网 时间:2024/05/29 13:29
Lesson - 27
GET - Error Based - All your UNION & SELECT Belong to us - String - Single Quotes
首先进入欢迎界面:
构造 ?id=1,结果如图所示:
构造 ?id=1',结果如图所示:
由错误回显信息推测后台SQL语句结构:
select ... from table where id = '$id' limit 0,1
构造 ?id=1' --+,结果不变,推测过滤了注释符。
进一步测试之后发现:
'union','select',空格,注释,都被过滤了。
但是对于‘union','select'的过滤好像不严格
'uNiOn',‘sEleCt'并没有被过滤。
查看后台过滤函数源代码:
function blacklist($id){$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',"", $id); //Strip out union$id= preg_replace('/select/s',"", $id); //Strip out select$id= preg_replace('/UNION/s',"", $id); //Strip out UNION$id= preg_replace('/SELECT/s',"", $id); //Strip out SELECT$id= preg_replace('/Union/s',"", $id); //Strip out Union$id= preg_replace('/Select/s',"", $id); //Strip out selectreturn $id;}
发现对于'select',‘union'并没有用'/i'修饰正则表达式,所以并不是不区分大小写的。
(本节本人MySQL默认字符集为UTF-8)
尝试用'%a0'作为空格,构造:
?id=0'uNiOn%a0sEleCt%a01,2,'3
结果如图所示:
不出意外的,当字符集为UTF-8时并不能用'%a0'代替空格。
那么上节提到的'%0a',‘%0b',’%0c',‘%0d’能不能用呢?
构造 ?id=0'uNiOn%0asEleCt%0a1,2,'3
结果如图所示:
发现'%0a',‘%0b',’%0c',‘%0d’,均可以作为空格使用。
那么问题来了,为什么?
上节中同样的字符集,‘%a0','%0a',‘%0b',’%0c',‘%0d’,均不可以作为空格使用。
问题出现在blacklist函数中:
上节的blacklist源代码:
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;}
在空格过滤处使用的是
$id= preg_replace('/[\s]/',"", $id);
\s 匹配任意的空白符
而本节中的空格过滤:
$id= preg_replace('/[ +]/',"", $id);
下面看Lesson - 27a
GET - Blind Based - All your UNION & SELECT Belong to us - Double Quotes
构造
?id=0"uniunionon%0ASeLEct%0A1,2,"3
结果如图所示:
- SQLi Labs Lesson27 & Lesson27a
- sqli-labs
- sqli-labs
- sqli-labs ---- Less-2
- sqli-labs ---- Less-7
- sqli-labs lesson-2
- sqli labs通关秘籍
- SQLi Labs Lesson1
- SQLi Labs Lesson2
- SQLi Labs Lesson3
- SQLi Labs Lesson4
- SQLi Labs Lesson5
- SQLi Labs Lesson6
- SQLi Labs Lesson7
- SQLi Labs Lesson8
- SQLi Labs Lesson9 Lesson10
- SQLi Labs Lesson11
- SQLi Labs Lesson12
- 前后台性能优化
- Backbone之View的理解
- Tomcat7配置管理报错处理1 java.lang.OutOfMemoryError: Java heap space
- Educational Codeforces Round 16 -- C - Magic Odd Square (找规律)
- ubuntu基本命令
- SQLi Labs Lesson27 & Lesson27a
- su -c 残差平方和 2016.08.22回顾
- CodeForces 660A Co-prime Array
- 定制全局的导航栏样式
- Anroid studio遇到的问题2---Enable ADB integration' to be enabled.
- 安装Genymotion模拟器
- VLC 编程
- 读书笔记之Bitmap高效加载与缓存
- iOS NSPredicate的学习讲解