google_geolocate_bssid.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env ruby
  2. ##
  3. # This module requires Metasploit: https://metasploit.com/download
  4. # Current source: https://github.com/rapid7/metasploit-framework
  5. ##
  6. #
  7. # This tool asks Google for the location of a given set of BSSIDs
  8. #
  9. msfbase = __FILE__
  10. while File.symlink?(msfbase)
  11. msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
  12. end
  13. $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..','lib')))
  14. require 'optparse'
  15. if ARGV.length < 2
  16. $stderr.puts("Usage: #{$PROGRAM_NAME} <api_key> <mac> [mac] ...")
  17. $stderr.puts("Ask Google for the location of the given set of BSSIDs")
  18. $stderr.puts
  19. $stderr.puts("Example: iwlist sc 2>/dev/null|awk '/Address/{print $5}'|xargs #{$PROGRAM_NAME} <api_key>")
  20. $stderr.puts("Example: /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I|awk '/BSSID/{print $2}'|xargs #{$PROGRAM_NAME} <api_key>")
  21. exit(1)
  22. end
  23. g = Rex::Google::Geolocation.new
  24. g.set_api_key(ARGV[0])
  25. ARGV.drop(1).each do |mac|
  26. g.add_wlan(mac, -83)
  27. end
  28. g.fetch!
  29. puts g, g.google_maps_url