> For the complete documentation index, see [llms.txt](https://docs.panther.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.panther.com/ko/search/data-explorer/example-queries/cloudtrail-logs-queries.md).

# CloudTrail 로그 쿼리

## CloudTrail에서 특정 AWS 액세스 키 ID(AKID)에 대한 모든 레코드 찾기

```sql
SELECT
 *
FROM panther_logs.public.aws_cloudtrail
WHERE p_occurs_since('1 day')
     AND array_contains('ASIAVHOW5LG5FQ4R74ZZ'::variant, p_any_trace_ids)
ORDER BY p_event_time ASC
LIMIT 100
```

## CloudTrail에서 모든 콘솔 "root" 로그인을 찾기

root 계정이 AWS 콘솔에 로그인하는 일은 거의 없어야 합니다—그러한 모든 로그인을 찾아보세요.

```sql
SELECT
 *
FROM panther_logs.public.aws_cloudtrail
WHERE
  p_occurs_between('2021-01-01', '2021-01-02')
  AND
  eventtype = 'AwsConsoleSignIn'
  AND
  useridentity:arn LIKE '%root%'
ORDER BY p_event_time ASC
LIMIT 100
```

## CloudTrail에서 콘솔 로그인의 모든 sourceIPAddresses를 찾고 순위를 매기기

이 쿼리는 위 쿼리와 유사하며, 모든 콘솔 로그인에 대해 IP 주소를 순위화합니다. 이는 상대적인 활동을 순위화하면서 어떤 IP 주소가 콘솔에 로그인하는지 식별하는 데 도움이 됩니다. 이는 종종 비정상적인 동작을 드러낼 수 있습니다.

```sql
SELECT
 sourceipaddress,
 count(1) as total_rows
FROM panther_logs.public.aws_cloudtrail
WHERE
  p_occurs_between('2021-01-01', '2021-01-02')
  AND
  eventtype = 'AwsConsoleSignIn'
GROUP BY sourceipaddress
ORDER BY total_rows DESC
LIMIT 100
```

## AWS 인스턴스와 관련된 CloudTrail 활동 표시

조사 중에 특정 인스턴스가 초점이 될 수 있습니다. 예를 들어, 인스턴스가 침해된 경우입니다. 이 쿼리는 Panther 필드 `p_any_aws_instance_ids` 를 사용하여 관련 활동이 있는 모든 CloudTrail 이벤트를 쉽게 검색합니다.

```sql
SELECT
 *
FROM panther_logs.public.aws_cloudtrail
WHERE p_occurs_between('2021-01-01', '2021-02-01')
     AND array_contains('i-0c4f541ef2f82481c'::variant, p_any_aws_instance_ids)
ORDER BY p_event_time ASC
LIMIT 100
```

## AWS 역할과 관련된 CloudTrail 활동 표시

위 쿼리와 유사하게, Panther 필드 `p_any_aws_arns` 를 사용하면 관심 있는 ARN(아마도 침해된 것으로 알려진 역할의 ARN)과 관련된 모든 CloudTrail 활동을 빠르고 쉽게 찾을 수 있습니다.

```sql
SELECT
 *
FROM panther_logs.public.aws_cloudtrail
WHERE p_occurs_between('2021-01-01', '2021-02-01')
     AND array_contains('arn:aws:iam::123456789012:role/SomeRole'::variant, p_any_aws_arns)
ORDER BY p_event_time ASC
LIMIT 100
```

## AWS 계정 ID와 관련된 CloudTrail 활동 표시

이는 Panther 필드를 사용해 광범위하게 쿼리하는 또 다른 변형입니다. 이 경우 `p_any_aws_account_ids` 를 사용하여 관심 있는 계정과 관련된 모든 CloudTrail 데이터를 찾습니다(아마도 그 계정이 침해되었고, 우려되는 것은 측면 이동일 수 있습니다).

```sql
SELECT
 *
FROM panther_logs.public.aws_cloudtrail
WHERE p_occurs_between('2021-01-01', '2021-02-01')
     AND array_contains('123456789012'::variant, p_any_aws_account_ids)
ORDER BY p_event_time ASC
LIMIT 100
```

## CloudTrail에서 모든 인스턴스 시작 표시

자격 증명이 유출되었을 때는 공격자가 인프라를 생성하거나 수정하는 것이 우려되는 경우가 많습니다. 아래 쿼리는 모든 RunInstances 명령을 찾습니다. 이는 비정상적인 활동이 있는지 검토해야 합니다. 예를 들어, 공격자들이 침해된 계정에서 비트코인 채굴을 위해 많은 수의 GPU 인스턴스를 가동한 사례가 알려져 있습니다.

```sql
SELECT
 p_event_time,
 p_any_aws_instance_ids
FROM panther_logs.public.aws_cloudtrail
WHERE p_occurs_between('2021-01-01', '2021-02-01')
     AND eventname = 'RunInstances'
ORDER BY p_event_time ASC
LIMIT 100
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.panther.com/ko/search/data-explorer/example-queries/cloudtrail-logs-queries.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
