YARA · SEKOIA.IO Community
SEKOIA_Apt_Mustang_Panda_Toneshell
Detect the TONESHELL implant used by Mustang Panda from specific functions
- Author
- Sekoia.io
- Date
- 2022-11-28
- Modified
- 2024-12-19
- Score / Quality
- 75 / 80
What this rule detects
Detect the TONESHELL implant used by Mustang Panda from specific functions
Targets: Windows PE.
It defines 4 patterns (0 text, 4 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.
import "pe"
import "hash"
rule SEKOIA_Apt_Mustang_Panda_Toneshell : FILE
{
meta:
= "Detect the TONESHELL implant used by Mustang Panda from specific functions"
= "Sekoia.io"
= "bf7c68a9-dddc-494a-a603-c2311ed712a4"
= "2022-11-28"
= "2024-12-19"
= "https://github.com/SEKOIA-IO/Community"
= "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/yara_rules/apt_mustang_panda_toneshell.yar#L4-L160"
= "https://github.com/SEKOIA-IO/Community/blob/a438a5901a211c2abdf75da9c93921ef187473d1/LICENSE.md"
= "192fb01817cc6361062999cf539c51616d1755a5cd8e9d6e37bee6f6d04b0721"
= 75
= 80
= "FILE"
= "1.0"
= "TLP:CLEAR"
strings:
$func1 = {
55
89 E5
64 A1 18 00 00 00
A3 ?? ?? ?? ??
5D
C3
}
$func2 = {
55
89 E5
50
8B 45 ??
8B 45 ??
8B 45 ??
8B 45 ??
89 45 ??
8B 45 ??
89 C1
83 C1 FF
89 4D ??
83 F8 00
0F 84 ?? ?? ?? ??
8B 45 ??
8A 08
8B 45 ??
88 08
8B 45 ??
83 C0 01
89 45 ??
8B 45 ??
83 C0 01
89 45 ??
E9 ?? ?? ?? ??
8B 45 ??
83 C4 04
5D
C3
}
$decryption_routine1 = {
8B 45 ??
C7 45 ?? 00 00 00 00
83 7D ?? 20
0F 8D ?? ?? ?? ??
8B 45 ??
8B 4D ??
0F BE 04 08
83 F0 ??
88 C2
8B 45 ??
8B 4D ??
88 14 08
8B 45 ??
83 C0 01
89 45 ??
E9 ?? ?? ?? ??
83 C4 04
}
$decryption_routine2 = {
55
89 E5
83 EC 08
8B 45 ??
8B 45 ??
8B 45 ??
8B 45 ??
C7 45 ?? 00 00 00 00
C7 45 ?? 00 00 00 00
8B 45 ??
3B 45 ??
0F 8D ?? ?? ?? ??
8B 45 ??
8B 4D ??
0F BE 04 08
8B 4D ??
8B 55 ??
0F BE 0C 11
31 C8
88 C2
8B 45 ??
8B 4D ??
88 14 08
8B 45 ??
8B 4D ??
83 E9 01
39 C8
0F 85 ?? ?? ?? ??
C7 45 ?? 00 00 00 00
E9 ?? ?? ?? ??
8B 45 ??
83 C0 01
89 45 ??
8B 45 ??
83 C0 01
89 45 ??
E9 ?? ?? ?? ??
83 C4 08
5D
C3
}
condition:
uint16be( 0 ) == 0x4d5a and filesize < 8MB and for all i in ( 0 .. pe.number_of_sections -1 ) : ( hash.md5 ( pe.sections [ i ] . raw_data_offset , pe.sections [ i ] . raw_data_size ) != "69f400d3ff4679294e63fb8a8ca97dbb" ) and 3 of them and true
}
Strings (4 patterns)
| Identifier | Type | Value | Modifiers |
|---|---|---|---|
| $func1 | hex | { 55 89 E5 64 A1 18 00 00 00 A3 ?? ?? ?? ?? 5D C3 } | |
| $func2 | hex | { 55 89 E5 50 8B 45 ?? 8B 45 ?? 8B 45 ?? 8B 45 ?? 89 45 ?? 8B 45 ?? 89 C1 … | |
| $decryption_routine1 | hex | { 8B 45 ?? C7 45 ?? 00 00 00 00 83 7D ?? 20 0F 8D ?? ?? ?? ?? 8B 45 ?? 8B 4D ?? 0F BE 04 08 83 F … | |
| $decryption_routine2 | hex | { 55 89 E5 83 EC 08 8B 45 ?? 8B 45 ?? 8B 45 ?? 8B 45 ?? C7 45 ?? 00 00 00 00 C7 45 ?? 00 … |
Condition
uint16be( 0 ) == 0x4d5a and filesize < 8MB and for all i in ( 0 .. pe.number_of_sections -1 ) : ( hash.md5 ( pe.sections [ i ] . raw_data_offset , pe.sections [ i ] . raw_data_size ) != "69f400d3ff4679294e63fb8a8ca97dbb" ) and 3 of them and trueIn 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).
- At least 3 patterns in the rule 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.
References
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: bf7c68a9-dddc-494a-a603-c2311ed712a4
Metadata
| version | 1.0 |
|---|---|
| classification | TLP:CLEAR |
Tags:FILE
Related rules
- APT / threat actorSEKOIA.IO Community· Sekoia.io· 2024-09-10
- APT / threat actorSEKOIA.IO Community· Sekoia.io· 2024-10-21
- APT / threat actorSEKOIA.IO Community· Sekoia.io· 2024-10-21
- APT / threat actorSEKOIA.IO Community· Sekoia.io· 2024-09-27
- APT / threat actorSEKOIA.IO Community· Sekoia.io· 2024-09-27
- APT / threat actorSEKOIA.IO Community· Sekoia.io· 2024-09-23
- APT / threat actorSEKOIA.IO Community· Sekoia.io· 2024-06-11
- APT / threat actorSEKOIA.IO Community· Sekoia.io· 2024-03-06