Skip to content

YARA · SEKOIA.IO Community

SEKOIA_Infostealer_Win_Mars_Stealer

Detect Mars Stealer based on specific strings

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

What this rule detects

Detect Mars Stealer based on specific strings

Associated malware family: Mars Stealer.

Targets: Windows PE.

It defines 18 patterns (17 text, 1 hex, 0 regex). YARA modules used: pe.

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.

infostealer-win-mars-stealer.yarDetection Rule License 1.1
import "pe"

rule SEKOIA_Infostealer_Win_Mars_Stealer : FILE
{
	meta:
		description = "Detect Mars Stealer based on specific strings"
		author = "Sekoia.io"
		id = "3e2c7440b2fc9e4b039e6fa8152ac8fd"
		date = "2022-02-03"
		modified = "2024-12-19"
		reference = "https://3xp0rt.com/posts/mars-stealer"
		source_url = "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/yara_rules/infostealer_win_mars_stealer.yar#L3-L44"
		license_url = "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/LICENSE.md"
		logic_hash = "b2b36a280c3c6cbbb8cbb9f1dd3eb48a4943ebbddb48eba2ac3d0db03924cafd"
		score = 75
		quality = 80
		tags = "FILE"
		version = "1.0"
		modification_date = "2022-02-14"
		classification = "TLP:CLEAR"

	strings:
		$dec = {a3 ?? ?? ?? ?? 68 ?? ?? ?? ?? e8 ?? ?? 00 00 83 c4 ??}
		$api00 = "LoadLibrary" ascii
		$api01 = "GetProcAddress" ascii
		$api02 = "ExitProcess" ascii
		$api03 = "advapi32.dll" ascii
		$api04 = "crypt32.dll" ascii
		$api05 = "GetTickCount" ascii
		$api06 = "Sleep" ascii
		$api07 = "GetUserDefaultLangID" ascii
		$api08 = "CreateMutex" ascii
		$api09 = "GetLastError" ascii
		$api10 = "HeapAlloc" ascii
		$api11 = "GetProcessHeap" ascii
		$api12 = "GetComputerName" ascii
		$api13 = "VirtualProtect" ascii
		$api14 = "GetUserName" ascii
		$api15 = "CryptStringToBinary" ascii
		$str0 = "JohnDoe" ascii

	condition:
		uint16( 0 ) == 0x5A4D and ( #dec > 400 and 12 of ( $api* ) and $str0 ) or for any i in ( 0 .. pe.number_of_sections -1 ) : ( pe.sections [ i ] . name == "LLCPPC" and pe.sections [ i ] . raw_data_size < 5000 )
}

Strings (18 patterns)

IdentifierTypeValueModifiers
$dechex{a3 ?? ?? ?? ?? 68 ?? ?? ?? ?? e8 ?? ?? 00 00 83 c4 ??}
$api00text"LoadLibrary"ascii
$api01text"GetProcAddress"ascii
$api02text"ExitProcess"ascii
$api03text"advapi32.dll"ascii
$api04text"crypt32.dll"ascii
$api05text"GetTickCount"ascii
$api06text"Sleep"ascii
$api07text"GetUserDefaultLangID"ascii
$api08text"CreateMutex"ascii
$api09text"GetLastError"ascii
$api10text"HeapAlloc"ascii
$api11text"GetProcessHeap"ascii
$api12text"GetComputerName"ascii
$api13text"VirtualProtect"ascii
$api14text"GetUserName"ascii
$api15text"CryptStringToBinary"ascii
$str0text"JohnDoe"ascii

Condition

uint16( 0 ) == 0x5A4D and ( #dec > 400 and 12 of ( $api* ) and $str0 ) or for any i in ( 0 .. pe.number_of_sections -1 ) : ( pe.sections [ i ] . name == "LLCPPC" and pe.sections [ i ] . raw_data_size < 5000 )

In plain words (Heuristic)

  • The file must start with “MZ” — a Windows executable (PE).
  • At least 12 patterns in ( $api* ) must match.
  • Pattern $dec must occur > 400 times.
  • A for-loop checks a property over several matches or items.
  • Pattern $str0 must be present.
  • Uses the pe module.
  • 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: 3e2c7440b2fc9e4b039e6fa8152ac8fd

Metadata

version1.0
modification_date2022-02-14
classificationTLP:CLEAR

Tags:FILE

More Mars Stealer rules