/* * 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" 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 } 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 }