CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/login_scanner/mybook_live.rb
Views: 1904
1
require 'metasploit/framework/login_scanner/http'
2
3
module Metasploit
4
module Framework
5
module LoginScanner
6
7
# Western Digital MyBook Live login scanner
8
class MyBookLive < HTTP
9
10
# Inherit LIKELY_PORTS,LIKELY_SERVICE_NAMES, and REALM_KEY from HTTP
11
CAN_GET_SESSION = true
12
DEFAULT_PORT = 80
13
PRIVATE_TYPES = [ :password ]
14
15
# (see Base#set_sane_defaults)
16
def set_sane_defaults
17
self.uri = '/UI/login' if self.uri.nil?
18
self.method = 'POST' if self.method.nil?
19
20
super
21
end
22
23
def attempt_login(credential)
24
result_opts = {
25
credential: credential,
26
host: host,
27
port: port,
28
protocol: 'tcp'
29
}
30
if ssl
31
result_opts[:service_name] = 'https'
32
else
33
result_opts[:service_name] = 'http'
34
end
35
begin
36
res = send_request({
37
'method' => method,
38
'uri' => uri,
39
'vars_post' => {
40
'data[Login][owner_name]' => 'admin',
41
'data[Login][owner_passwd]' => credential.private
42
}
43
})
44
45
if res && res.code == 302 && res.headers['location'] && res.headers['location'].include?('UI')
46
result_opts.merge!(status: Metasploit::Model::Login::Status::SUCCESSFUL, proof: res.headers)
47
elsif res.nil?
48
result_opts.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: 'No response')
49
else
50
result_opts.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: res.headers)
51
end
52
rescue ::EOFError, Errno::ETIMEDOUT, Rex::ConnectionError, ::Timeout::Error
53
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
54
end
55
Result.new(result_opts)
56
end
57
end
58
end
59
end
60
end
61
62