Skip to content

Commit e31c9f5

Browse files
committed
Land rapid7#3987 - Buffalo Linkstation NAS Login Scanner
2 parents 4e12fdb + 44f7db4 commit e31c9f5

File tree

3 files changed

+147
-0
lines changed

3 files changed

+147
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
cli = Rex::Proto::Http::Client.new(host, port, {}, ssl, ssl_version)
38+
cli.connect
39+
req = cli.request_cgi({
40+
'method'=>'POST',
41+
'uri'=>'/dynamic.pl',
42+
'vars_post'=> {
43+
'bufaction'=>'verifyLogin',
44+
'user' => credential.public,
45+
'password'=>credential.private
46+
}
47+
})
48+
res = cli.send_recv(req)
49+
body = JSON.parse(res.body)
50+
if res && body.has_key?('success') && body['success']
51+
result_opts.merge!(status: Metasploit::Model::Login::Status::SUCCESSFUL, proof: res.body)
52+
else
53+
result_opts.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: res)
54+
end
55+
rescue ::JSON::ParserError
56+
result_opts.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: res.body)
57+
rescue ::EOFError, Errno::ETIMEDOUT, Rex::ConnectionError, ::Timeout::Error
58+
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
59+
end
60+
Result.new(result_opts)
61+
end
62+
end
63+
end
64+
end
65+
end
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'metasploit/framework/credential_collection'
8+
require 'metasploit/framework/login_scanner/buffalo'
9+
10+
class Metasploit3 < Msf::Auxiliary
11+
include Msf::Auxiliary::Scanner
12+
include Msf::Exploit::Remote::HttpClient
13+
include Msf::Auxiliary::Report
14+
include Msf::Auxiliary::AuthBrute
15+
16+
def initialize
17+
super(
18+
'Name' => 'Buffalo NAS Login Utility',
19+
'Description' => 'This module simply attempts to login to a Buffalo NAS instance using a specific user/pass. It is confirmed to work with 1.68',
20+
'Author' => [ 'Nicholas Starke <starke.nicholas[at]gmail.com>' ],
21+
'License' => MSF_LICENSE
22+
)
23+
24+
register_options(
25+
[
26+
Opt::RPORT(80)
27+
], self.class)
28+
29+
deregister_options('RHOST')
30+
end
31+
32+
def run_host(ip)
33+
cred_collection = Metasploit::Framework::CredentialCollection.new(
34+
blank_passwords: datastore['BLANK_PASSWORDS'],
35+
pass_file: datastore['PASS_FILE'],
36+
password: datastore['PASSWORD'],
37+
user_file: datastore['USER_FILE'],
38+
userpass_file: datastore['USERPASS_FILE'],
39+
username: datastore['USERNAME'],
40+
user_as_pass: datastore['USER_AS_PASS']
41+
)
42+
43+
scanner = Metasploit::Framework::LoginScanner::Buffalo.new(
44+
host: ip,
45+
port: rport,
46+
proxies: datastore['PROXIES'],
47+
cred_details: cred_collection,
48+
stop_on_success: datastore['STOP_ON_SUCCESS'],
49+
connection_timeout: 10,
50+
user_agent: datastore['UserAgent'],
51+
vhost: datastore['VHOST']
52+
)
53+
54+
scanner.scan! do |result|
55+
credential_data = result.to_h
56+
credential_data.merge!(
57+
module_fullname: fullname,
58+
workspace_id: myworkspace_id
59+
)
60+
if result.success?
61+
credential_core = create_credential(credential_data)
62+
credential_data[:core] = credential_core
63+
create_credential_login(credential_data)
64+
65+
print_good "#{ip}:#{rport} - LOGIN SUCCESSFUL: #{result.credential}"
66+
else
67+
invalidate_login(credential_data)
68+
print_status "#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status})"
69+
end
70+
end
71+
end
72+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'spec_helper'
2+
require 'metasploit/framework/login_scanner/buffalo'
3+
4+
describe Metasploit::Framework::LoginScanner::Buffalo do
5+
6+
it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false
7+
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
8+
it_behaves_like 'Metasploit::Framework::LoginScanner::HTTP'
9+
10+
end

0 commit comments

Comments
 (0)