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/buffalo.rb
Views: 1904
1
require 'metasploit/framework/login_scanner/http'
2
require 'json'
3
4
module Metasploit
5
module Framework
6
module LoginScanner
7
8
# Buffalo Linkstation NAS login scanner
9
class Buffalo < HTTP
10
11
# Inherit LIKELY_PORTS,LIKELY_SERVICE_NAMES, and REALM_KEY from HTTP
12
CAN_GET_SESSION = true
13
DEFAULT_PORT = 80
14
PRIVATE_TYPES = [ :password ]
15
16
# (see Base#set_sane_defaults)
17
def set_sane_defaults
18
self.uri = "/dynamic.pl" if self.uri.nil?
19
self.method = "POST" if self.method.nil?
20
21
super
22
end
23
24
def attempt_login(credential)
25
result_opts = {
26
credential: credential,
27
host: host,
28
port: port,
29
protocol: 'tcp'
30
}
31
if ssl
32
result_opts[:service_name] = 'https'
33
else
34
result_opts[:service_name] = 'http'
35
end
36
begin
37
res = send_request({
38
'method'=>'POST',
39
'uri'=>'/dynamic.pl',
40
'vars_post'=> {
41
'bufaction'=>'verifyLogin',
42
'user' => credential.public,
43
'password'=>credential.private
44
}
45
})
46
47
body = JSON.parse(res.body)
48
if res && body.has_key?('success') && body['success']
49
result_opts.merge!(status: Metasploit::Model::Login::Status::SUCCESSFUL, proof: res.body)
50
else
51
result_opts.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: res)
52
end
53
rescue ::JSON::ParserError
54
result_opts.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: res.body)
55
rescue ::EOFError, Errno::ETIMEDOUT, Rex::ConnectionError, ::Timeout::Error
56
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
57
end
58
Result.new(result_opts)
59
end
60
end
61
end
62
end
63
end
64
65