YARA-L 2.0을 사용하는 UDM 검색 및 대시보드의 조건
condition
섹션은 검색 결과에 데이터를 포함하기 위한 기준을 정의합니다.
이러한 조건은 events
섹션에 정의된 이벤트 및 자리표시자 변수에 대해 평가됩니다. and
키워드를 사용하여 이러한 조건을 결합할 수 있습니다.
제한사항
검색의 조건에는 다음과 같은 제한사항이 있습니다.
필수:
match
섹션은 필수입니다. 또는 그룹화되지 않은 필터를events
섹션 내에 직접 정의할 수 있습니다.필수: 이벤트 및 자리표시자 변수는
condition
섹션 내에서 집계되어야 합니다.정수 및 부동 소수점 비교 표현식만 지원됩니다. 이러한 표현식의 왼쪽에는 변수가 있어야 하고 오른쪽에는 정수 또는 부동 소수점이 있어야 합니다 (예:
#c > 1
,$port = 80
). 지원되는 연산자는<
,>
,=
입니다.condition
섹션 내의 변수와 절의 순서는 결과에 영향을 미치지 않습니다.condition
섹션에서 결과 변수를 사용하려면 이를 정의하고 집계하세요.events
섹션에서 집계되지 않은 결과 변수를 필터링할 수 있습니다.변수를 사용한 직접적인 수학 연산은 지원되지 않습니다 (예:
#e1 + 5 > 6
,$o1.sum($pl) > 0
).OR
조건이 동일한 기본 이벤트에 적용되는 경우 추가 제한사항은 없습니다.OR
이 여러 이벤트에서 사용되는 경우 다음 제한사항이 적용됩니다.OR
에서는 비존재 비교가 지원되지 않습니다. 예를 들어math.log($outcome1_sent_bytes) > 5 OR (#placeholder2) < 10
는 지원되지 않습니다.UDM이 아닌 변수는 서로 다른 이벤트에 걸쳐 있는
OR
절에서 지원되지 않습니다. 하지만OR
는 단일 이벤트 컨텍스트 내에서 또는AND
와 그룹화된 경우 지원됩니다. 예를 들면$entity and ($udm_event_1 or $placeholder_derived_from_udm_event_1)
입니다. 또 다른 예로$entity and ($udm_event_1 or $outcome_udm_event_1_bytes > 1000)
를 들 수 있습니다.
카운트 문자 (#
)
#
문자는 이벤트 또는 자리표시자 변수 이름 (예: #c
) 앞에 사용될 경우 해당 이벤트의 고유 어커런스 수 또는 해당 변수와 연결된 events
섹션의 모든 조건을 충족하는 고유 값 수를 나타냅니다. 예를 들어 #c > 1
은 이벤트 또는 자리표시자 c
가 두 번 이상 발생해야 함을 의미합니다.
샘플 쿼리:
$e1.principal.hostname = $hostname
$e1.target.hostname = "fedex.com"
$e1.target.port = 3042 // tcp/udp
$e2.principal.hostname = $hostname
$e2.target.hostname = "homedepot.com"
$e2.target.port = 3042 // tcp/udp
match:
$hostname over 1h
condition:
#e1 > 0 or #e2 > 1
값 문자 ($
)
$
문자의 기능은 컨텍스트에 따라 다릅니다.
결과 변수: 결과 변수 이름 (예:
$risk_score
) 앞에 배치되면 변수의 값을 나타냅니다.이벤트 또는 자리표시자 변수: 이벤트 또는 자리표시자 변수 이름 (예:
$event
) 앞에 배치되면#event > 0
와 동일하며 해당 이벤트가 한 번 이상 발생해야 함을 의미합니다.
이벤트 및 자리표시자 조건
and
키워드를 사용하여 이벤트 및 자리표시자 변수의 여러 조건 조건자를 결합할 수 있습니다.
or
사용 예 (단일 이벤트):
condition:
$ph2 and $ph3
중요: events
또는 condition
섹션에 로직을 작성할 때는 부정에 !
를 사용하세요. outcome
섹션에서만 not
키워드를 사용합니다.
바운드 및 언바운드 조건
이벤트 변수 조건은 제한되거나 제한되지 않을 수 있습니다.
바운드 조건에는 연결된 이벤트 변수가 있어야 합니다. 즉, 어떤 감지 항목에서든 이벤트가 하나 이상 표시되어야 합니다.
예:
$var
(#var > 0
과 같음)#var > n
(n >= 0
인 경우)#var >= m
(m > 0
인 경우)
샘플 쿼리:
$e1.principal.hostname = $hostname
$e1.target.hostname = "fedex.com"
match:
$hostname over 1h
condition:
#e1 > 0
제한되지 않은 조건을 사용하면 연결된 이벤트 변수가 존재하지 않아도 됩니다. 즉, 감지 항목에 이벤트가 표시되지 않아도 됩니다. 이벤트 변수의 필드에 대한 모든 참조는 0 값을 생성합니다. 존재하지 않는 항목을 검색할 때 사용합니다.
예:
!$var
(#var = 0
과 같음)#var >= 0
#var < n
(n > 0
인 경우)#var <= m
(m >= 0
인 경우)
샘플 쿼리:
$e1.principal.hostname = $hostname
$e1.target.hostname = "fedex.com"
$e1.target.port = 3042 // tcp/udp
match:
$hostname over 1h
outcome:
$bytes_sent = sum($e1.network.sent_bytes)
condition:
$bytes_sent >= 0
참고: 존재하지 않는 검색어 (무한 조건 사용)의 경우 감지 엔진이 예상 지연 시간에 1시간 지연을 추가합니다.
무한 조건이 있는 검색어는 다음 기준을 충족해야 합니다.
하나 이상의 UDM 이벤트에 제한된 조건이 있어야 합니다. 즉, 하나 이상의 UDM 이벤트가 있어야 합니다.
제한되지 않은 조건이 있는 자리표시자는 하나 이상의 제한된 UDM 이벤트와 연결되어야 합니다.
제한되지 않은 조건이 있는 항목은 하나 이상의 제한된 UDM 이벤트와 연결되어야 합니다.
결과 조건
결과 변수를 사용하여 결과 조건을 정의하고 논리 연산자 (and
, or
, not
)와 결합할 수 있습니다. 비교 구문은 결과 변수의 데이터 유형에 따라 다릅니다.
- 정수 및 부동 소수점:
=
,>
,>=
,<
,<=
,!=
을 사용합니다 (예:$risk_score > 10
,$risk_score <= 5.5
). - 문자열:
=
또는!=
(예:$severity = "HIGH"
)을 사용합니다. - 정수 또는 배열 목록:
arrays.contains()
를 사용합니다 (예:arrays.contains($event_ids, "id_1234")
).
샘플 쿼리:
$e1.principal.hostname = $hostname
$e1.target.hostname = "fedex.com"
$e1.target.port = 3042 // tcp/udp
match:
$hostname over 1h
outcome:
$bytes_sent = sum($e1.network.sent_bytes)
condition:
$e1
UDM 검색의 X 조건 중 N
UDM 검색 조건은 'X 중 N' 구문을 지원하므로 여러 기준을 유연하게 평가할 수 있습니다. 이 구문을 사용하면 X
(불리언 표현식 목록) 중 N
(특정 숫자)이 true로 평가되는 경우 조건을 충족하도록 지정할 수 있습니다.
예: VirusTotal (VT) 보강에서 제공하는 사전 정의된 태그 목록에서 여러 의심스러운 동작을 보이지만 반드시 모든 동작을 보이는 것은 아닌 프로세스를 식별하려는 시나리오를 고려해 보세요. 'X 중 N' 구문은 충족해야 하는 최소 조건 수를 지정할 수 있어 이 문제를 해결합니다.
다음 UDM 검색 쿼리는 조건 중 3개 이상이 참인 프로세스를 찾습니다.
$e.metadata.event_type = "PROCESS_LAUNCH"
$e.target.process.file.full_path = $process
match:
$process
outcome:
$first_seen = earliest($e.metadata.event_timestamp)
$last_seen = latest($e.metadata.event_timestamp)
$total_events = count($e.metadata.id)
// Collect all unique tags associated with this process from all its launch events
$tags = array_distinct($e.target.process.file.tags)
condition:
// Trigger if at least 3 of the following conditions (tag checks) are true
3 of [
arrays.contains($tags, "malware"),
arrays.contains($tags, "detect-debug-environment"),
arrays.contains($tags, "checks-disk-space"),
arrays.contains($tags, "checks-cpu-name"),
arrays.contains($tags, "invalid-signature"),
arrays.contains($tags, "self-delete")
]
order:
$total_events desc
ANY of 및 ALL of 연산자
나열된 불리언 표현식 중 하나 이상이 true
이면 ANY of [expressions]
은 true
로 평가됩니다. ALL of [expressions]
에서는 나열된 모든 표현식이 true
여야 합니다. AND
와 같은 키워드를 사용하여 이러한 연산자를 다른 조건과 결합합니다.
예:
$e.metadata.event_type = "PROCESS_LAUNCH"
$e.target.process.file.full_path = $process
match:
$process
outcome:
$first_seen = timestamp.get_timestamp(min($e.metadata.event_timestamp.seconds))
$last_seen = timestamp.get_timestamp(max($e.metadata.event_timestamp.seconds))
$total = count($e.metadata.id)
$tags = array_distinct($e.target.process.file.tags)
$vt_first_seen_time = max(if((timestamp.current_seconds() - $e.target.process.file.first_seen_time.seconds) < 86400, 1 , 0))
$vt_last_analysis_time = max(if((timestamp.current_seconds() - $e.target.process.file.last_analysis_time.seconds) < 86400, 1 , 0))
$vt_last_modification_time = max(if((timestamp.current_seconds() - $e.target.process.file.last_modification_time.seconds) < 86400, 1 , 0))
$vt_last_seen_time = max(if((timestamp.current_seconds() - $e.target.process.file.last_seen_time.seconds) < 86400, 1 , 0))
condition:
3 of [
arrays.contains($tags, "malware"),
arrays.contains($tags, "detect-debug-environment"),
arrays.contains($tags, "checks-disk-space"),
arrays.contains($tags, "checks-cpu-name"),
arrays.contains($tags, "invalid-signature"),
arrays.contains($tags, "self-delete")
]
and ANY of [
$vt_first_seen_time = 1,
$vt_last_analysis_time = 1,
$vt_last_modification_time = 1,
$vt_last_seen_time = 1
]
order:
$total desc
unselect:
$vt_first_seen_time,
$vt_last_analysis_time,
$vt_last_modification_time,
$vt_last_seen_time
도움이 더 필요하신가요? 커뮤니티 회원 및 Google SecOps 전문가로부터 답변을 받으세요.