Skip to content

YARA · SEKOIA.IO Community

SEKOIA_Merlin_Win_Exe

Detects Merling agent (PE)

GenericSEKOIA.IO CommunityDetection Rule License 1.1Compiles with YARA-X (with warnings)
Author
Sekoia.io
Date
2022-01-03
Modified
2024-12-19
Score / Quality
75 / 80

What this rule detects

Detects Merling agent (PE)

Targets: Windows PE.

It defines 4 patterns (4 text, 0 hex, 0 regex). YARA modules used: pe, hash.

YARA-X says: warning[deprecated_field]: field `number_of_sections` is deprecated

Summary generated from the rule's metadata and condition.

Rule source

Includes the imports needed to compile it on its own.

merlin-win-exe.yarDetection Rule License 1.1
import "pe"
import "hash"

rule SEKOIA_Merlin_Win_Exe : FILE
{
	meta:
		description = "Detects Merling agent (PE)"
		author = "Sekoia.io"
		id = "c9c57f5e-26c3-43be-b2cf-10f5129d3be4"
		date = "2022-01-03"
		modified = "2024-12-19"
		reference = "https://github.com/SEKOIA-IO/Community"
		source_url = "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/yara_rules/merlin_win_exe.yar#L4-L27"
		license_url = "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/LICENSE.md"
		logic_hash = "6a42e9ea9749dc894788d80cd4395da026ef3c49eab1de6802e09f8b1751f5bd"
		score = 75
		quality = 80
		tags = "FILE"
		version = "1.0"
		classification = "TLP:CLEAR"

	strings:
		$s1 = "B.symtab" ascii
		$s2 = "github.com/Ne0nd0g/merlin" ascii
		$s3 = "github.com/lucas-clemente" ascii
		$s4 = "SendMerlinMessage" ascii

	condition:
		uint16( 0 ) == 0x5A4D and for any i in ( 0 .. pe.number_of_sections -1 ) : ( hash.md5 ( pe.sections [ i ] . raw_data_offset , pe.sections [ i ] . raw_data_size ) == "07b5472d347d42780469fb2654b7fc54" ) and all of them and $s1 at 591 and filesize < 15MB
}

Strings (4 patterns)

IdentifierTypeValueModifiers
$s1text"B.symtab"ascii
$s2text"github.com/Ne0nd0g/merlin"ascii
$s3text"github.com/lucas-clemente"ascii
$s4text"SendMerlinMessage"ascii

Condition

uint16( 0 ) == 0x5A4D and for any i in ( 0 .. pe.number_of_sections -1 ) : ( hash.md5 ( pe.sections [ i ] . raw_data_offset , pe.sections [ i ] . raw_data_size ) == "07b5472d347d42780469fb2654b7fc54" ) and all of them and $s1 at 591 and filesize < 15MB

In plain words (Heuristic)

  • The file must start with “MZ” — a Windows executable (PE).
  • The file must be smaller than 15MB (a cheap guard that skips large files).
  • All patterns in the rule must match.
  • Pattern $s1 must be found at offset 591.
  • A for-loop checks a property over several matches or items.
  • Uses the pe module.
  • Uses the hash module.
  • Compares a hash of the file or a part of it.
  • Checks PE sections (names, count or properties).

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

Licence & attribution

Author: Sekoia.io

Source repository: SEKOIA.IO Community @ a438a5901a

Licence: Detection Rule License 1.1 (repository licence)

Original rule

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

Rule id: c9c57f5e-26c3-43be-b2cf-10f5129d3be4

Metadata

version1.0
classificationTLP:CLEAR

Tags:FILE