Skip to content

YARA · SEKOIA.IO Community

SEKOIA_Merlin_Win_Dll

Detects Merling agent (DLL)

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 (DLL)

Targets: Windows PE.

It defines 5 patterns (5 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-dll.yarDetection Rule License 1.1
import "pe"
import "hash"

rule SEKOIA_Merlin_Win_Dll : FILE
{
	meta:
		description = "Detects Merling agent (DLL)"
		author = "Sekoia.io"
		id = "c9c57f5e-26c3-43be-b2cf-10f5129d3be5"
		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_dll.yar#L4-L42"
		license_url = "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/LICENSE.md"
		logic_hash = "eefaed10bd3accc884673437a1cc6b8c503db4ef797e58bd95daec36a297c4be"
		score = 75
		quality = 80
		tags = "FILE"
		version = "1.0"
		classification = "TLP:CLEAR"

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

	condition:
		uint16( 0 ) == 0x5A4D and pe.imphash ( ) == "da7f8acb6151c95be088a02465d68ef8" 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 ) == "491d9a18aea3d0eb3653fdaf0b9b86bb" ) 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 ) == "d41d8cd98f00b204e9800998ecf8427e" ) 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 ) == "bf619eac0cdf3f68d496ea9344137e8b" ) 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 ) == "ce7969c1e894363133e386361be064e5" ) 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 ) == "c6179cdcd9ba0758a18a1280f98062eb" ) and all of them and $s1 at 712 and $s2 at 752 and filesize < 15MB
}

Strings (5 patterns)

IdentifierTypeValueModifiers
$s1text".CRT"ascii
$s2text".tls"ascii
$s3text"github.com/Ne0nd0g/merlin"ascii
$s4text"github.com/lucas-clemente"ascii
$s5text"SendMerlinMessage"ascii

Condition

uint16( 0 ) == 0x5A4D and pe.imphash ( ) == "da7f8acb6151c95be088a02465d68ef8" 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 ) == "491d9a18aea3d0eb3653fdaf0b9b86bb" ) 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 ) == "d41d8cd98f00b204e9800998ecf8427e" ) 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 ) == "bf619eac0cdf3f68d496ea9344137e8b" ) 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 ) == "ce7969c1e894363133e386361be064e5" ) 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 ) == "c6179cdcd9ba0758a18a1280f98062eb" ) and all of them and $s1 at 712 and $s2 at 752 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 712.
  • Pattern $s2 must be found at offset 752.
  • 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 the PE import hash (imphash).
  • 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-10f5129d3be5

Metadata

version1.0
classificationTLP:CLEAR

Tags:FILE