Skip to content

Commit ce8a994

Browse files
committed
Cleanup. Sanity check in setup. vprint
1 parent ee3dd3a commit ce8a994

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

lib/metasploit/framework/login_scanner/mybook_live.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ 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+
body = "data[Login][owner_name]=admin&data[Login][owner_passwd]=#{credential.private}"
3737
cli = Rex::Proto::Http::Client.new(host, port, {}, ssl, ssl_version)
3838
cli.connect
39-
req = cli.request_cgi({
39+
req = cli.request_cgi(
4040
'method' => 'POST',
4141
'uri' => '/UI/login',
42-
'data' => body
43-
})
42+
'data' => Rex::Text.uri_encode(body)
43+
)
4444
res = cli.send_recv(req)
4545
if res && res.code == 302 && res.headers['location'] && res.headers['location'].include?('UI')
4646
result_opts.merge!(status: Metasploit::Model::Login::Status::SUCCESSFUL, proof: res.headers)

modules/auxiliary/scanner/http/mybook_live_login.rb

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,25 @@ 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+
# They must select at least blank passwords, provide a pass file or a password
37+
one_required = %w(BLANK_PASSWORDS PASS_FILE PASSWORD)
38+
unless one_required.any? { |o| datastore[o] }
39+
fail_with(Failure::BadConfig, "Invalid options: One of #{one_required.join(', ')} must be set")
40+
end
41+
end
42+
3543
def run_host(ip)
3644
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'
45+
blank_passwords: datastore['BLANK_PASSWORDS'],
46+
pass_file: datastore['PASS_FILE'],
47+
password: datastore['PASSWORD'],
48+
username: 'admin'
4149
)
4250

4351
scanner = Metasploit::Framework::LoginScanner::MyBookLive.new(
@@ -59,8 +67,8 @@ def run_host(ip)
5967
scanner.scan! do |result|
6068
credential_data = result.to_h
6169
credential_data.merge!(
62-
module_fullname: fullname,
63-
workspace_id: myworkspace_id
70+
module_fullname: fullname,
71+
workspace_id: myworkspace_id
6472
)
6573
if result.success?
6674
credential_core = create_credential(credential_data)
@@ -70,7 +78,7 @@ def run_host(ip)
7078
print_good "#{ip}:#{rport} - LOGIN SUCCESSFUL: #{result.credential}"
7179
else
7280
invalidate_login(credential_data)
73-
print_status "#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status})"
81+
vprint_status "#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status})"
7482
end
7583
end
7684
end

0 commit comments

Comments
 (0)