Skip to content

Commit 83df08a

Browse files
committed
Properly encode body and catch invalid configs
1 parent ce8a994 commit 83df08a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/metasploit/framework/login_scanner/mybook_live.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ def attempt_login(credential)
3333
result_opts[:service_name] = 'http'
3434
end
3535
begin
36-
body = "data[Login][owner_name]=admin&data[Login][owner_passwd]=#{credential.private}"
36+
cred = Rex::Text.uri_encode(credential.private)
37+
body = "data%5BLogin%5D%5Bowner_name%5D=admin&data%5BLogin%5D%5Bowner_passwd%5D=#{cred}"
3738
cli = Rex::Proto::Http::Client.new(host, port, {}, ssl, ssl_version)
3839
cli.connect
3940
req = cli.request_cgi(
4041
'method' => 'POST',
4142
'uri' => '/UI/login',
42-
'data' => Rex::Text.uri_encode(body)
43+
'data' => body
4344
)
4445
res = cli.send_recv(req)
4546
if res && res.code == 302 && res.headers['location'] && res.headers['location'].include?('UI')

modules/auxiliary/scanner/http/mybook_live_login.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ def initialize
3333
end
3434

3535
def setup
36+
super
3637
# They must select at least blank passwords, provide a pass file or a password
3738
one_required = %w(BLANK_PASSWORDS PASS_FILE PASSWORD)
38-
unless one_required.any? { |o| datastore[o] }
39+
unless one_required.any? { |o| datastore.has_key?(o) && datastore[o] }
3940
fail_with(Failure::BadConfig, "Invalid options: One of #{one_required.join(', ')} must be set")
4041
end
42+
if !datastore['PASS_FILE']
43+
if !datastore['BLANK_PASSWORDS'] && datastore['PASSWORD'].blank?
44+
fail_with(Failure::BadConfig, "PASSWORD or PASS_FILE must be set to a non-empty string if not BLANK_PASSWORDS")
45+
end
46+
end
4147
end
4248

4349
def run_host(ip)

0 commit comments

Comments
 (0)