Key findings
- A 0xDC-byte configuration footer follows an encrypted resource body and controls anti-analysis, persistence and execution paths.
- Rolling XOR, a second XOR stage, code-bound SHA-256 derivation, AES-256-GCM and optional Xpress Huffman form a coupled payload chain.
- The strongest detection opportunities correlate the loader resource, persistence changes, process manipulation and subsequent network activity.
Review snapshot, method and evidence
- Snapshot
- Artefact: decrypt_payload.py · SHA-256 d44d008e7203…
- Scope
- The public ThreatLabz report on 2CLoader and the payload-decryption tool published with that research.
- Method
- Original architecture reconstruction from the pinned source snapshot
- Evidence
- Official extractor pinned locally by file hash and revision.
What we derived from this evidence set.
The strongest lead is not a screenshot from a report but the format encoded in the extractor: footer, XOR stage and AES-GCM form a reviewable chain. We did not hold a 2CLoader binary.
- Artefact
- decrypt_payload.py
- SHA-256
d44d008e720351ba346aef227934800568721e9babbb2aa77c4c21a13abd7f2b- Revision
aa8b55c63411a0ec691b4023cfdf6a81e48e1641- Analysis basis
- Official extractor pinned locally by file hash and revision.
Source, scope and evidence boundary
ThreatLabz published a technical analysis of 2CLoader and a Python payload-extraction tool on 30 September 2026. This review reads both primary sources against each other: which structure is actually encoded in the tool, which behavioural claims depend exclusively on ThreatLabz sample and telemetry analysis, and which defensive consequences follow?
We did not possess a 2CLoader sample. The companion code was not executed with malware. Runtime behaviour, delivered families and infrastructure therefore remain explicitly attributed to the primary source.
Files and checksums
- threatlabz-tools/2cloader/decrypt_payload.py
d44d008e720351ba346aef227934800568721e9babbb2aa77c4c21a13abd7f2bOfficial ThreatLabz companion tool pinned at commit aa8b55c6; read statically only for this review.
Visual overview & analysis model
One resource. Three execution paths.
A footer and fixed magic identify the embedded configuration. The report binds this structure to the published companion code.
Rolling XOR, a second XOR step and AES-GCM form the documented decryption chain; optional Xpress Huffman decompression follows.
Depending on configuration, the loader selects different execution and persistence paths. Without a sample, their actual use remains explicitly unresolved.
Explanatory diagram, not live telemetry or an audit score. The article documents the assessment and its limits.
Resource → Execution path
The analysis path for this report. Every node shows what is supported, where detection can start and where the claim stops.
Resource
The source-bound architecture begins with an embedded resource.
Review resource size, entropy and access path together.
Bound to primary researchFooter
A footer with a fixed marker describes the configuration location.
Validate the structure marker and offset relationships.
Bound to primary researchDecryption
Several documented decoding and decryption steps prepare the payload.
Capture primitive, order and buffer hand-offs.
Bound to primary researchDecompression
Optional decompression depends on the parsed configuration.
Join API use with the configuration branch.
Bound to primary researchExecution path
The source describes alternative execution paths; use in a concrete sample remains unresolved.
Separate memory, process and persistence signals by path.
Bounded or unresolvedConfiguration fingerprint
Review pivots derived from the report — not a live configuration or universal family indicator.
Defensive artefacts
Source, validation and limits accompany every rule.
YARAOpen rule +
rule Windows_Loader_2CLoader_Footer_Candidate {
meta:
author = "Ruhrdigital Studio"
scope = "synthetic structural hunt; not family attribution"
strings:
$footer_magic = { 2C 3D 4E 5F }
condition:
uint16(0) == 0x5a4d and filesize > 0xDC and $footer_magic in (filesize-0xDC..filesize-1)
}SigmaOpen rule +
title: 2CLoader-style scheduled task persistence candidate
status: experimental
logsource:
product: windows
category: process_creation
detection:
task_tool:
Image|endswith: '\\schtasks.exe'
CommandLine|contains|all:
- '/create'
- '/sc'
- 'onlogon'
suspicious_name:
CommandLine|contains: 'SecurityHealthService.exe'
condition: task_tool and suspicious_name
falsepositives:
- Legitimate software using the same filename or task pattern
level: mediumWhat is supported — and what is missing
The report and companion code form two different evidence layers. The report describes observed samples, execution options and campaign telemetry. The tool implements resource discovery, footer structure and the decryption sequence. Without an original sample, this implementation cannot be replayed here against a concrete build.
Public evidence and the open sample gap
The map separates the published report, reproducible tool snapshot and unavailable malware sample.
A file reference does not establish runtime behaviour. Recorded processing is not a new execution.
Evidence
Two public primary sources; no local malware artifact.
ThreatLabz report
Behavioural, sample and telemetry claims from the primary source.
- ThreatLabz report → decrypt_payload.pypublished as companion tool · Verified reference
The primary report links the ThreatLabz decryptor; its commit and file were pinned.
decrypt_payload.py
Hash-bound official parser and decryptor.
- File
- threatlabz-tools/2cloader/decrypt_payload.py
- SHA-256
- d44d008e720351ba346aef227934800568721e9babbb2aa77c4c21a13abd7f2b
- Location
- 1-366
- ThreatLabz report → decrypt_payload.pypublished as companion tool · Verified reference
The primary report links the ThreatLabz decryptor; its commit and file were pinned.
- decrypt_payload.py → Malware sample unavailablenot replayed here · Unresolved
No extraction, decryption or decompression was run without a sample.
Malware sample unavailable
No first-party binary, runtime or C2 evidence.
- decrypt_payload.py → Malware sample unavailablenot replayed here · Unresolved
No extraction, decryption or decompression was run without a sample.
Limit: Publishing a decryptor establishes its intended handling of ThreatLabz-reviewed builds, not compatibility with every variant.
The footer is the control plane
The public tool expects exactly 0xDC bytes of configuration at the end of the PE resource. A magic value identifies the footer; size fields separate the main payload, an optional additional file and an optional message. Other fields control persistence, anti-analysis, target process, sleep time and scheduled task.
This matters defensively because the footer links a statically visible structure to later behaviour. A magic value alone would be too brittle for detection; combined with PE-resource placement, plausible size relationships and subsequent process activity it becomes stronger.
Complete public offline analysis tool from the source snapshot already pinned in the report. The displayed code reads or decodes artefacts; publishing it does not prove we executed it on a malware sample.
Show file hash
SHA-256 d44d008e720351ba346aef227934800568721e9babbb2aa77c4c21a13abd7f2bimport argparse
import ctypes
import hashlib
import struct
from dataclasses import dataclass
from pathlib import Path
import pefile
from cryptography.exceptions import InvalidTag
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
FOOTER_SIZE = 0xDC
FOOTER_MAGIC = 0x5F4E3D2C
RTL_COMPRESSION_FORMAT_XPRESS_HUFF = 4
IMAGE_SCN_MEM_EXECUTE = 0x20000000
def fail() -> None:
print("[-]Decrpytion Failed")
raise SystemExit(1)
@dataclass
class configfooter:
magic: int
fl: int
final_payload_size: int
aes_gcm_nonce_size: int
aes_gcm_tag_size: int
aes_gcm_nonce: bytes
aes_gcm_tag: bytes
sha256_seed_xor2: bytes
sha256_seed_xor1: bytes
sum_of_bytes_checksum: int
persistence: int
opt_flag: int
optional_payload_size: int
optional_message_size: int
xor_add_after_rolling_xor: int
xor_key_after_rolling_xor: int
rolling_xor_seed: int
unk_67: int
sleeptime: int
beacon_id: bytes
target_executable_name_used_in_injection: bytes
bt: int
pn: bytes
unk_D0: int
scheduled_tasks_trigger_interval_hours: int
decompressed_buffer_size: int
@property
def total_body_size(self) -> int:
return self.final_payload_size + self.optional_payload_size + self.optional_message_size
def iterate_resouce(pe: pefile.PE):
if not hasattr(pe, "DIRECTORY_ENTRY_RESOURCE"):
return
for type_entry in pe.DIRECTORY_ENTRY_RESOURCE.entries:
if not hasattr(type_entry, "directory"):
continue
type_id = type_entry.id if type_entry.name is None else str(type_entry.name)
for name_entry in type_entry.directory.entries:
if not hasattr(name_entry, "directory"):
continue
name_id = name_entry.id if name_entry.name is None else str(name_entry.name)
for lang_entry in name_entry.directory.entries:
data_rva = lang_entry.data.struct.OffsetToData
data_size = lang_entry.data.struct.Size
blob = pe.get_data(data_rva, data_size)
if blob and len(blob) == data_size:
yield type_id, name_id, lang_entry.id, blob
def parse_footer(footer_bytes: bytes) -> configfooter:
if struct.unpack_from("<I", footer_bytes, 0)[0] != FOOTER_MAGIC:
fail()
dwords = struct.unpack("<55I", footer_bytes)
return configfooter(
magic=dwords[0],
fl=dwords[1],
final_payload_size=dwords[2],
aes_gcm_nonce_size=dwords[3],
aes_gcm_tag_size=dwords[4],
aes_gcm_nonce=footer_bytes[0x14:0x20],
aes_gcm_tag=footer_bytes[0x20:0x30],
sha256_seed_xor2=footer_bytes[0x30:0x40],
sha256_seed_xor1=footer_bytes[0x40:0x50],
sum_of_bytes_checksum=dwords[20],
persistence=dwords[21],
opt_flag=dwords[22],
optional_payload_size=dwords[23],
optional_message_size=dwords[24],
xor_add_after_rolling_xor=footer_bytes[0x64],
xor_key_after_rolling_xor=footer_bytes[0x65],
rolling_xor_seed=footer_bytes[0x66],
unk_67=footer_bytes[0x67],
sleeptime=dwords[26],
beacon_id=footer_bytes[0x6C:0x7C],
target_executable_name_used_in_injection=footer_bytes[0x7C:0xBC],
bt=dwords[47],
pn=footer_bytes[0xC0:0xD0],
unk_D0=dwords[52],
scheduled_tasks_trigger_interval_hours=dwords[53],
decompressed_buffer_size=dwords[54],
)
def find_footer_resource(pe_path: str | Path):
pe = pefile.PE(str(pe_path), fast_load=False)
for type_id, name_id, lang_id, blob in iterate_resouce(pe):
if len(blob) < FOOTER_SIZE:
continue
footer_bytes = blob[-FOOTER_SIZE:]
if struct.unpack_from("<I", footer_bytes, 0)[0] != FOOTER_MAGIC:
continue
footer = parse_footer(footer_bytes)
body_size = footer.total_body_size
if len(blob) < body_size + FOOTER_SIZE:
fail()
body_offset = len(blob) - FOOTER_SIZE - body_size
return {
"type_id": type_id,
"name_id": name_id,
"lang_id": lang_id,
"blob": blob,
"body": blob[body_offset:body_offset + body_size],
"footer": footer,
}
fail()
def decode_resource_stage(body: bytes, rolling_xor_seed: int) -> bytes:
return bytes(b ^ ((rolling_xor_seed + i) & 0xFF) for i, b in enumerate(body))
def xor_decrypt_payload(decoded_payload: bytearray, low: int, high: int) -> bytes:
for i in range(len(decoded_payload)):
decoded_payload[i] ^= (high + i * low) & 0xFF
return bytes(decoded_payload)
def compute_section_sha256_seed(pe_path: str | Path) -> bytes:
pe = pefile.PE(str(pe_path), fast_load=False)
chosen = None
for section in pe.sections:
name = section.Name.rstrip(b"\x00")
if name == b".text":
chosen = section
break
if chosen is None:
for section in pe.sections:
if section.Characteristics & IMAGE_SCN_MEM_EXECUTE:
chosen = section
break
if chosen is None:
fail()
raw = pe.get_data(chosen.VirtualAddress, chosen.Misc_VirtualSize)
if not raw:
fail()
return hashlib.sha256(raw).digest()
def generate_aes_key(footer: configfooter, sha256_seed: bytes) -> bytes:
if len(sha256_seed) != 32:
fail()
seed = bytearray(sha256_seed)
for i in range(16):
seed[i] ^= footer.sha256_seed_xor2[i]
seed[16 + i] ^= footer.sha256_seed_xor1[i]
checksum = sum(seed) & 0xFFFFFFFF
if checksum != footer.sum_of_bytes_checksum:
fail()
return bytes(seed)
def aes_gcm_decrypt(ciphertext: bytes, footer: configfooter, key: bytes) -> bytes:
nonce = footer.aes_gcm_nonce[:footer.aes_gcm_nonce_size]
tag = footer.aes_gcm_tag[:footer.aes_gcm_tag_size]
if len(key) != 32:
fail()
if not nonce:
fail()
if not tag:
fail()
try:
return AESGCM(key).decrypt(nonce, ciphertext + tag, None)
except InvalidTag:
fail()
def decompress_final_payload(payload: bytes, footer: configfooter) -> bytes:
if footer.final_payload_size > len(payload):
fail()
if footer.decompressed_buffer_size == 0:
return payload
compressed = payload[:footer.final_payload_size]
tail = payload[footer.final_payload_size:]
output_size = footer.decompressed_buffer_size
ntdll = ctypes.WinDLL("ntdll")
rtl_get_workspace = ntdll.RtlGetCompressionWorkSpaceSize
rtl_get_workspace.argtypes = [
ctypes.c_ushort,
ctypes.POINTER(ctypes.c_ulong),
ctypes.POINTER(ctypes.c_ulong),
]
rtl_get_workspace.restype = ctypes.c_long
rtl_decompress_buffer_ex = ntdll.RtlDecompressBufferEx
rtl_decompress_buffer_ex.argtypes = [
ctypes.c_ushort,
ctypes.c_void_p,
ctypes.c_ulong,
ctypes.c_void_p,
ctypes.c_ulong,
ctypes.POINTER(ctypes.c_ulong),
ctypes.c_void_p,
]
rtl_decompress_buffer_ex.restype = ctypes.c_long
rtl_decompress_buffer = ntdll.RtlDecompressBuffer
rtl_decompress_buffer.argtypes = [
ctypes.c_ushort,
ctypes.c_void_p,
ctypes.c_ulong,
ctypes.c_void_p,
ctypes.c_ulong,
ctypes.POINTER(ctypes.c_ulong),
]
rtl_decompress_buffer.restype = ctypes.c_long
out_buf = (ctypes.c_ubyte * output_size)()
in_buf = (ctypes.c_ubyte * len(compressed)).from_buffer_copy(compressed)
final_size_written = ctypes.c_ulong(0)
status_ex = None
workspace_size = ctypes.c_ulong(0)
workspace_fragment_size = ctypes.c_ulong(0)
status_workspace = rtl_get_workspace(
RTL_COMPRESSION_FORMAT_XPRESS_HUFF,
ctypes.byref(workspace_size),
ctypes.byref(workspace_fragment_size),
)
if status_workspace == 0 and workspace_size.value:
workspace = (ctypes.c_ubyte * workspace_size.value)()
status_ex = rtl_decompress_buffer_ex(
RTL_COMPRESSION_FORMAT_XPRESS_HUFF,
out_buf,
output_size,
in_buf,
len(compressed),
ctypes.byref(final_size_written),
workspace,
)
if status_ex == 0:
if final_size_written.value != output_size:
fail()
return bytes(out_buf[:output_size]) + tail
final_size_written.value = 0
status = rtl_decompress_buffer(
RTL_COMPRESSION_FORMAT_XPRESS_HUFF,
out_buf,
output_size,
in_buf,
len(compressed),
ctypes.byref(final_size_written),
)
if status != 0:
fail()
if final_size_written.value != output_size:
fail()
return bytes(out_buf[:output_size]) + tail
def split_body_parts(payload: bytes, footer: configfooter) -> tuple[bytes, bytes, bytes]:
main_size = footer.decompressed_buffer_size if footer.decompressed_buffer_size else footer.final_payload_size
part1_size = footer.optional_payload_size
part2_size = footer.optional_message_size
if len(payload) < main_size + part1_size + part2_size:
fail()
main_payload = payload[:main_size]
dropped_payload = payload[main_size:main_size + part1_size]
message_block = payload[main_size + part1_size:main_size + part1_size + part2_size]
return main_payload, dropped_payload, message_block
def extract_decode_and_write(pe_path: str | Path, out_dir: str | Path):
resource = find_footer_resource(pe_path)
footer = resource["footer"]
out_dir = Path(out_dir)
out_dir.mkdir(parents=True, exist_ok=True)
section_sha256_seed = compute_section_sha256_seed(pe_path)
stage1 = decode_resource_stage(resource["body"], footer.rolling_xor_seed)
stage2 = xor_decrypt_payload(bytearray(stage1), footer.xor_add_after_rolling_xor, footer.xor_key_after_rolling_xor)
aes_key = generate_aes_key(footer, section_sha256_seed)
aes_plaintext = aes_gcm_decrypt(stage2, footer, aes_key)
final_buffer = decompress_final_payload(aes_plaintext, footer)
main_payload, dropped_payload, message_block = split_body_parts(final_buffer, footer)
(out_dir / "resource_footer.bin").write_bytes(resource["blob"][-FOOTER_SIZE:])
(out_dir / "payload_final.bin").write_bytes(main_payload)
dropped_path = None
if footer.optional_payload_size and dropped_payload:
dropped_path = out_dir / "optional_payload_dropped.bin"
dropped_path.write_bytes(dropped_payload)
message_path = None
if footer.optional_message_size and message_block:
message_path = out_dir / "messagebox_block.bin"
message_path.write_bytes(message_block)
return {
"[+] Final Payload decrpted and written to ": str(out_dir),
"optional_payload_path": str(dropped_path) if dropped_path else None,
"message_block_path": str(message_path) if message_path else None,
}
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("input_path")
args = parser.parse_args()
try:
info = extract_decode_and_write(args.input_path, Path.cwd())
except SystemExit:
raise
except Exception:
fail()
for key, value in info.items():
print(f"{key}: {value}")
if __name__ == "__main__":
main()
Original source-file lines. Choose a note to highlight its range.
MIT · Source & license notice
Pinned public source ↗MIT License Copyright (c) 2022 Zscaler ThreatLabz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
From resource to three outputs
The documented processing path is fixed: locate the resource, apply rolling XOR, apply a second XOR stage, derive a key from configuration and code hash, perform authenticated AES-GCM decryption and optionally decompress Xpress Huffman. Only then are the main payload, optional extra file and message block separated.
AES-GCM does not protect the victim here; it protects the embedded payload from simple static extraction. The authentication tag also creates a hard validation step: incorrect key derivation or altered data breaks the chain.
Show file hash
SHA-256 d44d008e720351ba346aef227934800568721e9babbb2aa77c4c21a13abd7f2bdef extract_decode_and_write(pe_path: str | Path, out_dir: str | Path):
resource = find_footer_resource(pe_path)
footer = resource["footer"]
out_dir = Path(out_dir)
out_dir.mkdir(parents=True, exist_ok=True)
section_sha256_seed = compute_section_sha256_seed(pe_path)
stage1 = decode_resource_stage(resource["body"], footer.rolling_xor_seed)
stage2 = xor_decrypt_payload(bytearray(stage1), footer.xor_add_after_rolling_xor, footer.xor_key_after_rolling_xor)
aes_key = generate_aes_key(footer, section_sha256_seed)
aes_plaintext = aes_gcm_decrypt(stage2, footer, aes_key)
final_buffer = decompress_final_payload(aes_plaintext, footer)
main_payload, dropped_payload, message_block = split_body_parts(final_buffer, footer)
Original source-file lines. Choose a note to highlight its range.
Anti-analysis reaches into key derivation
ThreatLabz describes VM, debugger, timing and user-activity checks. Most importantly, one timing check is coupled to decryption: it can alter the intermediate SHA-256 value and thereby produce an incorrect AES key. This does not require a separate visible exit; it makes the payload chain fail cryptographically.
ThreatLabz also reports indirect system calls and inline trampolines intended to influence what user-mode security products and the delivered payload observe. Their runtime effect was not measured independently here.
Three execution paths, multiple persistence paths
The primary report describes in-memory .NET execution, manual LoadPE in the loader process and RunPE in a suspended target process. Configuration flags can control fallbacks between the native paths. An optional second dropped file and decoy message may be added.
Persistence can use Run, RunOnce, the Startup folder, scheduled tasks, the Load registry value or UserInitMprLogonScript. For defenders, the useful signal is not one method alone but the sequence of new autorun configuration, suspicious process start or manipulation and subsequent beacon traffic.
Detection: correlate structure and behaviour
A defensible model should connect three layers. First, static structure: a PE resource with the matching footer magic, plausible size relationships and option fields. Second, host behaviour: new persistence followed by process manipulation or in-memory CLR loading. Third, network: a timely HTTP POST from a newly started, unexpected process.
The Sigma example below is a defensive correlation model for one high-signal persistence branch. It was not validated with a Sigma engine here and must be adapted to product fields, legitimate software distribution and local naming conventions.
title: 2CLoader-style scheduled task persistence candidate
status: experimental
logsource:
product: windows
category: process_creation
detection:
task_tool:
Image|endswith: '\\schtasks.exe'
CommandLine|contains|all:
- '/create'
- '/sc'
- 'onlogon'
suspicious_name:
CommandLine|contains: 'SecurityHealthService.exe'
condition: task_tool and suspicious_name
falsepositives:
- Legitimate software using the same filename or task pattern
level: medium
Line numbers refer to this excerpt. Choose a note to highlight its range.
Payload use is not developer attribution
ThreatLabz observed 2CLoader primarily delivering Vidar and Remus, with XWorm also present. This describes delivery relationships in the reviewed campaigns. It does not establish common authorship of loader and payloads, nor that every future 2CLoader build delivers the same families.
Likewise, filenames, message text, target process or individual C2 indicators do not establish operator identity. This report therefore makes no actor attribution.
What this source review supports
The report and official decryptor agree on the core structural claims: footer size and magic, three-part resource, staged decryption, code-bound key derivation and optional decompression. The primary source adds anti-analysis, persistence, execution options and campaign observations.
What is not established is first-party replay against a sample. This review therefore assesses architecture and defensive consequences, not the functionality of a specific sample or completeness across variants.
Review limits
- This report is an independent technical interpretation of public primary sources, not first-party malware-sample reverse engineering.
- The published decryptor was reviewed and hash-bound but was neither executed nor functionally verified without a malware input.
- Payload families and infrastructure observed by ThreatLabz do not attribute every 2CLoader build.
Sources & context
These sources provide evidence and further context. Our observations, reconstructions and other authors’ results are distinguished in the relevant analysis section.
Zscaler ThreatLabz — 2CLoader technical analysis ↗ThreatLabz tools — decrypt_payload.py (commit aa8b55c6) ↗Conclusion
Conclusion: evasion is configurable, the chain remains observable
2CLoader combines payload protection, anti-analysis, flexible execution and persistence in a configurable intermediate layer. That breadth also creates signals that can be joined: resource structure, decryption parameters, autorun changes, process manipulation and status traffic. The strongest defensive approach correlates these layers instead of treating a name, hash or magic value as family proof.
Next steps
- Validate the footer parser only against lawfully available, hash-bound samples.
- Test host and network detection against synthetic positives and known legitimate installers.
- Track new variants through structure and behavioural sequence, not published IOCs alone.
The public ThreatLabz report on 2CLoader and the payload-decryption tool published with that research.
