Skip to content

YARA · SEKOIA.IO Community

SEKOIA_Implant_Win_Magicrat

Detect Lazarus' MagicRAT

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

What this rule detects

Detect Lazarus' MagicRAT

Targets: Windows PE.

It has no patterns: the condition alone decides (modules, file properties or other rules). 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.

implant-win-magicrat.yarDetection Rule License 1.1
import "pe"
import "hash"

rule SEKOIA_Implant_Win_Magicrat : FILE
{
	meta:
		description = "Detect Lazarus' MagicRAT"
		author = "Sekoia.io"
		id = "74973682-b214-48ee-98c3-f4b6bef76587"
		date = "2022-09-13"
		modified = "2024-12-19"
		reference = "https://blog.talosintelligence.com/2022/09/lazarus-magicrat.html"
		source_url = "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/yara_rules/implant_win_magicrat.yar#L4-L24"
		license_url = "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/LICENSE.md"
		hash = "9dc04153455d054d7e04d46bcd8c13dd1ca16ab2995e518ba9bf33b43008d592"
		hash = "c2904dc8bbb569536c742fca0c51a766e836d0da8fac1c1abd99744e9b50164f"
		hash = "f6827dc5af661fbb4bf64bc625c78283ef836c6985bb2bfb836bd0c8d5397332"
		logic_hash = "9abc223c5ae9300b06b9161cbd9f5a501b6aaf46970b0bb74d98168792b7e659"
		score = 75
		quality = 80
		tags = "FILE"
		version = "1.0"
		classification = "TLP:CLEAR"

	condition:
		uint16( 0 ) == 0x5A4D and filesize > 15MB 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 ) == "39dfb9f035cba21ffd90973904f90469" and pe.sections [ i ] . name == ".qtmetad" )
}

Condition

uint16( 0 ) == 0x5A4D and filesize > 15MB 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 ) == "39dfb9f035cba21ffd90973904f90469" and pe.sections [ i ] . name == ".qtmetad" )

In plain words (Heuristic)

  • The file must start with “MZ” — a Windows executable (PE).
  • The file must be larger than 15MB.
  • 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

Sample hashes

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

  • 9dc04153455d054d7e04d46bcd8c13dd1ca16ab2995e518ba9bf33b43008d592
  • c2904dc8bbb569536c742fca0c51a766e836d0da8fac1c1abd99744e9b50164f
  • f6827dc5af661fbb4bf64bc625c78283ef836c6985bb2bfb836bd0c8d5397332

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: 74973682-b214-48ee-98c3-f4b6bef76587

Metadata

version1.0
classificationTLP:CLEAR

Tags:FILE