@@ -118,8 +118,10 @@ def run
118
118
action = 'CreateAccessKey'
119
119
response = call_iam ( creds , 'Action' => action , 'UserName' => username )
120
120
doc = print_results ( response , action )
121
- results [ 'SecretAccessKey' ] = doc [ 'SecretAccessKey' ]
122
- results [ 'AccessKeyId' ] = doc [ 'AccessKeyId' ]
121
+ if doc
122
+ results [ 'SecretAccessKey' ] = doc [ 'SecretAccessKey' ]
123
+ results [ 'AccessKeyId' ] = doc [ 'AccessKeyId' ]
124
+ end
123
125
end
124
126
125
127
if datastore [ 'CREATE_CONSOLE' ]
@@ -128,14 +130,15 @@ def run
128
130
action = 'CreateLoginProfile'
129
131
response = call_iam ( creds , 'Action' => action , 'UserName' => username , 'Password' => password )
130
132
doc = print_results ( response , action )
131
- results [ 'Password' ] = password
133
+ results [ 'Password' ] = password if doc
132
134
end
133
135
134
136
action = 'GetUser'
135
137
response = call_iam ( creds , 'Action' => action , 'UserName' => username )
136
138
doc = print_results ( response , action )
139
+ return if doc . nil?
137
140
arn = doc [ 'Arn' ]
138
- results [ 'AccountId' ] = arn [ /^arn:aws:iam::(\d +):/ , 1 ]
141
+ results [ 'AccountId' ] = arn [ /^arn:aws:iam::(\d +):/ , 1 ]
139
142
140
143
keys = results . keys
141
144
table = Rex ::Text ::Table . new (
0 commit comments