Skip to content

YARA · elceef yara-rulz

ELCEEF_BAT_Chunked_Payload_Setenv

Detects batch script storing chunks of payload in random environment variables

Genericelceef yara-rulzMIT LicenseCompiles with YARA-X
Author
marcin@ulikowski.pl
Date
2023-05-05
Modified
2024-04-10
Score / Quality
75 / 75

What this rule detects

Detects batch script storing chunks of payload in random environment variables

It defines 2 patterns (1 text, 1 hex, 0 regex).

Summary generated from the rule's metadata and condition.

Rule source

bat-chunked-payload-setenv.yarMIT License
rule ELCEEF_BAT_Chunked_Payload_Setenv
{
	meta:
		description = "Detects batch script storing chunks of payload in random environment variables"
		author = "marcin@ulikowski.pl"
		id = "18f3ddac-bc19-5b54-891e-93271d59490a"
		date = "2023-05-05"
		modified = "2024-04-10"
		reference = "https://github.com/elceef/yara-rulz"
		source_url = "https://github.com/elceef/yara-rulz/blob/5683b294a12cf0c875b624933586029ae43a852f/rules/Suspicious_BAT.yara#L22-L37"
		license_url = "https://github.com/elceef/yara-rulz/blob/5683b294a12cf0c875b624933586029ae43a852f/LICENSE"
		hash = "f73521adbf89be99c4d7ea74ebf7fed815af49ce4dc060656d7c9c631e4d0538"
		logic_hash = "6b202d1a5723db664c7ca689c73fc1f84365801fd56fc9a035c8d3a0b6b2b9da"
		score = 75
		quality = 75
		tags = ""

	strings:
		$echo = "@echo off"
		$set = { ( 0d 0a | 26 20 ) 73 65 74 20 22 [10] 3d [2-6] 22 }

	condition:
		$echo in ( 0 .. 4 ) and #set > 10
}

Strings (2 patterns)

IdentifierTypeValueModifiers
$echotext"@echo off"
$sethex{ ( 0d 0a | 26 20 ) 73 65 74 20 22 [10] 3d [2-6] 22 }

Condition

$echo in ( 0 .. 4 ) and #set > 10

In plain words (Heuristic)

  • Pattern $set must occur > 10 times.
  • Pattern $echo must be found within the range 0 .. 4.

Test this rule in your browser

Drop a file to scan it with this rule using YARA-X compiled to WebAssembly. Nothing is uploaded.

Drop a file here or click to chooseScanned locally with YARA-X. Files up to 200 MB.

Open in editor

References

Sample hashes

Hashes of samples the author lists in the rule's meta (look them up in your threat-intelligence platform).

  • f73521adbf89be99c4d7ea74ebf7fed815af49ce4dc060656d7c9c631e4d0538

Licence & attribution

Author: marcin@ulikowski.pl

Source repository: elceef yara-rulz @ 5683b294a1

Licence: MIT License (repository licence)

Copyright notice: Copyright (c) 2022 Marcin Ulikowski

Original rule

Mirrored via YARA Forge 20260927, which prefixes rule names with the source and adds normalised meta fields.

Rule id: 18f3ddac-bc19-5b54-891e-93271d59490a