Skip to content

Commit 33f73a8

Browse files
David MaloneyDavid Maloney
authored andcommitted
refactor db2
1 parent 439b893 commit 33f73a8

File tree

2 files changed

+14
-37
lines changed

2 files changed

+14
-37
lines changed

lib/metasploit/framework/login_scanner/db2.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ def attempt_login(credential)
4646
})
4747
end
4848

49-
::Metasploit::Framework::LoginScanner::Result.new(result_options)
49+
result = ::Metasploit::Framework::LoginScanner::Result.new(result_options)
50+
result.host = host
51+
result.port = port
52+
result.protocol = 'tcp'
53+
result.service_name = 'db2'
54+
result
5055
end
5156

5257
private

modules/auxiliary/scanner/db2/db2_auth.rb

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,48 +61,20 @@ def run_host(ip)
6161
connection_timeout: 30
6262
)
6363

64-
service_data = {
65-
address: ip,
66-
port: rport,
67-
service_name: 'db2',
68-
protocol: 'tcp',
69-
workspace_id: myworkspace_id
70-
}
71-
7264
scanner.scan! do |result|
65+
credential_data = result.to_h
66+
credential_data.merge!(
67+
module_fullname: self.fullname,
68+
workspace_id: myworkspace_id
69+
)
7370
if result.success?
74-
credential_data = {
75-
module_fullname: self.fullname,
76-
origin_type: :service,
77-
private_data: result.credential.private,
78-
private_type: :password,
79-
realm_key: Metasploit::Model::Realm::Key::DB2_DATABASE,
80-
realm_value: result.credential.realm,
81-
username: result.credential.public
82-
}
83-
credential_data.merge!(service_data)
84-
8571
credential_core = create_credential(credential_data)
72+
credential_data[:core] = credential_core
73+
create_credential_login(credential_data)
8674

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)
9575
print_good "#{ip}:#{rport} - LOGIN SUCCESSFUL: #{result.credential}"
9676
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: Metasploit::Model::Realm::Key::DB2_DATABASE,
104-
realm_value: result.credential.realm,
105-
status: result.status)
77+
invalidate_login(credential_data)
10678
print_status "#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status}: #{result.proof})"
10779
end
10880
end

0 commit comments

Comments
 (0)