forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_targets.rb
executable file
·88 lines (72 loc) · 1.69 KB
/
module_targets.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env ruby
#
# $Id$
#
# This script lists all modules with their targets
#
# $Revision$
#
msfbase = __FILE__
while File.symlink?(msfbase)
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
end
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
require 'fastlib'
require 'msfenv'
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
require 'rex'
require 'msf/ui'
require 'msf/base'
sort=0
fil = 0
filter = ""
opts = Rex::Parser::Arguments.new(
"-h" => [ false, "Help menu." ],
"-s" => [ false, "Sort by Target instead of Module Type."],
"-r" => [ false, "Reverse Sort"],
"-x" => [ true, "String or RegEx to try and match against the Targets field"]
)
opts.parse(ARGV) { |opt, idx, val|
case opt
when "-h"
puts "\nMetasploit Script for Displaying Module Target information."
puts "=========================================================="
puts opts.usage
exit
when "-s"
puts "Sorting by Target"
sort = 1
when "-r"
puts "Reverse Sorting"
sort = 2
when "-x"
puts "Filter: #{val}"
filter = val
fil=1
end
}
Indent = ' '
# Initialize the simplified framework instance.
$framework = Msf::Simple::Framework.create('DisableDatabase' => true)
tbl = Rex::Ui::Text::Table.new(
'Header' => 'Module Targets',
'Indent' => Indent.length,
'Columns' => [ 'Module name','Target' ]
)
all_modules = $framework.exploits
all_modules.each_module { |name, mod|
x = mod.new
x.targets.each do |targ|
if fil==0 or targ.name=~/#{filter}/
tbl << [ x.fullname, targ.name ]
end
end
}
if sort == 1
tbl.sort_rows(1)
end
if sort == 2
tbl.sort_rows(1)
tbl.rows.reverse
end
puts tbl.to_s