strawberry/config/example_rules.yar
trvon 97e21ee81b
Triage findings and cut routine false positives
Triage of all 26 findings on a developer workstation (none malicious)
is in docs/false-positives.md: binaries replaced while running
(auto-updates, reinstalls), Strawberry's own installer writing its
systemd units, sanitizer/self-debugging ptrace, deliberate tests, and
the test marker matching process memory.

Fixes:
- behavior detections now honor path and rule allowlist entries (they
  only checked sha256, which is computed for high severity only)
- finding summaries include what happened (file written, ptrace
  target) and metadata.details
- Strawberry_Test_Marker only matches files that start with the marker
  (EICAR-style); it no longer fires on processes holding the text
- ptrace between a parent and child running the same binary
  (LeakSanitizer StopTheWorld) is low instead of medium; ProcessRef
  carries the parent pid

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 20:56:35 -06:00

109 lines
3.5 KiB
Text

/*
* Strawberry starter rules.
*
* Kept deliberately small and high-signal so a first run with
* scan_existing_processes_on_start=true does not flood the database with
* matches on ordinary system binaries. For real coverage, add a maintained
* rule set next to this file, e.g.:
* - YARA Forge "core" bundle https://github.com/YARAHQ/yara-forge
* - Elastic protections-artifacts (Linux rules)
* https://github.com/elastic/protections-artifacts/tree/main/yara/rules
*
* Every rule should set meta.severity (critical/high/medium/low); Strawberry
* stores it on each hit and defaults to "medium" when it is missing.
*/
import "elf"
// End-to-end check (EICAR-style): a file that starts with the marker, e.g.
// printf 'STRAWBERRY-TEST-MARKER-7f3a9c\n' > /tmp/sb-test && strawberry --scan-file /tmp/sb-test
// The marker must be in the first 256 bytes. In process-memory scans YARA
// offsets are virtual addresses, so the rule never fires on processes that
// merely hold the text (editors, terminals, chat tools).
rule Strawberry_Test_Marker {
meta:
description = "Harmless marker used to verify the scanner end to end"
author = "Strawberry"
severity = "low"
strings:
$marker = "STRAWBERRY-TEST-MARKER-7f3a9c"
condition:
$marker in (0..256)
}
rule Linux_CryptoMiner_XMRig {
meta:
description = "XMRig-style cryptocurrency miner"
author = "Strawberry"
severity = "high"
strings:
$stratum = "stratum+tcp://" ascii
$stratum_ssl = "stratum+ssl://" ascii
$xmrig = "xmrig" ascii nocase
$donate = "--donate-level" ascii
$randomx = "randomx" ascii nocase
$pool = "pool_wallet" ascii
$nicehash = "nicehash" ascii nocase
condition:
uint32(0) == 0x464c457f
and 1 of ($stratum*)
and 2 of ($xmrig, $donate, $randomx, $pool, $nicehash)
}
rule Linux_ReverseShell_Strings {
meta:
description = "Executable embeds a classic interactive reverse-shell command"
author = "Strawberry"
severity = "high"
strings:
$bash_tcp = /bash -i\s*>&\s*\/dev\/tcp\// ascii
$sh_tcp = /sh -i\s*>&\s*\/dev\/tcp\// ascii
$nc_e = /\bnc(at)?\s+(-[a-z]*\s+)*-e\s+\/bin\/(ba)?sh/ ascii
$mkfifo = /mkfifo\s+\/tmp\/[a-z0-9_]+;\s*(cat|nc)/ ascii
$py_pty = "pty.spawn(\"/bin/sh\")" ascii
$py_pty2 = "pty.spawn(\"/bin/bash\")" ascii
condition:
any of them
}
rule Linux_Packed_UPX_ELF {
meta:
description = "UPX-packed ELF (packing is rare for distro binaries and common for Linux malware)"
author = "Strawberry"
severity = "medium"
strings:
$upx1 = "UPX!" ascii
$upx2 = "$Info: This file is packed with the UPX" ascii
condition:
uint32(0) == 0x464c457f and ($upx1 in (0..1024) or $upx2)
}
rule Linux_LdPreload_Rootkit_Traits {
meta:
description = "Userland LD_PRELOAD rootkit traits: preload persistence plus libc hooking of process/file listing"
author = "Strawberry"
severity = "high"
strings:
$preload = "/etc/ld.so.preload" ascii
$dlsym = "dlsym" ascii
$rtld_next = "RTLD_NEXT" ascii
$readdir = "readdir" ascii
$hide1 = "hide" ascii nocase
$proc = "/proc/" ascii
condition:
uint32(0) == 0x464c457f
and elf.type == elf.ET_DYN
and $preload and $dlsym and $readdir and $proc
and ($rtld_next or $hide1)
and filesize < 2MB
}