CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/tools/modules/module_count.rb
Views: 1904
1
#!/usr/bin/env ruby
2
3
##
4
# This module requires Metasploit: https://metasploit.com/download
5
# Current source: https://github.com/rapid7/metasploit-framework
6
##
7
8
#
9
# Lists the current count of modules, by type, and outputs a bare CSV.
10
#
11
12
msfbase = __FILE__
13
while File.symlink?(msfbase)
14
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
15
end
16
17
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
18
require 'msfenv'
19
20
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
21
22
require 'rex'
23
24
# Always disable the database (we never need it just to list module
25
# information).
26
framework_opts = { 'DisableDatabase' => true }
27
28
# Initialize the simplified framework instance.
29
$framework = Msf::Simple::Framework.create(framework_opts)
30
Indent = ' '
31
32
i = 0
33
module_types = {
34
:exploit => 0,
35
:auxiliary => 0,
36
:post => 0,
37
:payload => 0,
38
:encoder => 0,
39
:nop => 0
40
}
41
42
$framework.modules.each do |name, mod|
43
this_mod = mod.new
44
[:exploit, :auxiliary, :post, :payload, :encoder, :nop].each do |meth|
45
interrogative = "#{meth}?".intern
46
if this_mod.send(interrogative)
47
module_types[meth] += 1
48
end
49
end
50
end
51
52
puts module_types.keys.map {|k| k.to_s}.join(",")
53
puts module_types.values.join(",")
54
55