CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/scripts/meterpreter/get_application_list.rb
Views: 11766
1
##
2
# WARNING: Metasploit no longer maintains or accepts meterpreter scripts.
3
# If you'd like to improve this script, please try to port it as a post
4
# module instead. Thank you.
5
##
6
7
8
# Meterpreter script for listing installed applications and their version.
9
# Provided: carlos_perez[at]darkoperator[dot]com
10
11
#Options and Option Parsing
12
opts = Rex::Parser::Arguments.new(
13
"-h" => [ false, "Help menu." ]
14
)
15
16
def app_list
17
tbl = Rex::Text::Table.new(
18
'Header' => "Installed Applications",
19
'Indent' => 1,
20
'Columns' => [
21
"Name",
22
"Version"
23
])
24
appkeys = ['HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
25
'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall' ]
26
threadnum = 0
27
a = []
28
appkeys.each do |keyx86|
29
soft_keys = registry_enumkeys(keyx86)
30
if soft_keys
31
soft_keys.each do |k|
32
if threadnum < 10
33
a.push(::Thread.new {
34
begin
35
dispnm = registry_getvaldata("#{keyx86}\\#{k}","DisplayName")
36
dispversion = registry_getvaldata("#{keyx86}\\#{k}","DisplayVersion")
37
if dispnm =~ /\S*/
38
tbl << [dispnm,dispversion]
39
end
40
rescue
41
end
42
})
43
threadnum += 1
44
else
45
sleep(0.05) and a.delete_if {|x| not x.alive?} while not a.empty?
46
threadnum = 0
47
end
48
end
49
end
50
51
52
end
53
print_line("\n" + tbl.to_s + "\n")
54
end
55
56
opts.parse(args) { |opt, idx, val|
57
case opt
58
when "-h"
59
print_line "Meterpreter Script for extracting a list installed applications and their version."
60
print_line(opts.usage)
61
raise Rex::Script::Completed
62
63
end
64
}
65
if client.platform == 'windows'
66
app_list
67
else
68
print_error("This version of Meterpreter is not supported with this Script!")
69
raise Rex::Script::Completed
70
end
71
72