Skip to content

Commit 7f8a5d3

Browse files
committed
improved credential reporting
1 parent fe15ac3 commit 7f8a5d3

File tree

2 files changed

+13
-53
lines changed

2 files changed

+13
-53
lines changed

lib/metasploit/framework/login_scanner/directadmin.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class DirectAdmin < HTTP
88

99
DEFAULT_PORT = 443
1010
PRIVATE_TYPES = [ :password ]
11-
LOGIN_STATUS = Metasploit::Model::Login::Status # Shorter name
1211

1312

1413
# Checks if the target is Direct Admin Web Control Panel. The login module should call this.
@@ -73,7 +72,7 @@ def get_login_state(username, password)
7372
})
7473

7574
unless res
76-
return {:status => LOGIN_STATUS::UNABLE_TO_CONNECT, :proof => res.to_s}
75+
return {:status => Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, :proof => res.to_s}
7776
end
7877

7978
# After login, the application should give us a new SID
@@ -82,10 +81,10 @@ def get_login_state(username, password)
8281
@last_sid = sid # Update our SID
8382

8483
if res.headers['Location'].to_s.include?('/') && !sid.blank?
85-
return {:status => LOGIN_STATUS::SUCCESSFUL, :proof => res.to_s}
84+
return {:status => Metasploit::Model::Login::Status::SUCCESSFUL, :proof => res.to_s}
8685
end
8786

88-
{:status => LOGIN_STATUS::INCORRECT, :proof => res.to_s}
87+
{:status => Metasploit::Model::Login::Status::INCORRECT, :proof => res.to_s}
8988
end
9089

9190

@@ -100,14 +99,15 @@ def attempt_login(credential)
10099
proof: nil,
101100
host: host,
102101
port: port,
103-
protocol: 'tcp'
102+
protocol: 'tcp',
103+
service_name: ssl ? 'https' : 'http'
104104
}
105105

106106
begin
107107
result_opts.merge!(get_login_state(credential.public, credential.private))
108108
rescue ::Rex::ConnectionError => e
109109
# Something went wrong during login. 'e' knows what's up.
110-
result_opts.merge!(status: LOGIN_STATUS::UNABLE_TO_CONNECT, proof: e.message)
110+
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: e.message)
111111
end
112112

113113
Result.new(result_opts)

modules/auxiliary/scanner/http/directadmin_login.rb

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -61,63 +61,23 @@ def scanner(ip)
6161
}.call
6262
end
6363

64-
65-
def report_good_cred(ip, port, result)
66-
service_data = {
67-
address: ip,
68-
port: port,
69-
service_name: 'http',
70-
protocol: 'tcp',
71-
workspace_id: myworkspace_id
72-
}
73-
74-
credential_data = {
75-
module_fullname: self.fullname,
76-
origin_type: :service,
77-
private_data: result.credential.private,
78-
private_type: :password,
79-
username: result.credential.public,
80-
}.merge(service_data)
81-
82-
login_data = {
83-
core: create_credential(credential_data),
84-
last_attempted_at: DateTime.now,
85-
status: result.status,
86-
proof: result.proof
87-
}.merge(service_data)
88-
89-
create_credential_login(login_data)
90-
end
91-
92-
93-
def report_bad_cred(ip, rport, result)
94-
invalidate_login(
95-
address: ip,
96-
port: rport,
97-
protocol: 'tcp',
98-
public: result.credential.public,
99-
private: result.credential.private,
100-
realm_key: result.credential.realm_key,
101-
realm_value: result.credential.realm,
102-
status: result.status,
103-
proof: result.proof
104-
)
105-
end
106-
107-
10864
# Attempts to login
10965
def bruteforce(ip)
11066
scanner(ip).scan! do |result|
67+
credential_data = result.to_h.merge({
68+
workspace_id: myworkspace_id,
69+
module_fullname: self.fullname,
70+
})
11171
case result.status
11272
when Metasploit::Model::Login::Status::SUCCESSFUL
11373
print_brute(:level => :good, :ip => ip, :msg => "Success: '#{result.credential}'")
114-
report_good_cred(ip, rport, result)
74+
create_credential_and_login(credential_data)
11575
when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
11676
vprint_brute(:level => :verror, :ip => ip, :msg => result.proof)
117-
report_bad_cred(ip, rport, result)
77+
invalidate_login(credential_data)
11878
when Metasploit::Model::Login::Status::INCORRECT
11979
vprint_brute(:level => :verror, :ip => ip, :msg => "Failed: '#{result.credential}'")
120-
report_bad_cred(ip, rport, result)
80+
invalidate_login(credential_data)
12181
end
12282
end
12383
end

0 commit comments

Comments
 (0)