LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

yara

Pattern matching for malware detection

TLDR

Scan file with rules
$ yara [rules.yar] [file]
copy
Scan directory recursively
$ yara -r [rules.yar] [directory]
copy
Scan process
$ yara [rules.yar] [pid]
copy
Show matching strings
$ yara -s [rules.yar] [file]
copy
Show metadata
$ yara -m [rules.yar] [file]
copy
Multiple rule files
$ yara [rules1.yar] [rules2.yar] [file]
copy
Scan with timeout
$ yara -a [30] [rules.yar] [file]
copy
Count matches
$ yara -c [rules.yar] [file]
copy

SYNOPSIS

yara [-r] [-s] [-m] [-a timeout] [options] rules target

DESCRIPTION

yara matches patterns against files or processes. It's the primary tool for malware classification and detection.Rules define patterns using strings, regular expressions, and conditions. They describe characteristics of malware families or suspicious behavior.String matching finds literal text, hex bytes, or regex patterns. Conditions combine matches with logic for precise detection.Process scanning examines memory of running programs. This detects malware that may not be present on disk.Metadata in rules provides context: author, description, severity, and references. This aids incident response.External variables enable parameterized rules. Thresholds and settings can be adjusted without modifying rules.

PARAMETERS

-r

Recursive directory scan.
-s
Show matching strings.
-m
Show metadata.
-c
Count matches only.
-a SECONDS
Timeout per file.
-n
Negate (show non-matches).
-g
Show tags.
-e
Show namespace.
-w
Disable warnings.
-f
Fast matching mode.
-p N
Parallel threads.
-d VAR=VAL
Define external variable.

INSTALL

sudo apt install yara
copy
sudo dnf install yara
copy
sudo pacman -S yara
copy
sudo apk add yara
copy
sudo zypper install yara
copy
brew install yara
copy
nix profile install nixpkgs#yara
copy

CAVEATS

Rules require expertise to write well. False positives need tuning. Memory-resident malware harder to detect. Regular rule updates needed.

HISTORY

YARA was created by Victor M. Alvarez at VirusTotal around 2007. It became the standard for malware classification, used by antivirus vendors, incident responders, and researchers.

SEE ALSO

clamav(1), strings(1), file(1), ssdeep(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid