# IPinfo

## 개요

Panther는 [IPinfo](https://ipinfo.io/)와 파트너십을 맺었습니다. IP 주소 데이터의 신뢰할 수 있는 출처인 IPinfo는 Panther 고객에게 통합된 IP 관련 보강 정보를 제공합니다.

다음과 같은 방법으로 Panther 디택션에서 IPinfo 보강 데이터를 사용하여 오탐 알러트를 줄이세요:

* 의심스러운 사용자의 현재 IP 지리 위치 세부 정보를 교차 검증하여 프로필 정보의 불일치를 발견하고 차단합니다.
* 고위험 위치나 네트워크에서 들어오는 트래픽을 사전에 식별하고 차단하여 귀하에게 도달하기 전에 막습니다.
* 대상과 관련된 보안 위험을 초래할 수 있는 다른 엔티티를 정확하고 신뢰성 있게 발견합니다.

IPinfo 데이터 세트는 추가 비용 없이 모든 Panther 계정에서 사용할 수 있으며 기본적으로 비활성화되어 있습니다. 방법 알아보기 [여기에서 저장된 인리치먼트 데이터 보기](/ko/enrichment.md#viewing-and-managing-enrichments)및 [여기에서 인리치먼트 데이터가 포함된 로그 이벤트 보기](/ko/enrichment.md#viewing-log-events-with-enrichment-data).

### IPinfo 작동 방식

알러트 이벤트는 JSON 이벤트의 `p_enrichment` 필드 내에서 IPinfo 데이터로 자동 보강됩니다.

IPinfo 데이터는 다음을 사용하여 디택션에서 액세스할 수 있습니다. [사전 구축된 Python 헬퍼](#available-methods) (및 [`deep_get`](/ko/detections/rules/python/globals.md#deep_get)).

[IPinfo 데이터 세트는](#ipinfo-datasets) 보강 테이블로 대량 저장되므로, 디택션 로직이나 알러트에서 이 보강 기능을 활용하기 위해 API 호출을 할 필요가 없습니다.

IPinfo의 데이터는 하루에 한 번 업데이트됩니다.

### IPinfo 데이터 세트는

IP 주소에 대한 컨텍스트 정보를 추가하는 IPinfo의 데이터 유형은 세 가지입니다:

* [지리 위치 데이터](https://ipinfo.io/developers/data-types#geolocation-data)
* [ASN 데이터](https://ipinfo.io/developers/data-types#asn-data)
* [개인 정보 데이터](https://ipinfo.io/developers/data-types#privacy-data)

## IPinfo 데이터 세트를 활성화하는 방법

CI/CD 워크플로를 사용 중이라면 [아래의 CI/CD Users 섹션을 참조하여](#ci-cd-users) 추가 고려 사항에 대해 알아보세요.

{% hint style="info" %}
Panther Console에서 Analyst 역할이 IPinfo 패키지를 보고 관리할 수 있도록 하려면 해당 역할에 다음 권한을 할당해야 합니다. **조회 보기** 및 **조회 관리** 권한입니다.
{% endhint %}

IPinfo 보강을 활성화하려면:

1. 왼쪽 탐색 모음에서 Panther Console의 **디택션.**
2. 을 클릭하세요. **팩** 탭을 클릭합니다.
   * 이 페이지에서 IPinfo에서 사용할 수 있는 기본 제공 팩을 볼 수 있습니다.
3. 활성화하려는 IPInfo 타일의 오른쪽에서 토글을 클릭하여 팩을 활성화합니다.
4. 클릭 **계속** 라는 대화상자가 나타납니다.

   <figure><img src="/files/06cca3535d9e3bf3ac0cbcef47546f365240cac6" alt=""><figcaption></figcaption></figure>

   * CI/CD를 통해 추가 변경을 하고 싶으시다면 [Panther Analysis Tool (PAT)](/ko/panther/detections-repo/pat.md), 자세한 내용은 Panther 담당자에게 문의하세요.
5. IPinfo 데이터 세트가 활성화되었는지 확인하려면 왼쪽 사이드바 메뉴에서 **구성** > **보강 제공업체를 클릭합니다.**
   * 이 페이지에서 모든 보강 소스, 각 소스의 현재 활성화 또는 비활성화 상태, 그리고 소스 데이터가 마지막으로 새로 고쳐진 시간을 볼 수 있습니다.
   * 6개의 IPinfo 소스 테이블과 마지막으로 새로 고쳐진 시간이 표시됩니다. 비활성화된 데이터 세트는 새로 고쳐지지 않습니다.

     * The `ipinfo_asn` ,`ipinfo_location` 및 `ipinfo_privacy` 테이블은 디택션 엔진에서 실시간 조회에 사용됩니다.
     * The `ipinfo_asn_datalake` , `ipinfo_location_datalake` 및 `ipinfo_privacy_datalake` 테이블은 데이터 레이크에서 IPinfo 데이터에 대한 쿼리 및 조인에 사용됩니다.

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

### CI/CD 사용자

CLI 워크플로에서 IPinfo enrichment를 활성화하려면 다음을 참조하세요. [Panther Analysis Tool로 Enrichments 관리하기](/ko/panther/detections-repo/pat/managing-enrichment.md) 가이드.

다음 고려 사항에 유의하세요:

* CI/CD 사용자는 IPinfo 테이블을 가져오기 위해 디택션 Packs를 사용할 필요가 없습니다. 최신 릴리스를 가져올 수 있습니다. [`panther-analysis`](https://github.com/panther-labs/panther-analysis) 그리고 다음을 사용할 수 있습니다. `panther_analysis_tool` (PAT)를 사용하여 IPinfo enrichments를 업로드합니다.
  * 다음을 사용하여 IPinfo 테이블을 활성화하려면 [`panther-analysis`](https://github.com/panther-labs/panther-analysis) repository에서 각 해당 YAML 구성 파일을 열고 다음을 설정해야 합니다. `enabled: true`.
* CI/CD 사용자는 PAT를 사용하여 IPinfo 테이블을 사용자 지정하지 않는 한, 디택션 Packs를 통해 IPinfo enrichments를 활성화할 수 있습니다.
  * Panther Console에서 활성화한 후 PAT를 통해 IPinfo를 관리하기로 선택한 경우, 먼저 Panther Console에서 디택션 Packs를 비활성화해야 합니다. Panther Console과 PAT를 동시에 사용하여 IPinfo를 관리하는 것은 지원되지 않습니다.
* IPinfo enrichment를 관리하는 방법에 대한 자세한 내용은 다음을 참조하세요. [Panther의 GitHub repository에 있는 IPinfo 파일](https://github.com/panther-labs/panther-analysis/tree/master/lookup_tables/ipinfo).

## 데이터 레이크에서 IPinfo 데이터를 쿼리하는 방법

데이터 레이크에는 세 개의 IPinfo 테이블이 있습니다:

* `ipinfo_asn_datalake`
  * 다음을 참조하세요 [IPinfo의 ASN API 문서](https://ipinfo.io/products/asn-api).
* `ipinfo_location_datalake`
  * 다음을 참조하세요 [IPinfo의 IP Geolocation API 문서](https://ipinfo.io/products/ip-geolocation-api).
* `ipinfo_privacy_datalake`
  * 다음을 참조하세요 [IPinfo의 Privacy 디택션 API 문서](https://ipinfo.io/products/proxy-vpn-detection-api).

위 각 테이블에는 또한 `<table>_history` 모든 변경 사항을 기록하는 테이블이 있습니다.

### 다음 사용 `joinkey`

데이터 레이크에서 IPinfo 데이터를 쿼리할 때는 다음을 사용해야 합니다. `joinkey` 쿼리를 효율적으로 만들기 위해. 다음 사용자 정의 함수는 다음 설정을 `joinkey` 더 쉽게 만듭니다:

* `PANTHER_LOOKUPS.PUBLIC.IPINFO_RANGE_TO_CIDR`
* `PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_INT`
* `PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_IP`
  * 참고: 다음에 대한 IPinfo의 코드 `TO_IP` 는 IPv4만 지원합니다.
* `PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_JOIN_KEY`

다음 보기 [다음을 사용하여 데이터 레이크를 쿼리하는 방법을 보여주는 예시 `joinkey` 아래](#example-query-the-data-lake-for-ipinfo-data-using-a-joinkey).

## 예시

### 예시: IPinfo 위치 데이터를 기반으로 한 알러트

이 예시에서는 예상하지 못한 국가에서 수행된 AWS 콘솔에 대한 모든 로그인에서 알러트를 발생시키는 룰을 생성합니다.

```python
def 룰(event):
    global ipinfo_location
    ipinfo_location = IPInfoLocation(event)
    match_field = ""
    if event.get("p_log_type") == "AWS.Cloudtrail":
        match_field = "sourceIPAddress"
    
    if event.get("eventname") == 'ConsoleLogin' and ipinfo_location.country(match_field) != "US":
        return True
    return False
```

### 예시: 다음을 사용하여 IPinfo 데이터에 대해 데이터 레이크 쿼리하기 `joinkey`

IP를 조회하려면 `71.114.47.25`, 다음을 지정해야 합니다. `joinkey` 그리고 범위.

```sql
SELECT
   *
FROM
   panther_lookups.public.ipinfo_asn_datalake
WHERE 
   PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_JOIN_KEY(joinkey) = PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_JOIN_KEY('71.114.47.25')
   AND 
   PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_INT('71.114.47.25') BETWEEN 
     PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_INT(startip) 
       AND PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_INT(endip)

```

다른 테이블에 조인하려면, 위와 동일한 패턴을 따르되 로그 테이블의 IP 주소를 사용하세요.

```sql
SELECT
   log.*, 
   ipinfo.* EXCLUDE (p_schema_version,p_event_time, p_parse_time,p_log_type,p_row_id,p_source_id,p_source_label)
FROM
   panther_logs.public.panther_audit log 
     LEFT OUTER JOIN panther_lookups.public.ipinfo_asn_datalake ipinfo
   ON (
     PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_JOIN_KEY(joinkey) = PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_JOIN_KEY(log.sourceIP)
     AND 
     PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_INT(log.sourceIP) BETWEEN 
       PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_INT(startip) AND PANTHER_LOOKUPS.PUBLIC.IPINFO_TO_INT(endip)
   )
WHERE
   p_occurs_since('1 day', log)
LIMIT 10
```

## IPinfo Python 헬퍼 함수 사용법 및 메서드

Panther는 실시간 디택션 엔진에서 IPInfo 데이터를 더 쉽게 사용할 수 있도록 통합 헬퍼 함수를 제공합니다.

### Python 룰에서 IPinfo 객체 만들기

데이터셋에서 관련 데이터를 반환하기 위해 호출할 수 있는 메서드를 포함한 객체를 생성하는 헬퍼 함수가 있습니다.

다음은 이러한 객체가 생성되는 예제 코드입니다:

{% code overflow="wrap" %}

```python
from panther_ipinfo_helpers import (IPInfoASN, IPInfoLocation, geoinfo_from_ip)

def 룰(event):
    global ipinfo_location
    global ipinfo_asn
    ipinfo_location = IPInfoLocation(event) 
    ipinfo_asn = IPInfoASN(event)
```

{% endcode %}

The `global` keyword는 선언된 함수 외부에서 객체를 사용하려는 경우에만 필요합니다.

### IPinfo 객체에서 메서드 호출하기

IPinfo 데이터셋의 다양한 구성 요소는 해당 `_location` 및 `_asn` 객체의 메서드를 통해 사용할 수 있습니다. 룰이 처리하는 하나의 이벤트에 여러 필드(예: 네트워크 로그의 IP 주소, source, destination IP)가 있을 수 있습니다. IPInfo 객체를 호출할 때는 찾고자 하는 필드를 반드시 지정하세요.

아래 예제는 다음에서 모든 헬퍼 메서드를 호출하는 방법을 보여줍니다. `ipinfo_location` 및 `ipinfo_asn` 이전 예제에서 생성한 객체를 사용하여 디택션의 룰에서 사용할 수 있는 모든 보강 정보를 가져옵니다.

```python
    match_field = ""
    if event.get("p_log_type") == "AWS.Cloudtrail":
        match_field = "sourceIPAddress"
    
    if ipinfo_location:
        city = ipinfo_location.city(match_field)
        country = ipinfo_location.country(match_field)
        latitude = ipinfo_location.latitude(match_field)
        longitude = ipinfo_location.longitude(match_field)
        postal_code = ipinfo_location.postal_code(match_field)
        region = ipinfo_location.region(match_field)
        region_code = ipinfo_location.region_code(match_field)
        timezone = ipinfo_location.timezone(match_field)
    
    if ipinfo_asn:
        asn = ipinfo_asn.asn(match_field)
        domain = ipinfo_asn.domain(match_field)
        name = ipinfo_asn.name(match_field)
        route = ipinfo_asn.route(match_field)
        asn_type = ipinfo_asn._type(match_field)
```

다음 예제에서는 `geoinfo_from_ip()` 함수를 사용하며, 이는 다음과 동일한 형식의 지리 위치 정보가 포함된 딕셔너리를 반환합니다 `panther_oss_helper.geoinfo_from_ip()`를 제외하고는 제공하지 않음 `호스트명` 및 `애니캐스트` 필드.

```python
result = geoinfo_from_ip(event, "sourceIPAddress")
```

참조되는 이벤트 필드가 배열인 경우, 도우미 함수는 일치하는 값들의 배열을 반환합니다. 예를 들면:

```python
countries_of_all_ips = ipinfo_location.country('p_any_ip_addresses')
for country in countries_of_all_ips:
    if country == 'some unusual country':
        return True
```

### 사용 가능한 메서드

다음 표는 IPinfo Location, ASN 및 Privacy 객체에서 사용할 수 있는 메서드, 해당 설명, 그리고 예상 반환 값을 보여줍니다.

모든 메서드는 검색하려는 필드 인자를 받습니다.

#### 위치

<table><thead><tr><th width="185">Location 메서드</th><th width="152">반환 타입</th><th>예시</th></tr></thead><tbody><tr><td>도시</td><td>문자열</td><td>"샌프란시스코"</td></tr><tr><td>국가</td><td>문자열</td><td>"US"</td></tr><tr><td>위도</td><td>문자열</td><td>"37.7812"</td></tr><tr><td>경도</td><td>문자열</td><td>"-122.4614"</td></tr><tr><td>우편번호</td><td>문자열</td><td>"94118"</td></tr><tr><td>region</td><td>문자열</td><td>"캘리포니아"</td></tr><tr><td>지역 코드</td><td>문자열</td><td>"CA"</td></tr><tr><td>시간대</td><td>문자열</td><td>"America/Los_Angeles"</td></tr><tr><td>context</td><td>객체</td><td><p>대문자로 시작하는 메서드 이름을 키로 하여 위의 모든 필드를 포함하는 딕셔너리입니다. 예: {</p><p>"City":"샌프란시스코",<br>...</p><p>}</p></td></tr></tbody></table>

#### ASN

<table><thead><tr><th width="152">ASN 메서드</th><th width="137">반환 타입</th><th width="419">예시</th></tr></thead><tbody><tr><td>asn</td><td>문자열</td><td>"AS7018"</td></tr><tr><td>도메인</td><td>문자열</td><td>"att.com"</td></tr><tr><td>name</td><td>문자열</td><td>"AT&#x26;T Services, Inc."</td></tr><tr><td>경로</td><td>문자열</td><td>"107.128.0.0/12"</td></tr><tr><td>유형</td><td>문자열</td><td>"isp"</td></tr><tr><td>context</td><td>객체</td><td><p>대문자로 시작하는 메서드 이름을 키로 하여 위의 모든 필드를 포함하는 딕셔너리입니다. 예: {</p><p>"ASN":"AS7018",</p><p>"Domain" : "att.com",<br>...</p><p>}</p></td></tr></tbody></table>

#### 프라이버시

<table><thead><tr><th width="178.66666666666666">프라이버시 메서드</th><th width="138">반환 타입</th><th>예시</th></tr></thead><tbody><tr><td>호스팅</td><td>불리언</td><td>true</td></tr><tr><td>프록시</td><td>불리언</td><td>false</td></tr><tr><td>토르</td><td>불리언</td><td>true</td></tr><tr><td>VPN</td><td>불리언</td><td>false</td></tr><tr><td>릴레이</td><td>불리언</td><td>true</td></tr><tr><td>서비스</td><td>string</td><td>"NordVPN"</td></tr></tbody></table>


---

# 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://docs.panther.com/ko/enrichment/ipinfo.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.
