Command line

The package installs yaranormalize and yara_uniq. Both are also available as subcommands of python -m yaratool.

yaranormalize

$ yaranormalize [-i in_file]... [-o out_file] [-h | -H] [--hash-version 1|2]
$ python -m yaratool normalize ...

-i input file (repeatable, default STDIN); -o output file (default STDOUT); -h include the yara hash in the normalized rule; -H print only the hash of each rule; --hash-version picks the legacy yn01 (1) or the default yn02 (2) hash.

yara_uniq

$ yara_uniq [-i in_file]... [-o out_file] [-u | -d] [--hash-version 1|2]
$ python -m yaratool uniq ...

By default the first copy of each rule is printed and duplicates are omitted. -u prints only rules that are never duplicated; -d prints every copy of rules that are duplicated. What counts as a duplicate is decided by the rule hash, so --hash-version applies here too.

Command line entry points for yaratool.

Run as python -m yaratool <normalize|uniq> [options], or use the yaranormalize and yara_uniq console scripts installed with the package.

yaratool.__main__.main(argv: List[str] | None = None) → int[source]

Dispatch python -m yaratool <command> ....

Parameters:

argv – arguments excluding the program name; defaults to sys.argv[1:].

Returns:

the process exit status (2 for a missing or unknown command).

yaratool.__main__.normalize_main(argv: List[str] | None = None, prog: str = 'yaranormalize') → int[source]

Entry point for yaranormalize: normalize yara rules, or print their hashes.

Parameters:
  • argv – arguments excluding the program name; defaults to sys.argv[1:].

  • prog – program name used in usage output.

Returns:

the process exit status.

yaratool.__main__.uniq_main(argv: List[str] | None = None, prog: str = 'yara_uniq') → int[source]

Entry point for yara_uniq: filter yara rules by whether their hash is unique or duplicated.

Parameters:
  • argv – arguments excluding the program name; defaults to sys.argv[1:].

  • prog – program name used in usage output.

Returns:

the process exit status.