Skip to content

Commit 753fa2c

Browse files
committed
Handles error when TARGETEMAIL is invalid.
1 parent 61ffced commit 753fa2c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

modules/auxiliary/admin/http/rails_devise_pass_reset.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
require 'msf/core'
99
require 'rexml/element'
10+
require 'pry'
1011

1112
class Metasploit3 < Msf::Auxiliary
1213

@@ -67,6 +68,15 @@ def generate_token(account)
6768
'method' => 'POST',
6869
'data' => postdata,
6970
})
71+
72+
if res.code == 200
73+
error_text = res.body[/<div id=\"error_explanation\">\n\s+(.*?)<\/div>/m, 1]
74+
print_error("Server returned an error:")
75+
print_error(error_text)
76+
return false
77+
end
78+
return true
79+
#binding.pry
7080
end
7181

7282
def clear_tokens()
@@ -100,8 +110,6 @@ def reset_one(password, report=false)
100110
'data' => xml,
101111
})
102112

103-
#binding.pry if report
104-
105113
case res.code
106114
when 200
107115
# Failure, grab the error text
@@ -132,7 +140,12 @@ def run
132140
clear_tokens() if datastore['FLUSHTOKENS']
133141

134142
# Generate a token for our account
135-
generate_token(datastore['TARGETEMAIL'])
143+
status = generate_token(datastore['TARGETEMAIL'])
144+
if status == false
145+
print_error("Failed")
146+
return
147+
end
148+
print_good("Success")
136149

137150
# Reset a password. We're racing users creating other reset tokens.
138151
# If we didn't flush, we'll reset the account with the lowest ID that has a token.

0 commit comments

Comments
 (0)