Ringkasan tentang bahasa YARA-L 2.0
YARA-L 2.0 adalah bahasa komputer yang digunakan untuk membuat aturan penelusuran data log perusahaan yang diserap ke instance Google Security Operations Anda. Sintaksis YARA-L berasal dari bahasa YARA yang dikembangkan oleh VirusTotal. Bahasa ini bekerja bersama dengan Mesin Deteksi Google SecOps dan memungkinkan Anda memburu ancaman dan peristiwa lainnya di seluruh data dalam jumlah besar.
Untuk informasi selengkapnya, lihat referensi berikut:
Contoh aturan YARA-L 2.0
Contoh berikut menunjukkan aturan yang ditulis dalam YARA-L 2.0. Setiap contoh menunjukkan cara mengorelasikan peristiwa dalam bahasa aturan.
Aturan dan penyetelan
Aturan berikut memeriksa pola tertentu dalam data peristiwa dan membuat deteksi jika menemukan pola tersebut. Aturan ini mencakup variabel $e1
untuk melacak jenis peristiwa dan kolom UDM metadata.event_type
. Aturan ini memeriksa kemunculan tertentu
dari kecocokan ekspresi reguler dengan e1
. Saat peristiwa $e1
terjadi, deteksi akan dibuat.
Kondisi not
disertakan dalam aturan untuk mengecualikan jalur non-berbahaya tertentu.
Anda dapat menambahkan not
kondisi untuk mencegah positif palsu.
rule suspicious_unusual_location_svchost_execution
{
meta:
author = "Google Cloud Security"
description = "Windows 'svchost' executed from an unusual location"
yara_version = "YL2.0"
rule_version = "1.0"
events:
$e1.metadata.event_type = "PROCESS_LAUNCH"
re.regex($e1.principal.process.command_line, `\bsvchost(\.exe)?\b`) nocase
not re.regex($e1.principal.process.command_line, `\\Windows\\System32\\`) nocase
condition:
$e1
}
Login dari kota yang berbeda
Aturan berikut menelusuri pengguna yang telah login ke perusahaan Anda dari dua kota atau lebih dalam waktu kurang dari 5 menit:
rule DifferentCityLogin {
meta:
events:
$udm.metadata.event_type = "USER_LOGIN"
$udm.principal.user.userid = $user
$udm.principal.location.city = $city
match:
$user over 5m
condition:
$udm and #city > 1
}
Variabel kecocokan: $user
Variabel peristiwa:$udm
Variabel placeholder: $city
dan $user
Berikut cara kerja aturan ini:
- Mengelompokkan peristiwa dengan nama pengguna (
$user
) dan menampilkannya ($user
) saat kecocokan ditemukan. - Rentang waktu adalah 5 menit, yang berarti hanya peristiwa yang berjarak kurang dari 5 menit yang berkorelasi.
- Menelusuri grup peristiwa (
$udm
) yang jenis peristiwanya adalah USER_LOGIN. - Untuk grup peristiwa tersebut, aturan memanggil ID pengguna sebagai
$user
dan kota login sebagai$city.
- Menampilkan kecocokan jika jumlah nilai
city
yang berbeda (ditandai dengan#city
) lebih besar dari 1 dalam grup peristiwa ($udm
) dalam rentang waktu 5 menit.
Pembuatan dan penghapusan pengguna yang cepat
Aturan berikut menelusuri pengguna yang telah dibuat lalu dihapus dalam waktu 4 jam:
rule UserCreationThenDeletion {
meta:
events:
$create.target.user.userid = $user
$create.metadata.event_type = "USER_CREATION"
$delete.target.user.userid = $user
$delete.metadata.event_type = "USER_DELETION"
$create.metadata.event_timestamp.seconds <=
$delete.metadata.event_timestamp.seconds
match:
$user over 4h
condition:
$create and $delete
}
Variabel peristiwa:$create
dan $delete
Variabel kecocokan: $user
Variabel placeholder: T/A
Berikut cara kerja aturan ini:
- Mengelompokkan peristiwa dengan nama pengguna (
$user
) dan menampilkannya ($user
) saat kecocokan ditemukan. - Jendela waktu adalah 4 jam, yang berarti hanya peristiwa yang terpisah kurang dari 4 jam yang dikorelasikan.
- Menelusuri dua grup peristiwa (
$create
dan$delete
, dengan$create
setara dengan#create >= 1
). $create
sesuai dengan peristiwaUSER_CREATION
dan memanggil ID pengguna sebagai$user
.$user
digunakan untuk menggabungkan kedua grup peristiwa.$delete
sesuai dengan peristiwaUSER_DELETION
dan memanggil ID pengguna sebagai$user
. Aturan ini mencari kecocokan saat ID pengguna di kedua grup peristiwa sama.- Aturan ini mencari kasus saat peristiwa dari
$delete
terjadi setelah peristiwa dari$create
, dan menampilkan kecocokan saat ditemukan.
Aturan acara tunggal
Aturan peristiwa tunggal adalah aturan yang berkorelasi dengan satu peristiwa. Satu aturan peristiwa dapat berupa:
- Aturan apa pun tanpa bagian kecocokan.
- Aturan dengan bagian
match
dan bagiancondition
yang hanya memeriksa keberadaan 1 peristiwa (misalnya, "$e", "#e > 0", "#e >= 1", "1 <= #e", "0 < #e").
Misalnya, aturan berikut menelusuri peristiwa login pengguna dan akan menampilkan peristiwa pertama yang ditemukannya dalam data perusahaan yang disimpan di akun Google SecOps Anda:
rule SingleEventRule {
meta:
author = "noone@altostrat.com"
events:
$e.metadata.event_type = "USER_LOGIN"
condition:
$e
}
Berikut contoh lain aturan peristiwa tunggal dengan bagian kecocokan. Aturan ini menelusuri pengguna yang telah login setidaknya sekali dalam waktu kurang dari 5 menit. Opsi ini memeriksa keberadaan sederhana peristiwa login pengguna.
rule SingleEventRule {
meta:
author = "alice@example.com"
description = "windowed single event example rule"
events:
$e.metadata.event_type = "USER_LOGIN"
$e.principal.user.userid = $user
match:
$user over 5m
condition:
#e > 0
}
rule MultiEventRule{
meta:
author = "alice@example.com"
description = "Rule with outcome condition and simple existence condition on one event variable"
events:
$e.metadata.event_type = "USER_LOGIN"
$e.principal.user.userid = $user
match:
$user over 10m
outcome:
$num_events_in_match_window = count($e.metadata.id)
condition:
#e > 0 and $num_events_in_match_window >= 10 // Could be rewritten as #e >= 10
}
Beberapa aturan acara
Gunakan beberapa aturan peristiwa untuk mengelompokkan banyak peristiwa selama jangka waktu tertentu dan mencoba menemukan korelasi antar-peristiwa. Aturan beberapa peristiwa yang umum akan memiliki hal berikut:
- Bagian
match
yang menentukan rentang waktu pengelompokan peristiwa. - Bagian
condition
yang menentukan kondisi yang harus memicu deteksi dan memeriksa keberadaan beberapa peristiwa.
Misalnya, aturan berikut menelusuri pengguna yang telah login setidaknya 10 kali dalam waktu kurang dari 10 menit:
rule MultiEventRule {
meta:
author = "noone@altostrat.com"
events:
$e.metadata.event_type = "USER_LOGIN"
$e.principal.user.userid = $user
match:
$user over 10m
condition:
#e >= 10
}
Satu peristiwa dalam rentang alamat IP
Contoh berikut menunjukkan satu aturan peristiwa yang menelusuri kecocokan antara dua nama host tertentu dan rentang alamat IP tertentu:
rule OrsAndNetworkRange {
meta:
author = "noone@altostrat.com"
events:
// Checks CIDR ranges.
net.ip_in_range_cidr($e.principal.ip, "203.0.113.0/24")
// Detection when the hostname field matches either value using or.
$e.principal.hostname = /pbateman/ or $e.principal.hostname = /sspade/
condition:
$e
}
contoh aturan apa pun dan semua
Aturan berikut menelusuri peristiwa login saat semua alamat IP sumber tidak cocok dengan alamat IP yang diketahui aman dalam rentang waktu 5 menit.
rule SuspiciousIPLogins {
meta:
author = "alice@example.com"
events:
$e.metadata.event_type = "USER_LOGIN"
// Detects if all source IP addresses in an event do not match "100.97.16.0"
// For example, if an event has source IP addresses
// ["100.97.16.1", "100.97.16.2", "100.97.16.3"],
// it will be detected since "100.97.16.1", "100.97.16.2",
// and "100.97.16.3" all do not match "100.97.16.0".
all $e.principal.ip != "100.97.16.0"
// Assigns placeholder variable $ip to the $e.principal.ip repeated field.
// There will be one detection per source IP address.
// For example, if an event has source IP addresses
// ["100.97.16.1", "100.97.16.2", "100.97.16.3"],
// there will be one detection per address.
$e.principal.ip = $ip
match:
$ip over 5m
condition:
$e
}
Regular expression dalam aturan
Contoh ekspresi reguler YARA-L 2.0 berikut menelusuri peristiwa dengan email yang diterima dari domain altostrat.com. Karena nocase
telah ditambahkan ke perbandingan regex
variabel $host
dan fungsi regex
, kedua perbandingan ini tidak peka huruf besar/kecil.
rule RegexRuleExample {
meta:
author = "noone@altostrat.com"
events:
$e.principal.hostname = $host
$host = /.*HoSt.*/ nocase
re.regex($e.network.email.from, `.*altostrat\.com`) nocase
match:
$host over 10m
condition:
#e > 10
}
Contoh aturan komposit
Deteksi gabungan meningkatkan deteksi ancaman dengan menggunakan aturan gabungan. Aturan gabungan ini menggunakan deteksi dari aturan lain sebagai inputnya. Hal ini memungkinkan deteksi ancaman kompleks yang mungkin tidak terdeteksi oleh aturan individual. Untuk informasi selengkapnya, lihat Ringkasan deteksi komposit.
Deteksi kawat jebakan
Deteksi gabungan tripwire adalah bentuk paling sederhana dari deteksi gabungan yang beroperasi pada kolom dalam temuan deteksi, seperti variabel hasil atau metadata aturan. Filter ini membantu memfilter deteksi untuk kondisi yang dapat menunjukkan risiko lebih tinggi, seperti pengguna administrator atau lingkungan produksi.
rule composite_admin_detection {
meta:
rule_name = "Detection with Admin User"
author = "Google Cloud Security"
description = "Composite rule that looks for any detections where the actor is an admin user"
severity = "Medium"
events:
$rule_name = $d.detection.detection.rule_name
$principal_user = $d.detection.detection.outcomes["principal_users"]
$principal_user = /admin|root/ nocase
match:
$principal_user over 1h
outcome:
$risk_score = 75
$upstream_rules = array_distinct($rule_name)
condition:
$d
}
Deteksi Nilai Minimum dan Agregasi
Aturan deteksi komposit agregasi memungkinkan Anda mengelompokkan temuan deteksi berdasarkan atribut bersama, seperti nama host atau nama pengguna, dan menganalisis data gabungan. Berikut adalah kasus penggunaan umum:
- Mengidentifikasi pengguna yang menghasilkan volume tinggi peringatan keamanan atau risiko gabungan.
- Mendeteksi host dengan pola aktivitas yang tidak biasa dengan menggabungkan deteksi terkait.
Contoh agregasi risiko:
rule composite_risk_aggregation {
meta:
rule_name = "Risk Aggregation Composite"
author = "Google Cloud Security"
description = "Composite detection that aggregates risk of a user over 48 hours"
severity = "High"
events:
$rule_name = $d.detection.detection.rule_name
$principal_user = $d.detection.detection.outcomes["principal_users"]
$risk = $d.detection.detection.risk_score
match:
$principal_user over 48h
outcome:
$risk_score = 90
$cumulative_risk = sum($risk)
$principal_users = array_distinct($principal_users)
$upstream_rules = array_distinct($rule_name)
condition:
$d and $cumulative_risk > 500
}
Contoh agregasi taktik:
rule composite_tactic_aggregation {
meta:
rule_name = "MITRE Tactic Aggregation Composite"
author = "Google Cloud Security"
description = "Composite detection that detects if a user has triggered detections over multiple mitre tactics."
severity = "Medium"
events:
$principal_user = $d.detection.detection.outcomes["principal_users"]
$tactic = $d.detection.detection.rule_labels["tactic"]
$rule_name = $d.detection.detection.rule_name
match:
$principal_user over 48h
outcome:
$mitre_tactics_count = count_distinct($tactic)
$mitre_tactics = array_distinct($d.detection.rule_labels["tactic"])
$risk_score = min(100, (50+15*$mitre_tactics_count))
$upstream_rules = array_distinct($rule_name)
condition:
$d and $mitre_tactics_count > 1
}
Deteksi gabungan berurutan
Deteksi komposit berurutan mengidentifikasi pola peristiwa terkait yang urutan deteksinya penting, seperti deteksi upaya login brute force yang diikuti dengan login yang berhasil. Pola ini dapat melibatkan beberapa deteksi dasar atau kombinasi deteksi dasar dan peristiwa.
rule composite_bruteforce_login {
meta:
rule_name = "Bruteforce Login Composite"
author = "Google Cloud Security"
description = "Detects when an IP address associated with a Workspace brute force attempt successfully logs in"
severity = "High"
events:
$bruteforce_detection.detection.detection.rule_name = /Workspace Anomalous Failed Logins/
$bruteforce_ip = $d.detection.detection.outcomes["principal_ips"]
$login_event.metadata.product_name = "login"
$login_event.metadata.product_event_type = "login_success"
$login_event.metadata.vendor_name = "Google Workspace"
$login_ip = $login_event.principal.ip
// Ensure the brute force detection and successful login occurred from the same IP
$login_ip = $bruteforce_ip
$target_account = $login_event.target.user.email_addresses
// Ensure the brute force detection occurred before the successful login
$bruteforce_detection.detection.detection_time.seconds < $login_event.metadata.event_timestamp.seconds
match:
$bruteforce_ip over 24h
outcome:
$risk_score = 90
$principal_users = array_distinct($target_account)
condition:
$bruteforce_detection and $login_event
}
Deteksi kontekstual
Deteksi komposit yang sadar konteks memperkaya deteksi dengan konteks tambahan, seperti alamat IP yang ditemukan di feed ancaman.
rule composite_tor_enrichment {
meta:
rule_name = "Detection with IP from TOR Feed"
author = "Google Cloud Security"
description = "Adds additional context from the TOR intel feed to detections"
severity = "High"
events:
$detection_ip = $d.detection.detection.outcomes["principal_ips"]
$gcti.graph.metadata.entity_type = "IP_ADDRESS"
$gcti.graph.metadata.vendor_name = "Google Cloud Threat Intelligence"
$gcti_feed.graph.metadata.source_type = "GLOBAL_CONTEXT"
$gcti.graph.metadata.product_name = "GCTI Feed"
$gcti.graph.metadata.threat.threat_feed_name = "Tor Exit Nodes"
$detection_ip = $gcti.graph.entity.ip
$rule_name = $d.detection.detection.rule_name
$risk = $d.detection.detection.outcomes["risk_score"]
match:
$detection_ip, $rule_name over 1h
outcome:
$risk_score = 80
$upstream_rule = array_distinct($rule_name)
condition:
$d and $gcti
}
Deteksi kemunculan bersama
Deteksi komposit ko-okurensi adalah bentuk agregasi yang dapat mendeteksi kombinasi peristiwa terkait, seperti kombinasi deteksi eskalasi hak istimewa dan eksfiltrasi data yang dipicu oleh pengguna.
rule composite_privesc_exfil_sequential {
meta:
rule_name = "Privilege Escalation and Exfiltration Composite"
author = "Google Cloud Security"
description = "Looks for a detection sequence of privilege escalation followed by exfiltration."
severity = "High"
events:
$privilege_escalation.detection.detection.rule_labels["tactic"] = "TA0004"
$exfiltration.detection.detection.rule_labels["tactic"] = "TA0010"
$pe_user = $privilege_escalation.detection.detection.outcomes["principal_users"]
$ex_user = $exfiltration.detection.detection.outcomes["principal_users"]
$pe_user = $ex_user
match:
$pe_user over 48h
outcome:
$risk_score = 75
$privesc_rules = array_distinct($privilege_escalation.detection.detection.rule_name)
$exfil_rules = array_distinct($exfiltration.detection.detection.rule_name)
condition:
$privilege_escalation and $exfiltration
}
Contoh aturan jendela geser
Contoh jendela geser YARA-L 2.0 berikut menelusuri tidak adanya peristiwa firewall_2
setelah peristiwa firewall_1
. Kata kunci after
digunakan dengan
variabel peristiwa titik pusat $e1
untuk menentukan bahwa hanya periode 10 menit setelah setiap
peristiwa firewall_1
yang harus diperiksa saat mengorelasikan peristiwa.
rule SlidingWindowRuleExample {
meta:
author = "alice@example.com"
events:
$e1.metadata.product_name = "firewall_1"
$e1.principal.hostname = $host
$e2.metadata.product_name = "firewall_2"
$e2.principal.hostname = $host
match:
$host over 10m after $e1
condition:
$e1 and !$e2
}
Contoh pengecualian nilai nol
Mesin Aturan secara implisit memfilter nilai nol untuk semua placeholder
yang digunakan di bagian match
.
Untuk mengetahui informasi selengkapnya, lihat penanganan nilai nol di bagian match
.
Hal ini dapat dinonaktifkan menggunakan opsi allow_zero_values
seperti yang dijelaskan di allow_zero_values.
Namun, untuk kolom peristiwa lain yang dirujuk, nilai nol tidak dikecualikan kecuali jika Anda secara eksplisit menentukan kondisi tersebut.
rule ExcludeZeroValues {
meta:
author = "alice@example.com"
events:
$e1.metadata.event_type = "NETWORK_DNS"
$e1.principal.hostname = $hostname
// $e1.principal.user.userid may be empty string.
$e1.principal.user.userid != "Guest"
$e2.metadata.event_type = "NETWORK_HTTP"
$e2.principal.hostname = $hostname
// $e2.target.asset_id cannot be empty string as explicitly specified.
$e2.target.asset_id != ""
match:
// $hostname cannot be empty string. The rule behaves as if the
// predicate, `$hostname != ""` was added to the events section, because
// `$hostname` is used in the match section.
$hostname over 1h
condition:
$e1 and $e2
}
Contoh aturan dengan bagian outcome
Anda dapat menambahkan bagian outcome
opsional dalam aturan YARA-L 2.0 untuk mengekstrak
informasi tambahan dari setiap deteksi. Di bagian kondisi, Anda juga dapat menentukan
kondisional pada variabel hasil. Anda dapat menggunakan bagian outcome
dari aturan
deteksi untuk menetapkan variabel untuk penggunaan hilir. Misalnya, Anda dapat menetapkan skor tingkat keparahan berdasarkan data dari peristiwa yang dianalisis.
Untuk informasi selengkapnya, lihat referensi berikut:
Aturan multi-peristiwa dengan bagian hasil:
Aturan berikut melihat dua peristiwa untuk mendapatkan nilai
$hostname
. Jika nilai $hostname
cocok selama periode 5 menit,
skor tingkat keparahan akan diterapkan. Saat menyertakan jangka waktu di bagian match
,
aturan akan memeriksa dalam jangka waktu yang ditentukan.
rule OutcomeRuleMultiEvent {
meta:
author = "Google Cloud Security"
events:
$u.udm.principal.hostname = $hostname
$asset_context.graph.entity.hostname = $hostname
$severity = $asset_context.graph.entity.asset.vulnerabilities.severity
match:
$hostname over 5m
outcome:
$risk_score =
max(
100
+ if($hostname = "my-hostname", 100, 50)
+ if($severity = "HIGH", 10)
+ if($severity = "MEDIUM", 5)
+ if($severity = "LOW", 1)
)
$asset_id_list =
array(
if($u.principal.asset_id = "",
"Empty asset id",
$u.principal.asset_id
)
)
$asset_id_distinct_list = array_distinct($u.principal.asset_id)
$asset_id_count = count($u.principal.asset_id)
$asset_id_distinct_count = count_distinct($u.principal.asset_id)
condition:
$u and $asset_context and $risk_score > 50 and not arrays.contains($asset_id_list, "id_1234")
}
rule OutcomeRuleMultiEvent {
meta:
author = "alice@example.com"
events:
$u.udm.principal.hostname = $hostname
$asset_context.graph.entity.hostname = $hostname
$severity = $asset_context.graph.entity.asset.vulnerabilities.severity
match:
$hostname over 5m
outcome:
$total_network_bytes = sum($u.network.sent_bytes) + sum($u.network.received_bytes)
$risk_score = if(total_network_bytes > 1024, 100, 50) +
max(
if($severity = "HIGH", 10)
+ if($severity = "MEDIUM", 5)
+ if($severity = "LOW", 1)
)
$asset_id_list =
array(
if($u.principal.asset_id = "",
"Empty asset id",
$u.principal.asset_id
)
)
$asset_id_distinct_list = array_distinct($u.principal.asset_id)
$asset_id_count = count($u.principal.asset_id)
$asset_id_distinct_count = count_distinct($u.principal.asset_id)
condition:
$u and $asset_context and $risk_score > 50 and not arrays.contains($asset_id_list, "id_1234")
}
Aturan peristiwa tunggal dengan bagian hasil:
rule OutcomeRuleSingleEvent {
meta:
author = "alice@example.com"
events:
$u.metadata.event_type = "FILE_COPY"
$u.principal.file.size = $file_size
$u.principal.hostname = $hostname
outcome:
$suspicious_host = $hostname
$admin_severity = if($u.principal.userid in %admin_users, "SEVERE", "MODERATE")
$severity_tag = if($file_size > 1024, $admin_severity, "LOW")
condition:
$u
}
Memfaktorkan ulang aturan hasil multi-peristiwa menjadi aturan hasil peristiwa tunggal.
Anda dapat menggunakan bagian outcome
untuk aturan peristiwa tunggal (aturan tanpa bagian
match
), dan aturan multi-peristiwa (aturan dengan bagian match
).
Jika sebelumnya Anda mendesain aturan multi-acara hanya agar dapat menggunakan bagian hasil, Anda dapat secara opsional memfaktorkan ulang aturan tersebut dengan menghapus bagian match
untuk meningkatkan performa. Perlu diketahui bahwa karena aturan Anda tidak
lagi memiliki bagian match
yang menerapkan pengelompokan,
Anda mungkin menerima lebih banyak deteksi. Refaktor ini hanya
mungkin dilakukan untuk aturan yang menggunakan satu variabel peristiwa seperti yang ditunjukkan dalam
contoh berikut.
Aturan hasil multi-peristiwa yang hanya menggunakan satu variabel peristiwa (kandidat yang baik untuk refaktor):
rule OutcomeMultiEventPreRefactor {
meta:
author = "alice@example.com"
description = "Outcome refactor rule, before the refactor"
events:
$u.udm.principal.hostname = $hostname
match:
$hostname over 5m
outcome:
$risk_score = max(if($hostname = "my-hostname", 100, 50))
condition:
$u
}
Anda dapat memfaktorkan ulang aturan dengan menghapus bagian match
. Perhatikan bahwa Anda
juga harus menghapus agregat di bagian outcome
karena aturan sekarang akan menjadi
peristiwa tunggal. Untuk mengetahui informasi selengkapnya tentang agregasi, lihat agregasi hasil.
rule OutcomeSingleEventPostRefactor {
meta:
author = "alice@example.com"
description = "Outcome refactor rule, after the refactor"
events:
$u.udm.principal.hostname = $hostname
// We deleted the match section.
outcome:
// We removed the max() aggregate.
$risk_score = if($hostname = "my-hostname", 100, 50)
condition:
$u
}
Contoh aturan fungsi ke placeholder
Anda dapat menetapkan variabel placeholder ke hasil panggilan fungsi dan dapat menggunakan variabel placeholder di bagian lain aturan, seperti bagian match
, bagian outcome
, atau bagian condition
. Lihat contoh berikut:
rule FunctionToPlaceholderRule {
meta:
author = "alice@example.com"
description = "Rule that uses function to placeholder assignments"
events:
$u.metadata.event_type = "EMAIL_TRANSACTION"
// Use function-placeholder assignment to extract the
// address from an email.
// address@website.com -> address
$email_to_address_only = re.capture($u.network.email.from , "(.*)@")
// Use function-placeholder assignment to normalize an email:
// uid@??? -> uid@company.com
$email_from_normalized = strings.concat(
re.capture($u.network.email.from , "(.*)@"),
"@company.com"
)
// Use function-placeholder assignment to get the day of the week of the event.
// 1 = Sunday, 7 = Saturday.
$dayofweek = timestamp.get_day_of_week($u.metadata.event_timestamp.seconds)
match:
// Use placeholder (from function-placeholder assignment) in match section.
// Group by the normalized from email, and expose it in the detection.
$email_from_normalized over 5m
outcome:
// Use placeholder (from function-placeholder assignment) in outcome section.
// Assign more risk if the event happened on weekend.
$risk_score = max(
if($dayofweek = 1, 10, 0) +
if($dayofweek = 7, 10, 0)
)
condition:
// Use placeholder (from function-placeholder assignment) in condition section.
// Match if an email was sent to multiple addresses.
#email_to_address_only > 1
}
Contoh aturan bersyarat hasil
Di bagian condition
, Anda dapat menggunakan variabel hasil yang ditentukan
di bagian outcome
. Contoh berikut menunjukkan cara memfilter skor risiko untuk mengurangi derau dalam deteksi menggunakan kondisi hasil.
rule OutcomeConditionalRule {
meta:
author = "alice@example.com"
description = "Rule that uses outcome conditionals"
events:
$u.metadata.event_type = "FILE_COPY"
$u.principal.file.size = $file_size
$u.principal.hostname = $hostname
// 1 = Sunday, 7 = Saturday.
$dayofweek = timestamp.get_day_of_week($u.metadata.collected_timestamp.seconds)
outcome:
$risk_score =
if($file_size > 500*1024*1024, 2) + // Files 500MB are moderately risky
if($file_size > 1024*1024*1024, 3) + // Files over 1G get assigned extra risk
if($dayofweek=1 or $dayofweek=7, 4) + // Events from the weekend are suspicious
if($hostname = /highly-privileged/, 5) // Check for files from highly privileged devices
condition:
$u and $risk_score >= 10
}
Perlu bantuan lain? Dapatkan jawaban dari anggota Komunitas dan profesional Google SecOps.