邪恶的strip_tags()函数

简介:  爆人品的一次.下了个loudblog最新版看看,好像是0.8inc/buildwebsite.
 爆人品的一次.
下了个loudblog最新版看看,好像是0.8
inc/buildwebsite.php里:
//template required by URL? Override template-setting
if (isset($_GET['template'])) {
    $requested_template = killevilcharacters(strip_tags($_GET['template']));
    $settings['template'] = $requested_template;

}

//building the right path to required template
$templpath = $GLOBALS['templatepath'] .
             $settings['template'];//. "/index.html";
//
//copies template into variable
$connect = @fopen ($templpath, "rb") OR die("Unfortunately I could not find a valid template! $templpath");
$template = fread ($connect, 262144);
fclose($connect);
$_GET['template']最终会带到fopen里,但前面经过了strip_tags函数和killevilcharacters函数的检查,strip_tags是过滤HTML和PHP标签的,那就看下killevilcharacters函数过滤了什么东西
同目录下的function.php:
#################################################
#################################################

function killevilcharacters($text) {
    $trans       = array();
    $trans[" "] = '';
    $trans[".."] = '';
    $trans["/"] = '';
    $trans["'"] = '';
    $trans['"'] = '';
    $trans['"'] = '';
    $trans['<'] = '';
    $trans['>'] = '';

    return strtr($text, $trans);
}

#################################################
#################################################
看来作者意识到之前这个变量出过LFI的漏洞,所以对目录的操作限制了一下,可惜没有过滤. 和/
可以很轻松的构造出跳转的URL如下:
index.php?template=/././%5c/././%5c/././%5c/././%5c/././%5cINSTALL.txt%00
用/././就把..带进去了
理论上这个漏洞是成功利用了,确实函数写的过滤不严格,可以绕过得,可问题就是根本读不出文件,%00并没有截断后面的/index.html,找了很多可能出现过滤得地方都没有发现原因,还有哪里会出问题呢...
最后只能回到strip_tags函数上,根本没抱希望的测试了下
$b = strip_tags($_GET['a']);
include "$b.php";
居然%00被过滤掉了... 手册里没提到这函数还有这个特性啊...
还有多少这种小地方是我们不知道的呢-_-
目录
相关文章
|
10月前
|
PHP
php正则表达式函数preg_replace替换span标签
php正则表达式函数preg_replace替换span标签
43 0
|
10月前
|
Python
Python:字符串基操_strip()/rstrip()/lstrip()_lower()/upper()_startswith()/endswith()_split()/rspilt()_join
Python:字符串基操_strip()/rstrip()/lstrip()_lower()/upper()_startswith()/endswith()_split()/rspilt()_join
81 0
|
前端开发 PHP
TP5 使用strip_tags过滤html标签不起作用的解决方法
TP5 使用strip_tags过滤html标签不起作用的解决方法
218 0
|
开发工具
[oeasy]python0054_三引号_原样显示字符串_triple_quoted
[oeasy]python0054_三引号_原样显示字符串_triple_quoted
109 0
[oeasy]python0054_三引号_原样显示字符串_triple_quoted
字符串匹配 正则表达式函数之match、test、exec、search、split、replace使用详解
字符串匹配 正则表达式函数之match、test、exec、search、split、replace使用详解
99 0
|
自然语言处理 JavaScript 前端开发
万恶的 eval() ?
万恶的 eval() ?
83 0
使用 English words 包生成文本来替换字符串“Hello World”.
使用 English words 包生成文本来替换字符串“Hello World”.
94 0
|
Web App开发 测试技术 C#
艾伟_转载:Regex.Replace 方法的性能!
园子里有很多关于去除Html标签的文章。一个常用的经验是使用 Regex.Replace 方法利用正则去替换。这里有一篇使用该方法的文章 C#中如何去除HTML标记 。下面我贴出该方法的代码,见代码清单1-1 代码清单1-1 引用 http://www.
841 0

热门文章

最新文章