Skip to content

Commit 439b893

Browse files
David MaloneyDavid Maloney
authored andcommitted
refactor axislogin
1 parent 0fffb17 commit 439b893

File tree

2 files changed

+21
-49
lines changed

2 files changed

+21
-49
lines changed

lib/metasploit/framework/login_scanner/axis2.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ def attempt_login(credential)
2121
)
2222

2323
result_opts = {
24-
credential: credential
24+
credential: credential,
25+
host: host,
26+
port: port,
27+
protocol: 'tcp'
2528
}
29+
if ssl
30+
result_opts[:service_name] = 'https'
31+
else
32+
result_opts[:service_name] = 'http'
33+
end
34+
2635
begin
2736
http_client.connect
2837
body = "userName=#{Rex::Text.uri_encode(credential.public)}&password=#{Rex::Text.uri_encode(credential.private)}&submit=+Login+"

modules/auxiliary/scanner/http/axis_login.rb

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -83,67 +83,30 @@ def run_host(ip)
8383
)
8484

8585
scanner.scan! do |result|
86+
credential_data = result.to_h
87+
credential_data.merge!(
88+
module_fullname: self.fullname,
89+
workspace_id: myworkspace_id
90+
)
8691
case result.status
8792
when Metasploit::Model::Login::Status::SUCCESSFUL
8893
print_brute :level => :good, :ip => ip, :msg => "Success: '#{result.credential}'"
89-
do_report(ip, rport, result)
94+
credential_core = create_credential(credential_data)
95+
credential_data[:core] = credential_core
96+
create_credential_login(credential_data)
9097
:next_user
9198
when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
9299
print_brute :level => :verror, :ip => ip, :msg => "Could not connect"
93-
invalidate_login(
94-
address: ip,
95-
port: rport,
96-
protocol: 'tcp',
97-
public: result.credential.public,
98-
private: result.credential.private,
99-
realm_key: result.credential.realm_key,
100-
realm_value: result.credential.realm,
101-
status: result.status
102-
)
100+
invalidate_login(credential_data)
103101
:abort
104102
when Metasploit::Model::Login::Status::INCORRECT
105103
print_brute :level => :verror, :ip => ip, :msg => "Failed: '#{result.credential}'"
106-
invalidate_login(
107-
address: ip,
108-
port: rport,
109-
protocol: 'tcp',
110-
public: result.credential.public,
111-
private: result.credential.private,
112-
realm_key: result.credential.realm_key,
113-
realm_value: result.credential.realm,
114-
status: result.status
115-
)
104+
invalidate_login(credential_data)
116105
end
117106
end
118107

119108
end
120109

121-
def do_report(ip, port, result)
122-
service_data = {
123-
address: ip,
124-
port: port,
125-
service_name: 'http',
126-
protocol: 'tcp',
127-
workspace_id: myworkspace_id
128-
}
129-
130-
credential_data = {
131-
module_fullname: self.fullname,
132-
origin_type: :service,
133-
private_data: result.credential.private,
134-
private_type: :password,
135-
username: result.credential.public,
136-
}.merge(service_data)
137-
138-
credential_core = create_credential(credential_data)
139-
140-
login_data = {
141-
core: credential_core,
142-
last_attempted_at: DateTime.now,
143-
status: result.status
144-
}.merge(service_data)
145-
146-
create_credential_login(login_data)
147-
end
110+
148111

149112
end

0 commit comments

Comments
 (0)