Skip to content

YARA · SEKOIA.IO Community

SEKOIA_Apt_Mustang_Panda_Toneins

Detect the TONEINS implant used by Mustang Panda

APT / threat actorSEKOIA.IO CommunityDetection Rule License 1.1Compiles with YARA-X (with warnings)
Author
Sekoia.io
Date
2022-11-28
Modified
2024-12-19
Score / Quality
75 / 80

What this rule detects

Detect the TONEINS implant used by Mustang Panda

Targets: Windows PE.

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

YARA-X says: warning[text_as_hex]: hex pattern could be written as text literal

Summary generated from the rule's metadata and condition.

Rule source

Includes the imports needed to compile it on its own.

apt-mustang-panda-toneins.yarDetection Rule License 1.1
import "pe"
import "hash"

rule SEKOIA_Apt_Mustang_Panda_Toneins : FILE
{
	meta:
		description = "Detect the TONEINS implant used by Mustang Panda"
		author = "Sekoia.io"
		id = "f178217a-ff28-4dd7-9395-f19f3e2e934c"
		date = "2022-11-28"
		modified = "2024-12-19"
		reference = "https://github.com/SEKOIA-IO/Community"
		source_url = "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/yara_rules/apt_mustang_panda_toneins.yar#L4-L44"
		license_url = "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/LICENSE.md"
		logic_hash = "b71932f16ffb1d8d1780b6f9b4db2f0c98d1c770829a4d2284e78c19d37e54bb"
		score = 75
		quality = 80
		tags = "FILE"
		version = "1.0"
		classification = "TLP:CLEAR"

	strings:
		$rtti1 = ".?AVDNameNode@@"
		$rtti2 = ".?AVcharNode@@"
		$rtti3 = ".?AVpcharNode@@"
		$rtti4 = ".?AVpDNameNode@@"
		$rtti5 = ".?AVDNameStatusNode@@"
		$rtti6 = ".?AVpairNode@@"
		$s1 = "DefWindowProcW1222_test" wide ascii
		$s2 = "schtasks /create /sc minute /mo 2 /tn" wide ascii
		$fnv_CreateFile = {CE C9 CA BD}
		$fnv_GetFileSize = {18 81 ED 44}
		$fnv_ReadFile = {43 C9 FC 54}
		$fnv_CloseHandle = {65 00 BA FA}
		$fnv_WriteFile = {4A C4 07 7F}
		$fnv_CreateEventA = {E2 DD D2 F9}
		$fnv_TerminateProcess = {59 EE 4E F8}
		$fnv_GetCurrentProcess = {45 A8 D8 6D}
		$fnv_CreateProcessA = { 09 0A 7C 4A}

	condition:
		uint16be( 0 ) == 0x4d5a and 4 of ( $rtti* ) and filesize < 8MB 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 ) == "69f400d3ff4679294e63fb8a8ca97dbb" ) or ( all of ( $s* ) and 5 of ( $fnv* ) ) )
}

Strings (17 patterns)

IdentifierTypeValueModifiers
$rtti1text".?AVDNameNode@@"
$rtti2text".?AVcharNode@@"
$rtti3text".?AVpcharNode@@"
$rtti4text".?AVpDNameNode@@"
$rtti5text".?AVDNameStatusNode@@"
$rtti6text".?AVpairNode@@"
$s1text"DefWindowProcW1222_test"wide ascii
$s2text"schtasks /create /sc minute /mo 2 /tn"wide ascii
$fnv_CreateFilehex{CE C9 CA BD}
$fnv_GetFileSizehex{18 81 ED 44}
$fnv_ReadFilehex{43 C9 FC 54}
$fnv_CloseHandlehex{65 00 BA FA}
$fnv_WriteFilehex{4A C4 07 7F}
$fnv_CreateEventAhex{E2 DD D2 F9}
$fnv_TerminateProcesshex{59 EE 4E F8}
$fnv_GetCurrentProcesshex{45 A8 D8 6D}
$fnv_CreateProcessAhex{ 09 0A 7C 4A}

Condition

uint16be( 0 ) == 0x4d5a and 4 of ( $rtti* ) and filesize < 8MB 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 ) == "69f400d3ff4679294e63fb8a8ca97dbb" ) or ( all of ( $s* ) and 5 of ( $fnv* ) ) )

In plain words (Heuristic)

  • The file must start with “MZ” — a Windows executable (PE).
  • The file must be smaller than 8MB (a cheap guard that skips large files).
  • All patterns in ( $s* ) must match.
  • At least 4 patterns in ( $rtti* ) must match.
  • At least 5 patterns in ( $fnv* ) must match.
  • 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: f178217a-ff28-4dd7-9395-f19f3e2e934c

Metadata

version1.0
classificationTLP:CLEAR

Tags:FILE