Skip to content

Commit ed9b7ea

Browse files
committed
Merge pull request #1 from jhart-r7/landing-4003-jhart
Cleanup. Sanity check in setup. vprint
2 parents ee3dd3a + 83df08a commit ed9b7ea

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

lib/metasploit/framework/login_scanner/mybook_live.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,26 @@ def set_sane_defaults
2222

2323
def attempt_login(credential)
2424
result_opts = {
25-
credential: credential,
26-
host: host,
27-
port: port,
28-
protocol: 'tcp'
25+
credential: credential,
26+
host: host,
27+
port: port,
28+
protocol: 'tcp'
2929
}
3030
if ssl
3131
result_opts[:service_name] = 'https'
3232
else
3333
result_opts[:service_name] = 'http'
3434
end
3535
begin
36-
body = "data%5BLogin%5D%5Bowner_name%5D=admin&data%5BLogin%5D%5Bowner_passwd%5D=#{Rex::Text.uri_encode(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
39-
req = cli.request_cgi({
40+
req = cli.request_cgi(
4041
'method' => 'POST',
4142
'uri' => '/UI/login',
4243
'data' => body
43-
})
44+
)
4445
res = cli.send_recv(req)
4546
if res && res.code == 302 && res.headers['location'] && res.headers['location'].include?('UI')
4647
result_opts.merge!(status: Metasploit::Model::Login::Status::SUCCESSFUL, proof: res.headers)

modules/auxiliary/scanner/http/mybook_live_login.rb

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,31 @@ def initialize
2727
], self.class)
2828

2929
register_autofilter_ports([ 80 ])
30-
31-
#username is hardcoded into application
30+
31+
# username is hardcoded into application
3232
deregister_options('RHOST', 'USERNAME', 'USER_FILE', 'USER_AS_PASS', 'DB_ALL_USERS')
3333
end
3434

35+
def setup
36+
super
37+
# They must select at least blank passwords, provide a pass file or a password
38+
one_required = %w(BLANK_PASSWORDS PASS_FILE PASSWORD)
39+
unless one_required.any? { |o| datastore.has_key?(o) && datastore[o] }
40+
fail_with(Failure::BadConfig, "Invalid options: One of #{one_required.join(', ')} must be set")
41+
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
47+
end
48+
3549
def run_host(ip)
3650
cred_collection = Metasploit::Framework::CredentialCollection.new(
37-
blank_passwords: datastore['BLANK_PASSWORDS'],
38-
pass_file: datastore['PASS_FILE'],
39-
password: datastore['PASSWORD'],
40-
username: 'admin'
51+
blank_passwords: datastore['BLANK_PASSWORDS'],
52+
pass_file: datastore['PASS_FILE'],
53+
password: datastore['PASSWORD'],
54+
username: 'admin'
4155
)
4256

4357
scanner = Metasploit::Framework::LoginScanner::MyBookLive.new(
@@ -59,8 +73,8 @@ def run_host(ip)
5973
scanner.scan! do |result|
6074
credential_data = result.to_h
6175
credential_data.merge!(
62-
module_fullname: fullname,
63-
workspace_id: myworkspace_id
76+
module_fullname: fullname,
77+
workspace_id: myworkspace_id
6478
)
6579
if result.success?
6680
credential_core = create_credential(credential_data)
@@ -70,7 +84,7 @@ def run_host(ip)
7084
print_good "#{ip}:#{rport} - LOGIN SUCCESSFUL: #{result.credential}"
7185
else
7286
invalidate_login(credential_data)
73-
print_status "#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status})"
87+
vprint_status "#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status})"
7488
end
7589
end
7690
end

0 commit comments

Comments
 (0)