Skip to content

Commit 0344c56

Browse files
committed
Merge branch 'smb_fixes' of git://github.com/alexmaloteaux/metasploit-framework into alexmaloteaux-smb_fixes
2 parents 4b56e3c + c0c3dff commit 0344c56

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

lib/rex/proto/smb/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,7 @@ def tree_connect(share = 'IPC$', pass = '', do_recv = true)
10461046

10471047
pkt = CONST::SMB_TREE_CONN_PKT.make_struct
10481048
self.smb_defaults(pkt['Payload']['SMB'])
1049+
pkt['Payload']['SMB'].v['TreeID'] = 0
10491050

10501051
pkt['Payload']['SMB'].v['Command'] = CONST::SMB_COM_TREE_CONNECT_ANDX
10511052
pkt['Payload']['SMB'].v['Flags1'] = 0x18

modules/auxiliary/admin/smb/list_directory.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def run
6868
connect()
6969
smb_login()
7070
print_status("Mounting the remote share \\\\#{datastore['RHOST']}\\#{datastore['SMBSHARE']}'...")
71-
self.simple.connect("#{datastore['SMBSHARE']}")
71+
self.simple.connect("\\\\#{datastore['RHOST']}\\#{datastore['SMBSHARE']}")
7272
if datastore['RPATH']
7373
print_status("Listing \\\\#{datastore['RHOST']}\\#{datastore['SMBSHARE']}\\#{datastore['RPATH']}'...")
7474
end

modules/auxiliary/admin/smb/psexec_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def check_cleanup(smbshare, ip, text)
150150
# Instead of uploading and runing a binary. This method runs a single windows command fed into the COMMAND paramater
151151
def psexec(command)
152152

153-
simple.connect("IPC$")
153+
simple.connect("\\\\#{datastore['RHOST']}\\IPC$")
154154

155155
handle = dcerpc_handle('367abb81-9844-35f1-ad32-98f038001003', '2.0', 'ncacn_np', ["\\svcctl"])
156156
vprint_status("#{peer} - Binding to #{handle} ...")

modules/auxiliary/scanner/smb/smb_enumshares.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def lanman_netshareenum
107107

108108
def srvsvc_netshareenum
109109

110-
simple.connect("IPC$")
110+
simple.connect("\\\\#{rhost}\\IPC$")
111111
handle = dcerpc_handle('4b324fc8-1670-01d3-1278-5a47bf6ee188', '3.0', 'ncacn_np', ["\\srvsvc"])
112112
begin
113113
dcerpc_bind(handle)

modules/exploits/windows/smb/psexec.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ def exploit
172172
folder_list = smbshare.split(/[\\\/]/)
173173
smbshare = folder_list[0]
174174
fileprefix = folder_list[1..-1].map {|a| a + "\\"}.join.gsub(/\\$/,"") if folder_list.length > 1
175-
simple.connect(smbshare)
175+
simple.connect("\\\\#{datastore['RHOST']}\\#{smbshare}")
176176
fd = smb_open("\\#{fileprefix}\\#{filename}", 'rwct')
177177
else
178178
subfolder = false
179-
simple.connect(smbshare)
179+
simple.connect("\\\\#{datastore['RHOST']}\\#{smbshare}")
180180
fd = smb_open("\\#{filename}", 'rwct')
181181
end
182182
exe = ''
@@ -196,10 +196,9 @@ def exploit
196196
end
197197

198198
# Disconnect from the share
199-
simple.disconnect(smbshare)
200-
199+
simple.disconnect("\\\\#{datastore['RHOST']}\\#{smbshare}")
201200
# Connect to the IPC service
202-
simple.connect("IPC$")
201+
simple.connect("\\\\#{datastore['RHOST']}\\IPC$")
203202

204203

205204
# Bind to the service
@@ -350,10 +349,10 @@ def exploit
350349
select(nil, nil, nil, 1.0)
351350
#This is not really useful but will prevent double \\ on the wire :)
352351
if datastore['SHARE'] =~ /.[\\\/]/
353-
simple.connect(smbshare)
352+
simple.connect("\\\\#{datastore['RHOST']}\\#{smbshare}")
354353
simple.delete("\\#{fileprefix}\\#{filename}")
355354
else
356-
simple.connect(smbshare)
355+
simple.connect("\\\\#{datastore['RHOST']}\\#{smbshare}")
357356
simple.delete("\\#{filename}")
358357
end
359358

0 commit comments

Comments
 (0)