File tree Expand file tree Collapse file tree 5 files changed +137
-0
lines changed
ui/console/command_dispatcher Expand file tree Collapse file tree 5 files changed +137
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,39 @@ def run_simple(opts = {}, &block)
92
92
Msf ::Simple ::Auxiliary . run_simple ( self , opts , &block )
93
93
end
94
94
95
+ #
96
+ # Initiates a check, setting up the exploit to be used. The following
97
+ # options can be specified:
98
+ #
99
+ # LocalInput
100
+ #
101
+ # The local input handle that data can be read in from.
102
+ #
103
+ # LocalOutput
104
+ #
105
+ # The local output through which data can be displayed.
106
+ #
107
+ def self . check_simple ( mod , opts )
108
+ if opts [ 'LocalInput' ]
109
+ mod . init_ui ( opts [ 'LocalInput' ] , opts [ 'LocalOutput' ] )
110
+ end
111
+
112
+ # Validate the option container state so that options will
113
+ # be normalized
114
+ mod . validate
115
+
116
+ # Run check
117
+ mod . check
118
+ end
119
+
120
+ #
121
+ # Calls the class method.
122
+ #
123
+ def check_simple ( opts )
124
+ Msf ::Simple ::Auxiliary . check_simple ( self , opts )
125
+ end
126
+
127
+
95
128
protected
96
129
97
130
#
Original file line number Diff line number Diff line change @@ -44,6 +44,16 @@ def initialize(info = {})
44
44
self . queue = Array . new
45
45
end
46
46
47
+ #
48
+ # Checks to see if the target is vulnerable, returning unsupported if it's
49
+ # not supported.
50
+ #
51
+ # This method is designed to be overriden by exploit modules.
52
+ #
53
+ def check
54
+ Msf ::Exploit ::CheckCode ::Unsupported
55
+ end
56
+
47
57
#
48
58
# Creates a singleton instance of this auxiliary class
49
59
#
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class Auxiliary
27
27
#
28
28
def commands
29
29
super . update ( {
30
+ "check" => "Check to see if a target is vulnerable" ,
30
31
"run" => "Launches the auxiliary module" ,
31
32
"rerun" => "Reloads and launches the auxiliary module" ,
32
33
"exploit" => "This is an alias for the run command" ,
@@ -57,6 +58,45 @@ def name
57
58
"Auxiliary"
58
59
end
59
60
61
+ #
62
+ # Checks to see if a target is vulnerable.
63
+ #
64
+ def cmd_check ( *args )
65
+ defanged?
66
+
67
+ begin
68
+
69
+ code = mod . check_simple (
70
+ 'LocalInput' => driver . input ,
71
+ 'LocalOutput' => driver . output )
72
+
73
+ if ( code and code . kind_of? ( Array ) and code . length > 1 )
74
+
75
+ if ( code == Msf ::Exploit ::CheckCode ::Vulnerable )
76
+ print_good ( code [ 1 ] )
77
+ else
78
+ print_status ( code [ 1 ] )
79
+ end
80
+
81
+ else
82
+ print_error ( "Check failed: The state could not be determined." )
83
+ end
84
+
85
+ rescue ::Interrupt
86
+ raise $!
87
+ rescue ::Exception => e
88
+ print_error ( "Module check failed: #{ e . class } #{ e } " )
89
+ if ( e . class . to_s != 'Msf::OptionValidateError' )
90
+ print_error ( "Call stack:" )
91
+ e . backtrace . each do |line |
92
+ break if line =~ /lib.msf.base.simple/
93
+ print_error ( " #{ line } " )
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+
60
100
#
61
101
# Reloads an auxiliary module and executes it
62
102
#
Original file line number Diff line number Diff line change
1
+ ##
2
+ # This file is part of the Metasploit Framework and may be subject to
3
+ # redistribution and commercial restrictions. Please see the Metasploit
4
+ # Framework web site for more information on licensing and terms of use.
5
+ # http://metasploit.com/framework/
6
+ ##
7
+
8
+ require 'msf/core'
9
+
10
+ class Metasploit3 < Msf ::Auxiliary
11
+
12
+ include Msf ::Auxiliary ::Report
13
+ include Msf ::Exploit ::Remote ::HttpClient
14
+
15
+ def initialize ( info = { } )
16
+ super ( update_info ( info ,
17
+ 'Name' => "Check Test" ,
18
+ 'Description' => %q{
19
+ This module ensures that 'check' actually functions for Auxiilary modules.
20
+ } ,
21
+ 'References' =>
22
+ [
23
+ [ 'OSVDB' , '0' ]
24
+ ] ,
25
+ 'Author' =>
26
+ [
27
+ 'todb'
28
+ ] ,
29
+ 'License' => MSF_LICENSE
30
+ ) )
31
+
32
+ register_options (
33
+ [
34
+ Opt ::RPORT ( 80 )
35
+ ] , self . class )
36
+ end
37
+
38
+ def check
39
+ print_debug "Check is successful"
40
+ return Msf ::Exploit ::CheckCode ::Vulnerable
41
+ end
42
+
43
+ def run
44
+ print_debug "Run is successful."
45
+ end
46
+
47
+ end
Original file line number Diff line number Diff line change
1
+ # Usage:
2
+ # msfconsole -qLm test/modules -r test/scripts/test-check.rc
3
+
4
+ use auxiliary/test/check
5
+ set rhost www.metasploit.com
6
+ check
7
+ exit
You can’t perform that action at this time.
0 commit comments