Skip to content

Commit 0fffb17

Browse files
David MaloneyDavid Maloney
authored andcommitted
refactor afp_login
1 parent c3691ba commit 0fffb17

File tree

2 files changed

+14
-35
lines changed

2 files changed

+14
-35
lines changed

lib/metasploit/framework/login_scanner/afp.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ def attempt_login(credential)
3535
status = (success == true) ? Metasploit::Model::Login::Status::SUCCESSFUL : Metasploit::Model::Login::Status::INCORRECT
3636
end
3737

38-
Result.new(credential: credential, status: status)
38+
result = Result.new(credential: credential, status: status)
39+
result.host = host
40+
result.port = port
41+
result.protocol = 'tcp'
42+
result.service_name = 'afp'
43+
result
3944
end
4045

4146
def set_sane_defaults

modules/auxiliary/scanner/afp/afp_login.rb

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -63,46 +63,20 @@ def run_host(ip)
6363
connection_timeout: 30
6464
)
6565

66-
service_data = {
67-
address: ip,
68-
port: rport,
69-
service_name: 'afp',
70-
protocol: 'tcp',
71-
workspace_id: myworkspace_id
72-
}
73-
7466
scanner.scan! do |result|
67+
credential_data = result.to_h
68+
credential_data.merge!(
69+
module_fullname: self.fullname,
70+
workspace_id: myworkspace_id
71+
)
7572
if result.success?
76-
credential_data = {
77-
module_fullname: self.fullname,
78-
origin_type: :service,
79-
private_data: result.credential.private,
80-
private_type: :password,
81-
username: result.credential.public
82-
}
83-
credential_data.merge!(service_data)
84-
8573
credential_core = create_credential(credential_data)
74+
credential_data[:core] = credential_core
75+
create_credential_login(credential_data)
8676

87-
login_data = {
88-
core: credential_core,
89-
last_attempted_at: DateTime.now,
90-
status: Metasploit::Model::Login::Status::SUCCESSFUL
91-
}
92-
login_data.merge!(service_data)
93-
94-
create_credential_login(login_data)
9577
print_good "#{ip}:#{rport} - LOGIN SUCCESSFUL: #{result.credential}"
9678
else
97-
invalidate_login(
98-
address: ip,
99-
port: rport,
100-
protocol: 'tcp',
101-
public: result.credential.public,
102-
private: result.credential.private,
103-
realm_key: nil,
104-
realm_value: nil,
105-
status: result.status)
79+
invalidate_login(credential_data)
10680
print_status "#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status}: #{result.proof})"
10781
end
10882
end

0 commit comments

Comments
 (0)