# Public AMI

<figure><img src="/files/mQmL6yzanXu4HfvS6ZI0" alt=""><figcaption></figcaption></figure>

AMI(Amazon Machine Image)는 인스턴스를 실행할 때 사용하는 이미지입니다.

기본적으로 AMI는 Private으로 설정되지만 Public으로 설정되어 있을 경우 Account ID 정보를 토대로 AMI 목록을 열거할 수 있고, 공개된 AMI로부터 인스턴스를 생성하여 시스템 내부 데이터를 탈취할 수 있습니다.

{% hint style="info" %}
일반적으로 AMI는 깡통이라 생각할 수 있지만 초기 세팅 스크립트가 있을 확률이 높으며, 그 안에는 크리덴셜 등이 있을 수 있습니다.
{% endhint %}

## Abuse

{% hint style="info" %}
AMI 목록 열거는 Public 자산이더라도 익명 접근이 불가능하며 반드시 AWS 자격증명이 있어야 합니다.
{% endhint %}

<pre class="language-bash"><code class="lang-bash"><strong># Account ID를 기반으로 AMI 목록 열거
</strong>aws ec2 describe-images --owners '&#x3C;account-id>' --include-deprecated --region '&#x3C;region>'

<strong># AMI를 통해 인스턴스 생성
</strong>aws ec2 run-instances --image-id '&#x3C;ami-id>' --instance-type t2.micro --key-name '&#x3C;your-aws-ssh-key>' --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=TestInstance}]'

<strong># aws ssh 키를 통해 생성한 인스턴스에 로그인
</strong>ssh -i '&#x3C;your-aws-ssh-key>' '&#x3C;user@instance-ip>'
</code></pre>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pentestwiki.com/cloud/aws/undefined-1/public-ami.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
