> 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/vpc-flow-logs-queries.md).

# VPC 로그 쿼리

이 페이지에는 VPC 흐름 로그와 VPC DNS 로그에 대한 예제가 포함되어 있습니다.

## VPC 흐름 로그 쿼리

### SSH 및 RDP에 대한 VPC 흐름 로그 활동 표시

원격 셸에는 일반적으로 한쪽 끝에 사람이 있습니다. 조사 중에는 SSH 및 RDP에서 세션을 분리하는 것이 특정 행위자 활동을 식별하기 위한 표준 절차인 경우가 많습니다.

```sql
SELECT
 *
FROM panther_logs.public.aws_vpcflow
WHERE
  p_occurs_between('2021-01-01', '2021-01-02')
  AND
  (srcport IN (22, 3389) OR dstport IN (22, 3389))
ORDER BY p_event_time ASC
LIMIT 100
```

### IP 주소에 대한 VPC 흐름 로그 활동 표시

조사 중에는 특정 IP 주소가 관심 대상(예: 알려진 명령 및 제어 노드)으로 식별되는 경우가 많습니다. IP 주소의 역할이 식별되면 해당 활동을 분리하고 설명하는 것이 중요합니다. 이는 어떤 리소스가 손상될 가능성이 높은지 보여줄 수 있습니다.

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

### CloudTrail sourceIPAddresses와 관련된, 콘솔 로그인을 수행하는 VPC 흐름 로그 활동 표시

자격 증명 침해가 우려되는 경우 모든 AWS 콘솔 활동을 파악하는 것이 매우 중요합니다. 이 쿼리는 콘솔 로그인에 관여한 모든 CloudTrail sourceIPaddresses를 찾아낸 다음, 관련된 모든 VPC 흐름 활동을 반환합니다. 이렇게 하면 공통 IP 주소가 있는지 확인할 수 있습니다. 특히 관심을 둘 IP 주소는 **조직 외부의** 인스턴스와 통신하는 동시에 콘솔에 로그인하는 것입니다. 이는 권한 없는 행위자가 계정 리소스에 접근하고 있는 침해를 나타낼 수 있습니다.

```sql
WITH cloudTrailIPs as
(SELECT
  DISTINCT sourceIPAddress AS ip
 FROM panther_logs.public.aws_cloudtrail
 WHERE
    p_occurs_between('2021-01-01', '2021-01-02')
    AND
    eventtype = 'AwsConsoleSignIn'
)
SELECT
 *
FROM  cloudTrailIPs ips JOIN panther_logs.public.aws_vpcflow flow ON (ips.ip = flow.srcaddr OR ips.ip = flow.dstaddr)
WHERE
  p_occurs_between('2021-01-01', '2021-01-02')
ORDER BY p_event_time ASC
LIMIT 100
```

## **VPC DNS 쿼리 예제**

{% hint style="info" %}
아래 쿼리는 [VPC DNS 로그](/ko/data-onboarding/supported-logs/aws/vpc.md#vpc-dns-logging), 하지만 다른 DNS 로그에도 적용할 수 있습니다.
{% endhint %}

### **지난 1주일 동안 쿼리가 가장 많은 소스**

{% code overflow="wrap" %}

```sql
SELECT 
    srcids:instance, COUNT(*) 
FROM 
    panther_logs.public.aws_vpcdns 
WHERE 
    p_occurs_since(1w) 
GROUP BY 1 
LIMIT 100
```

{% endcode %}

### **지난 4주 동안의 드문 쿼리**

{% code overflow="wrap" %}

```sql
-- 지난 4주 동안의 드문 쿼리
SELECT 
    query_name, COUNT(*) as total
FROM  
    panther_logs.public.aws_vpcdns
WHERE 
    p_occurs_since(4w)
GROUP BY 1
ORDER BY 2
LIMIT 100
```

{% endcode %}

### **쿼리 목록 표시, AWS 내부 쿼리 제거**

```sql
-- 쿼리 목록
SELECT
    p_event_time, srcids, query_name, query_type, rcode
FROM
    panther_logs.public.aws_vpcdns
WHERE 
    -- AWS 내부 쿼리 제거
    not query_name LIKE ANY ('%amazonaws.com.', '%.compute.internal.')
LIMIT 10

```

### **상위 10개 최상위 도메인 분리 및 목록 표시**

```sql
-- 상위 10개 최상위 도메인 계산
SELECT
    split_part(query_name, '.', -2) as TLD, count(*) as total
FROM
    panther_logs.public.aws_vpcdns
GROUP by 1
ORDER BY 2 desc
LIMIT 10
```


---

# 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/vpc-flow-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.
