File tree Expand file tree Collapse file tree 8 files changed +179
-50
lines changed Expand file tree Collapse file tree 8 files changed +179
-50
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 @@ -415,16 +415,6 @@ def initialize(info = {})
415
415
#
416
416
##
417
417
418
- #
419
- # Checks to see if the target is vulnerable, returning unsupported if it's
420
- # not supported.
421
- #
422
- # This method is designed to be overriden by exploit modules.
423
- #
424
- def check
425
- CheckCode ::Unsupported
426
- end
427
-
428
418
#
429
419
# Kicks off the actual exploit. Prior to this call, the framework will
430
420
# have validated the data store using the options associated with this
Original file line number Diff line number Diff line change @@ -355,6 +355,16 @@ def disclosure_date
355
355
date_str = Date . parse ( module_info [ 'DisclosureDate' ] . to_s ) rescue nil
356
356
end
357
357
358
+ #
359
+ # Checks to see if the target is vulnerable, returning unsupported if it's
360
+ # not supported.
361
+ #
362
+ # This method is designed to be overriden by exploit modules.
363
+ #
364
+ def check
365
+ Msf ::Exploit ::CheckCode ::Unsupported
366
+ end
367
+
358
368
#
359
369
# Returns the hash that describes this module's compatibilities.
360
370
#
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ class Exploit
29
29
#
30
30
def commands
31
31
super . update ( {
32
- "check" => "Check to see if a target is vulnerable" ,
33
32
"exploit" => "Launch an exploit attempt" ,
34
33
"rcheck" => "Reloads the module and checks if the target is vulnerable" ,
35
34
"rexploit" => "Reloads the module and launches an exploit attempt" ,
@@ -46,44 +45,6 @@ def name
46
45
"Exploit"
47
46
end
48
47
49
- #
50
- # Checks to see if a target is vulnerable.
51
- #
52
- def cmd_check ( *args )
53
- defanged?
54
-
55
- begin
56
-
57
- code = mod . check_simple (
58
- 'LocalInput' => driver . input ,
59
- 'LocalOutput' => driver . output )
60
-
61
- if ( code and code . kind_of? ( Array ) and code . length > 1 )
62
-
63
- if ( code == Msf ::Exploit ::CheckCode ::Vulnerable )
64
- print_good ( code [ 1 ] )
65
- else
66
- print_status ( code [ 1 ] )
67
- end
68
-
69
- else
70
- print_error ( "Check failed: The state could not be determined." )
71
- end
72
-
73
- rescue ::Interrupt
74
- raise $!
75
- rescue ::Exception => e
76
- print_error ( "Exploit check failed: #{ e . class } #{ e } " )
77
- if ( e . class . to_s != 'Msf::OptionValidateError' )
78
- print_error ( "Call stack:" )
79
- e . backtrace . each do |line |
80
- break if line =~ /lib.msf.base.simple/
81
- print_error ( " #{ line } " )
82
- end
83
- end
84
- end
85
- end
86
-
87
48
#
88
49
# Launches an exploitation attempt.
89
50
#
Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ module ModuleCommandDispatcher
17
17
def commands
18
18
{
19
19
"pry" => "Open a Pry session on the current module" ,
20
- "reload" => "Reload the current module from disk"
20
+ "reload" => "Reload the current module from disk" ,
21
+ "check" => "Check to see if a target is vulnerable"
21
22
}
22
23
end
23
24
@@ -35,6 +36,38 @@ def mod=(m)
35
36
self . driver . active_module = m
36
37
end
37
38
39
+ #
40
+ # Checks to see if a target is vulnerable.
41
+ #
42
+ def cmd_check ( *args )
43
+ defanged?
44
+ begin
45
+ code = mod . check_simple (
46
+ 'LocalInput' => driver . input ,
47
+ 'LocalOutput' => driver . output )
48
+ if ( code and code . kind_of? ( Array ) and code . length > 1 )
49
+ if ( code == Msf ::Exploit ::CheckCode ::Vulnerable )
50
+ print_good ( code [ 1 ] )
51
+ else
52
+ print_status ( code [ 1 ] )
53
+ end
54
+ else
55
+ print_error ( "Check failed: The state could not be determined." )
56
+ end
57
+ rescue ::Interrupt
58
+ raise $!
59
+ rescue ::Exception => e
60
+ print_error ( "Exploit check failed: #{ e . class } #{ e } " )
61
+ if ( e . class . to_s != 'Msf::OptionValidateError' )
62
+ print_error ( "Call stack:" )
63
+ e . backtrace . each do |line |
64
+ break if line =~ /lib.msf.base.simple/
65
+ print_error ( " #{ line } " )
66
+ end
67
+ end
68
+ end
69
+ end
70
+
38
71
def cmd_pry_help
39
72
print_line "Usage: pry"
40
73
print_line
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
+ ##
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 ::Exploit
11
+
12
+ def initialize ( info = { } )
13
+ super ( update_info ( info ,
14
+ 'Name' => "Check Test Exploit" ,
15
+ 'Description' => %q{
16
+ This module ensures that 'check' actually functions for Exploit modules.
17
+ } ,
18
+ 'References' =>
19
+ [
20
+ [ 'OSVDB' , '0' ]
21
+ ] ,
22
+ 'Author' =>
23
+ [
24
+ 'todb'
25
+ ] ,
26
+ 'License' => MSF_LICENSE ,
27
+ 'DisclosureDate' => 'May 23 2013'
28
+ ) )
29
+
30
+ register_options (
31
+ [
32
+ Opt ::RPORT ( 80 )
33
+ ] , self . class )
34
+ end
35
+
36
+ def check
37
+ print_debug "Check is successful"
38
+ return Msf ::Exploit ::CheckCode ::Vulnerable
39
+ end
40
+
41
+ def exploit
42
+ print_debug "Exploit is successful."
43
+ end
44
+
45
+ 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
+
8
+ use exploit/test/check
9
+ set rhost www.metasploit.com
10
+ check
You can’t perform that action at this time.
0 commit comments