Skip to content

Commit 4a575d5

Browse files
agixMeatballs1
authored andcommitted
Try to fix Meatballs1 suggestions : optional service_description change call
1 parent b636a67 commit 4a575d5

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

lib/msf/core/exploit/smb/psexec.rb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def psexec(command, disconnect=true, service_description=nil)
7272
end
7373
servicename = Rex::Text.rand_text_alpha(11)
7474
displayname = Rex::Text.rand_text_alpha(16)
75-
servicedescription = service_description || Rex::Text.rand_text_alpha(rand(32)+1)
75+
7676
svc_handle = nil
7777
svc_status = nil
7878
stubdata =
@@ -101,21 +101,20 @@ def psexec(command, disconnect=true, service_description=nil)
101101
return false
102102
end
103103

104-
vprint_status("#{peer} - Changing service description...")
105-
stubdata =
106-
svc_handle +
107-
NDR.long(1) +
108-
NDR.long(1) +
109-
NDR.long(0x0200) +
110-
NDR.long(0x04000200) +
111-
NDR.wstring(servicedescription)
112-
begin
113-
response = dcerpc.call(0x25, stubdata)
114-
if (dcerpc.last_response != nil and dcerpc.last_response.stub_data != nil)
104+
if service_description
105+
vprint_status("#{peer} - Changing service description...")
106+
stubdata =
107+
svc_handle +
108+
NDR.long(1) +
109+
NDR.long(1) +
110+
NDR.long(0x0200) +
111+
NDR.long(0x04000200) +
112+
NDR.wstring(service_description)
113+
begin
114+
response = dcerpc.call(0x25, stubdata)
115+
rescue ::Exception => e
116+
print_error("#{peer} - Error changing service description : #{e}")
115117
end
116-
rescue ::Exception => e
117-
print_error("#{peer} - Error changins service description : #{e}")
118-
return false
119118
end
120119

121120
vprint_status("#{peer} - Starting the service...")

modules/exploits/windows/smb/psexec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def exploit
153153
simple.disconnect("ADMIN$")
154154
else
155155
servicename = rand_text_alpha(8)
156-
servicedescription = datastore['SERVICE_DESCRIPTION'] || rand_text_alpha(rand(32)+1)
156+
servicedescription = datastore['SERVICE_DESCRIPTION']
157157

158158
# Upload the shellcode to a file
159159
print_status("Uploading payload...")

0 commit comments

Comments
 (0)