Files
metasploit-gs/modules/post/windows/gather/enum_applications.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
2.1 KiB
Ruby
Raw Normal View History

2011-01-12 18:11:24 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2011-01-12 18:11:24 +00:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
include Msf::Post::Windows::Registry
2023-02-08 13:47:34 +00:00
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Windows Gather Installed Application Enumeration',
'Description' => %q{ This module will enumerate all installed applications on a Windows system },
'License' => MSF_LICENSE,
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
'Platform' => [ 'win' ],
'SessionTypes' => [ 'meterpreter' ]
)
)
end
def app_list
2016-08-10 13:30:09 -05:00
tbl = Rex::Text::Table.new(
2023-02-08 13:47:34 +00:00
'Header' => 'Installed Applications',
'Indent' => 1,
'Columns' =>
2011-01-12 17:36:58 +00:00
[
2023-02-08 13:47:34 +00:00
'Name',
'Version'
]
)
appkeys = [
'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
'HKLM\\SOFTWARE\\WOW6432NODE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
'HKCU\\SOFTWARE\\WOW6432NODE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
2023-02-08 13:47:34 +00:00
]
2011-01-12 23:24:17 +00:00
apps = []
appkeys.each do |keyx86|
2011-07-12 21:05:44 +00:00
found_keys = registry_enumkeys(keyx86)
2023-02-08 13:47:34 +00:00
next unless found_keys
found_keys.each do |ak|
apps << keyx86 + '\\' + ak
end
2011-01-12 23:24:17 +00:00
end
2011-01-12 23:24:17 +00:00
t = []
2023-02-08 13:47:34 +00:00
until apps.empty?
2011-01-12 23:24:17 +00:00
1.upto(16) do
2023-02-08 13:47:34 +00:00
t << framework.threads.spawn("Module(#{refname})", false, apps.shift) do |k|
dispnm = registry_getvaldata(k.to_s, 'DisplayName')
dispversion = registry_getvaldata(k.to_s, 'DisplayVersion')
tbl << [dispnm, dispversion] if dispnm && dispversion
rescue StandardError
2011-01-12 23:24:17 +00:00
end
end
2023-02-08 13:47:34 +00:00
t.map(&:join)
end
2011-07-19 21:52:38 +00:00
results = tbl.to_s
2011-07-19 21:52:38 +00:00
print_line("\n" + results + "\n")
2023-02-08 13:47:34 +00:00
p = store_loot('host.applications', 'text/plain', session, results, 'applications.txt', 'Installed Applications')
2017-07-19 13:02:49 +01:00
print_good("Results stored in: #{p}")
end
def run
print_status("Enumerating applications installed on #{sysinfo['Computer']}")
app_list
end
2011-01-12 18:11:24 +00:00
end