Path: blob/master/modules/post/windows/gather/enum_applications.rb
19567 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::Windows::Registry78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Windows Gather Installed Application Enumeration',13'Description' => %q{ This module will enumerate all installed applications on a Windows system },14'License' => MSF_LICENSE,15'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],16'Platform' => [ 'win' ],17'SessionTypes' => [ 'meterpreter' ],18'Notes' => {19'Stability' => [CRASH_SAFE],20'SideEffects' => [],21'Reliability' => []22}23)24)25end2627def app_list28tbl = Rex::Text::Table.new(29'Header' => 'Installed Applications',30'Indent' => 1,31'Columns' =>32[33'Name',34'Version'35]36)37appkeys = [38'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',39'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',40'HKLM\\SOFTWARE\\WOW6432NODE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',41'HKCU\\SOFTWARE\\WOW6432NODE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',42]43apps = []44appkeys.each do |keyx86|45found_keys = registry_enumkeys(keyx86)46next unless found_keys4748found_keys.each do |ak|49apps << keyx86 + '\\' + ak50end51end5253t = []54until apps.empty?55561.upto(16) do57t << framework.threads.spawn("Module(#{refname})", false, apps.shift) do |k|58dispnm = registry_getvaldata(k.to_s, 'DisplayName')59dispversion = registry_getvaldata(k.to_s, 'DisplayVersion')60tbl << [dispnm, dispversion] if dispnm && dispversion61rescue StandardError => e62vprint_error(e.message)63end64end65t.map(&:join)66end6768results = tbl.to_s6970print_line("\n" + results + "\n")7172p = store_loot('host.applications', 'text/plain', session, results, 'applications.txt', 'Installed Applications')73print_good("Results stored in: #{p}")74end7576def run77print_status("Enumerating applications installed on #{sysinfo['Computer']}")78app_list79end80end818283