本文共 1557 字,大约阅读时间需要 5 分钟。
爆人品的一次. 下了个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被过滤掉了... 手册里没提到这函数还有这个特性啊... 还有多少这种小地方是我们不知道的呢-_-转载地址:http://mummb.baihongyu.com/