YARA · SEKOIA.IO Community
SEKOIA_Implant_Win_Magicrat
Detect Lazarus' MagicRAT
- 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.
import "pe"
import "hash"
rule SEKOIA_Implant_Win_Magicrat : FILE
{
meta:
= "Detect Lazarus' MagicRAT"
= "Sekoia.io"
= "74973682-b214-48ee-98c3-f4b6bef76587"
= "2022-09-13"
= "2024-12-19"
= "https://blog.talosintelligence.com/2022/09/lazarus-magicrat.html"
= "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/yara_rules/implant_win_magicrat.yar#L4-L24"
= "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/LICENSE.md"
= "9dc04153455d054d7e04d46bcd8c13dd1ca16ab2995e518ba9bf33b43008d592"
= "c2904dc8bbb569536c742fca0c51a766e836d0da8fac1c1abd99744e9b50164f"
= "f6827dc5af661fbb4bf64bc625c78283ef836c6985bb2bfb836bd0c8d5397332"
= "9abc223c5ae9300b06b9161cbd9f5a501b6aaf46970b0bb74d98168792b7e659"
= 75
= 80
= "FILE"
= "1.0"
= "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.
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)
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
| version | 1.0 |
|---|---|
| classification | TLP:CLEAR |
Tags:FILE
Related rules
- MalwareSEKOIA.IO Community· Sekoia.io· 2024-07-16
- MalwareSEKOIA.IO Community· Sekoia.io· 2024-08-23
- MalwareSEKOIA.IO Community· Sekoia.io· 2024-04-22
- MalwareSEKOIA.IO Community· Sekoia.io· 2024-07-23
- MalwareSEKOIA.IO Community· Sekoia.io· 2024-10-20
- MalwareSEKOIA.IO Community· Sekoia.io· 2024-03-20
- MalwareSEKOIA.IO Community· Sekoia.io· 2024-03-20
- MalwareSEKOIA.IO Community· Sekoia.io· 2024-03-20