[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71F4VXBWD17H6MNBY0QHSWZ":3,"skill-same:01M71F4VXBWD17H6MNBY0QHSWZ":86},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":59,"commitSha":60,"skillDirectory":61,"forksCount":14,"repositoryHtmlUrl":62,"repositoryHomepageUrl":6,"ownerHtmlUrl":63,"ownerBlogUrl":6,"ownerDescription":64,"updatedAt":65,"install":66,"resources":79},"01M71F4VXBWD17H6MNBY0QHSWZ","family-ransomware-detect",null,"Analyzes encryption algorithms, key management, and file encryption routines used by ransomware families to assess decryption feasibility, identify implementation weaknesses, and support recovery efforts. Covers AES, RSA, ChaCha20, and hybrid encryption schemes. Activates for requests involving ransomware cryptanalysis, encryption analysis, key recovery assessment, or ransomware decryption feasibility.","DCx7C5\u002Fai-marketplace","DCx7C5","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F42419559?v=4","01M71C01G2AZV3NTNGWAWSHJPP","DC","01M71C01GQW6G50S2BYMS7PP3E",0,"MIT","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fmalware\u002Ffamily\u002Fransomware\u002Fdetect\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"family ransomware detect","family","detect","ransomware","sonnet","decryption","malware","read","support","aes","de","cryptanalysis","analysis","encryption","Bash","cybersecurity","key management","assessment","cm","reverse-engineering","2026-11-10 10:12:30",false,"---\nname: family-ransomware-detect\ndescription: Analyzes encryption algorithms, key management, and file encryption routines used by ransomware families to assess decryption feasibility, identify implementation weaknesses, and support recovery efforts. Covers AES, RSA, ChaCha20, and hybrid encryption schemes. Activates for requests involving ransomware cryptanalysis, encryption analysis, key recovery assessment, or ransomware decryption feasibility.\ndomain: cybersecurity\nsubdomain: malware-analysis\ntags:\n- malware\n- ransomware\n- encryption\n- cryptanalysis\n- reverse-engineering\nnist_csf:\n- DE.AE-02\n- RS.AN-03\n- ID.RA-01\n- DE.CM-01\nmodel: sonnet\nmaxTurns: 20\ntools: [Read, Bash, Glob, Grep]\nmitre_attack:\n- T1486\ncapec: []\n---\n\n# Analyzing Ransomware Encryption Mechanisms\n\n## When to Use\n\n- A ransomware infection has occurred and recovery requires understanding the encryption scheme used\n- Assessing whether decryption is possible without paying the ransom (implementation flaws, known decryptors)\n- Reverse engineering ransomware to identify the encryption algorithm, key derivation, and key storage mechanism\n- Developing a decryptor tool when a weakness in the ransomware's cryptographic implementation is identified\n- Classifying a ransomware sample by its encryption approach to attribute it to a known family\n\n**Do not use** for production data recovery operations without first verifying the decryption method on test copies of encrypted files.\n\n## Prerequisites\n\n- Ghidra or IDA Pro for reverse engineering the ransomware binary\n- Python 3.8+ with `pycryptodome` library for testing encryption\u002Fdecryption routines\n- Sample encrypted files and their corresponding plaintext originals (known-plaintext pairs)\n- Access to the ransomware binary (unpacked if applicable)\n- Familiarity with symmetric (AES, ChaCha20) and asymmetric (RSA) cryptographic algorithms\n- NoMoreRansom.org database for checking existing free decryptors\n\n## Workflow\n\n### Step 1: Identify the Encryption Algorithm\n\nDetermine which cryptographic algorithm the ransomware uses:\n\n```python\n# Check for Windows Crypto API usage in imports\nimport pefile\n\npe = pefile.PE(\"ransomware.exe\")\n\ncrypto_apis = {\n    \"CryptAcquireContextA\": \"Windows CryptoAPI\",\n    \"CryptAcquireContextW\": \"Windows CryptoAPI\",\n    \"CryptGenKey\": \"Windows CryptoAPI key generation\",\n    \"CryptEncrypt\": \"Windows CryptoAPI encryption\",\n    \"CryptImportKey\": \"Windows CryptoAPI key import\",\n    \"BCryptOpenAlgorithmProvider\": \"Windows CNG (modern crypto)\",\n    \"BCryptEncrypt\": \"Windows CNG encryption\",\n    \"BCryptGenerateKeyPair\": \"Windows CNG asymmetric key gen\",\n}\n\nprint(\"Crypto API Imports:\")\nfor entry in pe.DIRECTORY_ENTRY_IMPORT:\n    for imp in entry.imports:\n        if imp.name and imp.name.decode() in crypto_apis:\n            print(f\"  {entry.dll.decode()} -> {imp.name.decode()}: {crypto_apis[imp.name.decode()]}\")\n```\n\n```\nCommon Ransomware Encryption Schemes:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nAES-256-CBC + RSA-2048:    Most common hybrid scheme (LockBit, REvil, Conti)\nAES-256-CTR + RSA-4096:    Stream cipher mode variant (BlackCat\u002FALPHV)\nChaCha20 + RSA-4096:       Modern stream cipher (Hive, Royal)\nSalsa20 + ECDH:            Curve25519 key exchange (Babuk)\nAES-128-ECB:               Weak mode - potential decryption via known-plaintext\nXOR-only:                  Trivial encryption - always recoverable\nCustom algorithm:          Often contains implementation flaws\n```\n\n### Step 2: Analyze Key Generation and Management\n\nReverse engineer how encryption keys are generated and stored:\n\n```\nKey Management Patterns in Ransomware:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n1. STRONG (no recovery possible without key):\n   - Per-file AES key generated with CryptGenRandom\n   - AES key encrypted with embedded RSA public key\n   - Encrypted key appended to each file or stored separately\n   - RSA private key held only by attacker's C2 server\n\n2. WEAK (potential recovery):\n   - AES key derived from predictable seed (timestamp, PID)\n   - Same AES key used for all files (single key compromise = full recovery)\n   - Key transmitted to C2 before encryption starts (PCAP may contain key)\n   - XOR with short repeating key (brute-forceable)\n   - PRNG seeded with GetTickCount or time() (limited keyspace)\n\n3. FLAWED IMPLEMENTATION:\n   - ECB mode (preserves plaintext patterns)\n   - Initialization vector (IV) reuse across files\n   - Key stored in plaintext in memory (recoverable from memory dump)\n   - Partial encryption (only first N bytes encrypted)\n```\n\n### Step 3: Examine File Encryption Routine\n\nReverse engineer the file processing logic:\n\n```c\n\u002F\u002F Typical ransomware file encryption flow (decompiled pseudo-code from Ghidra):\n\nvoid encrypt_file(char *filepath) {\n    \u002F\u002F 1. Check file extension against target list\n    if (!is_target_extension(filepath)) return;\n\n    \u002F\u002F 2. Generate per-file AES key (32 bytes for AES-256)\n    BYTE aes_key[32];\n    CryptGenRandom(hProv, 32, aes_key);\n\n    \u002F\u002F 3. Generate random IV (16 bytes)\n    BYTE iv[16];\n    CryptGenRandom(hProv, 16, iv);\n\n    \u002F\u002F 4. Read file contents\n    HANDLE hFile = CreateFile(filepath, GENERIC_READ, ...);\n    BYTE *plaintext = read_entire_file(hFile);\n\n    \u002F\u002F 5. Encrypt with AES-256-CBC\n    aes_cbc_encrypt(plaintext, file_size, aes_key, iv);\n\n    \u002F\u002F 6. Encrypt AES key with RSA public key\n    BYTE encrypted_key[256];  \u002F\u002F RSA-2048 output\n    rsa_encrypt(aes_key, 32, rsa_pubkey, encrypted_key);\n\n    \u002F\u002F 7. Write: encrypted_data + encrypted_key + IV to file\n    write_file(filepath, encrypted_data, encrypted_key, iv);\n\n    \u002F\u002F 8. Rename file with ransomware extension\n    rename_file(filepath, strcat(filepath, \".locked\"));\n}\n```\n\n### Step 4: Check for Cryptographic Weaknesses\n\nTest the implementation for exploitable flaws:\n\n```python\nfrom Crypto.Cipher import AES\nimport os\nimport struct\n\n# Test 1: Check if same key is used for multiple files\n# Compare encrypted versions of known files\ndef check_key_reuse(file1_enc, file2_enc):\n    with open(file1_enc, \"rb\") as f:\n        data1 = f.read()\n    with open(file2_enc, \"rb\") as f:\n        data2 = f.read()\n\n    # Extract IVs (location depends on ransomware family)\n    # If IVs are same and files share encrypted blocks -> same key\n    iv1 = data1[-16:]  # Example: IV at end\n    iv2 = data2[-16:]\n    if iv1 == iv2:\n        print(\"[!] Same IV detected - key reuse likely\")\n\n# Test 2: Check for predictable key derivation\n# If key is derived from timestamp, iterate possible values\ndef brute_force_timestamp_key(encrypted_file, known_header, timestamp_range):\n    with open(encrypted_file, \"rb\") as f:\n        encrypted_data = f.read()\n\n    for ts in timestamp_range:\n        # Derive key the same way ransomware does\n        import hashlib\n        key = hashlib.sha256(str(ts).encode()).digest()\n        iv = encrypted_data[-16:]\n        cipher = AES.new(key, AES.MODE_CBC, iv)\n        decrypted = cipher.decrypt(encrypted_data[:16])\n\n        if decrypted[:len(known_header)] == known_header:\n            print(f\"[!] Key found! Timestamp: {ts}\")\n            return key\n\n    return None\n\n# Test 3: Check for ECB mode (pattern preservation)\ndef check_ecb_mode(encrypted_file):\n    with open(encrypted_file, \"rb\") as f:\n        data = f.read()\n    # ECB produces identical ciphertext for identical plaintext blocks\n    blocks = [data[i:i+16] for i in range(0, len(data), 16)]\n    unique = len(set(blocks))\n    total = len(blocks)\n    if unique \u003C total * 0.95:\n        print(f\"[!] ECB mode likely: {total-unique} duplicate blocks out of {total}\")\n```\n\n### Step 5: Attempt Key Recovery\n\nUse identified weaknesses for key recovery:\n\n```python\n# Recovery Method 1: Extract key from memory dump\n# Volatility plugin to scan for AES key schedules\n# vol3 -f memory.dmp windows.yarascan --yara-rule \"aes_key_schedule\"\n\n# Recovery Method 2: Known-plaintext attack (weak algorithms)\ndef xor_key_recovery(encrypted_file, known_plaintext):\n    \"\"\"Recover XOR key from known plaintext-ciphertext pair\"\"\"\n    with open(encrypted_file, \"rb\") as f:\n        ciphertext = f.read()\n\n    key = bytes(c ^ p for c, p in zip(ciphertext, known_plaintext))\n    # Find repeating key length\n    for key_len in range(1, 256):\n        candidate = key[:key_len]\n        if all(key[i] == candidate[i % key_len] for i in range(min(len(key), key_len * 4))):\n            print(f\"XOR key (length {key_len}): {candidate.hex()}\")\n            return candidate\n    return None\n\n# Recovery Method 3: Check NoMoreRansom for existing decryptors\n# https:\u002F\u002Fwww.nomoreransom.org\u002Fen\u002Fdecryption-tools.html\n```\n\n### Step 6: Document Encryption Analysis\n\nCompile findings into a structured report:\n\n```\nAnalysis should document:\n- Algorithm identified (AES, RSA, ChaCha20, custom)\n- Key size and mode of operation (CBC, CTR, ECB, GCM)\n- Key generation method (CSPRNG, predictable seed, static key)\n- Key storage location (appended to file, registry, C2 transmission)\n- File modification pattern (full encryption, partial, header-only)\n- Targeted file extensions\n- Ransom note format and payment infrastructure\n- Decryption feasibility assessment (possible\u002Fimpossible\u002Fpartial)\n- Recommended recovery approach\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Hybrid Encryption** | Combining symmetric (AES) for fast file encryption with asymmetric (RSA) for secure key wrapping; the standard ransomware approach |\n| **Key Wrapping** | Encrypting the per-file symmetric key with the attacker's RSA public key so only the attacker's private key can decrypt it |\n| **ECB Mode** | Electronic Codebook mode encrypts each block independently; preserves patterns in plaintext, a critical weakness enabling partial recovery |\n| **Known-Plaintext Attack** | Using a known original file and its encrypted version to derive the encryption key; effective against XOR and weak stream ciphers |\n| **Key Schedule** | The expanded form of an AES key in memory; scannable in memory dumps to recover encryption keys before they are erased |\n| **CSPRNG** | Cryptographically Secure Pseudo-Random Number Generator; ransomware using CryptGenRandom produces unpredictable keys |\n| **Partial Encryption** | Some ransomware only encrypts the first N bytes or every Nth block for speed; unencrypted portions may aid recovery |\n\n## Tools & Systems\n\n- **Ghidra**: Reverse engineering suite for analyzing ransomware encryption routines at the assembly level\n- **PyCryptodome**: Python cryptographic library for implementing and testing decryption routines\n- **NoMoreRansom.org**: Free decryption tool repository maintained by Europol and security vendors for known ransomware families\n- **Volatility**: Memory forensics framework for extracting encryption keys from RAM dumps of infected systems\n- **CryptoTester**: Tool for identifying cryptographic algorithms based on constants and code patterns\n\n## Common Scenarios\n\n### Scenario: Assessing Decryption Feasibility for a Ransomware Incident\n\n**Context**: An organization is hit with ransomware encrypting file servers. Management needs to know if decryption is possible without paying the ransom before making a recovery decision.\n\n**Approach**:\n1. Identify the ransomware family from ransom note, file extension, and sample hash (check ID Ransomware)\n2. Check NoMoreRansom.org for existing free decryptors for this family\n3. Reverse engineer the encryption routine in Ghidra to identify the algorithm and key management\n4. Test for implementation weaknesses (key reuse, predictable seeds, ECB mode)\n5. Check if PCAP from the incident captured the key transmission to C2 (if key was sent before encryption)\n6. Scan memory dumps from affected machines for AES key schedules in RAM\n7. Report findings: decryption possible\u002Fimpossible with specific technical justification\n\n**Pitfalls**:\n- Testing decryption methods on the only copy of encrypted files (always work on copies)\n- Assuming all files use the same key without verifying (some ransomware uses per-file keys)\n- Not checking for volume shadow copies (vssadmin) which ransomware may have failed to delete\n- Confusing the file encryption algorithm with the key wrapping algorithm in reports\n\n## Output Format\n\n```\nRANSOMWARE ENCRYPTION ANALYSIS\n================================\nSample:           lockbit3.exe\nFamily:           LockBit 3.0 \u002F LockBit Black\nSHA-256:          abc123def456...\n\nENCRYPTION SCHEME\nFile Cipher:      AES-256-CTR (per-file unique key)\nKey Wrapping:     RSA-2048 (public key embedded in binary)\nKey Generation:   CryptGenRandom (CSPRNG - unpredictable)\nIV Generation:    Random 16 bytes per file\nFile Structure:   [encrypted_data][rsa_encrypted_key(256B)][iv(16B)][magic(8B)]\n\nTARGETED EXTENSIONS\nTotal:            412 extensions targeted\nCategories:       Documents (.doc, .xls, .pdf), Databases (.sql, .mdb),\n                  Archives (.zip, .7z), Source code (.py, .java, .cs)\nExcluded:         .exe, .dll, .sys, .lnk (system files preserved)\n\nIMPLEMENTATION ANALYSIS\nKey Strength:     STRONG - per-file random keys, no reuse\nMode Security:    STRONG - CTR mode with unique nonces\nKey Storage:      RSA-encrypted key appended to each file\nShadow Copies:    Deleted via vssadmin and WMI\n\nDECRYPTION FEASIBILITY\nWithout Key:      NOT POSSIBLE\n  - No implementation flaws identified\n  - RSA-2048 key wrapping prevents brute force\n  - CSPRNG prevents key prediction\n  - No existing free decryptor available\n\nRECOVERY OPTIONS\n1. Restore from offline backups (recommended)\n2. Check for volume shadow copies (low probability - ransomware deletes them)\n3. Memory forensics if machine was not rebooted (key may persist in RAM)\n4. Negotiate with attacker (last resort - no guarantee of decryption)\n```\n","# Analyzing Ransomware Encryption Mechanisms\n\n## When to Use\n\n- A ransomware infection has occurred and recovery requires understanding the encryption scheme used\n- Assessing whether decryption is possible without paying the ransom (implementation flaws, known decryptors)\n- Reverse engineering ransomware to identify the encryption algorithm, key derivation, and key storage mechanism\n- Developing a decryptor tool when a weakness in the ransomware's cryptographic implementation is identified\n- Classifying a ransomware sample by its encryption approach to attribute it to a known family\n\n**Do not use** for production data recovery operations without first verifying the decryption method on test copies of encrypted files.\n\n## Prerequisites\n\n- Ghidra or IDA Pro for reverse engineering the ransomware binary\n- Python 3.8+ with `pycryptodome` library for testing encryption\u002Fdecryption routines\n- Sample encrypted files and their corresponding plaintext originals (known-plaintext pairs)\n- Access to the ransomware binary (unpacked if applicable)\n- Familiarity with symmetric (AES, ChaCha20) and asymmetric (RSA) cryptographic algorithms\n- NoMoreRansom.org database for checking existing free decryptors\n\n## Workflow\n\n### Step 1: Identify the Encryption Algorithm\n\nDetermine which cryptographic algorithm the ransomware uses:\n\n```python\n# Check for Windows Crypto API usage in imports\nimport pefile\n\npe = pefile.PE(\"ransomware.exe\")\n\ncrypto_apis = {\n    \"CryptAcquireContextA\": \"Windows CryptoAPI\",\n    \"CryptAcquireContextW\": \"Windows CryptoAPI\",\n    \"CryptGenKey\": \"Windows CryptoAPI key generation\",\n    \"CryptEncrypt\": \"Windows CryptoAPI encryption\",\n    \"CryptImportKey\": \"Windows CryptoAPI key import\",\n    \"BCryptOpenAlgorithmProvider\": \"Windows CNG (modern crypto)\",\n    \"BCryptEncrypt\": \"Windows CNG encryption\",\n    \"BCryptGenerateKeyPair\": \"Windows CNG asymmetric key gen\",\n}\n\nprint(\"Crypto API Imports:\")\nfor entry in pe.DIRECTORY_ENTRY_IMPORT:\n    for imp in entry.imports:\n        if imp.name and imp.name.decode() in crypto_apis:\n            print(f\"  {entry.dll.decode()} -> {imp.name.decode()}: {crypto_apis[imp.name.decode()]}\")\n```\n\n```\nCommon Ransomware Encryption Schemes:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nAES-256-CBC + RSA-2048:    Most common hybrid scheme (LockBit, REvil, Conti)\nAES-256-CTR + RSA-4096:    Stream cipher mode variant (BlackCat\u002FALPHV)\nChaCha20 + RSA-4096:       Modern stream cipher (Hive, Royal)\nSalsa20 + ECDH:            Curve25519 key exchange (Babuk)\nAES-128-ECB:               Weak mode - potential decryption via known-plaintext\nXOR-only:                  Trivial encryption - always recoverable\nCustom algorithm:          Often contains implementation flaws\n```\n\n### Step 2: Analyze Key Generation and Management\n\nReverse engineer how encryption keys are generated and stored:\n\n```\nKey Management Patterns in Ransomware:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n1. STRONG (no recovery possible without key):\n   - Per-file AES key generated with CryptGenRandom\n   - AES key encrypted with embedded RSA public key\n   - Encrypted key appended to each file or stored separately\n   - RSA private key held only by attacker's C2 server\n\n2. WEAK (potential recovery):\n   - AES key derived from predictable seed (timestamp, PID)\n   - Same AES key used for all files (single key compromise = full recovery)\n   - Key transmitted to C2 before encryption starts (PCAP may contain key)\n   - XOR with short repeating key (brute-forceable)\n   - PRNG seeded with GetTickCount or time() (limited keyspace)\n\n3. FLAWED IMPLEMENTATION:\n   - ECB mode (preserves plaintext patterns)\n   - Initialization vector (IV) reuse across files\n   - Key stored in plaintext in memory (recoverable from memory dump)\n   - Partial encryption (only first N bytes encrypted)\n```\n\n### Step 3: Examine File Encryption Routine\n\nReverse engineer the file processing logic:\n\n```c\n\u002F\u002F Typical ransomware file encryption flow (decompiled pseudo-code from Ghidra):\n\nvoid encrypt_file(char *filepath) {\n    \u002F\u002F 1. Check file extension against target list\n    if (!is_target_extension(filepath)) return;\n\n    \u002F\u002F 2. Generate per-file AES key (32 bytes for AES-256)\n    BYTE aes_key[32];\n    CryptGenRandom(hProv, 32, aes_key);\n\n    \u002F\u002F 3. Generate random IV (16 bytes)\n    BYTE iv[16];\n    CryptGenRandom(hProv, 16, iv);\n\n    \u002F\u002F 4. Read file contents\n    HANDLE hFile = CreateFile(filepath, GENERIC_READ, ...);\n    BYTE *plaintext = read_entire_file(hFile);\n\n    \u002F\u002F 5. Encrypt with AES-256-CBC\n    aes_cbc_encrypt(plaintext, file_size, aes_key, iv);\n\n    \u002F\u002F 6. Encrypt AES key with RSA public key\n    BYTE encrypted_key[256];  \u002F\u002F RSA-2048 output\n    rsa_encrypt(aes_key, 32, rsa_pubkey, encrypted_key);\n\n    \u002F\u002F 7. Write: encrypted_data + encrypted_key + IV to file\n    write_file(filepath, encrypted_data, encrypted_key, iv);\n\n    \u002F\u002F 8. Rename file with ransomware extension\n    rename_file(filepath, strcat(filepath, \".locked\"));\n}\n```\n\n### Step 4: Check for Cryptographic Weaknesses\n\nTest the implementation for exploitable flaws:\n\n```python\nfrom Crypto.Cipher import AES\nimport os\nimport struct\n\n# Test 1: Check if same key is used for multiple files\n# Compare encrypted versions of known files\ndef check_key_reuse(file1_enc, file2_enc):\n    with open(file1_enc, \"rb\") as f:\n        data1 = f.read()\n    with open(file2_enc, \"rb\") as f:\n        data2 = f.read()\n\n    # Extract IVs (location depends on ransomware family)\n    # If IVs are same and files share encrypted blocks -> same key\n    iv1 = data1[-16:]  # Example: IV at end\n    iv2 = data2[-16:]\n    if iv1 == iv2:\n        print(\"[!] Same IV detected - key reuse likely\")\n\n# Test 2: Check for predictable key derivation\n# If key is derived from timestamp, iterate possible values\ndef brute_force_timestamp_key(encrypted_file, known_header, timestamp_range):\n    with open(encrypted_file, \"rb\") as f:\n        encrypted_data = f.read()\n\n    for ts in timestamp_range:\n        # Derive key the same way ransomware does\n        import hashlib\n        key = hashlib.sha256(str(ts).encode()).digest()\n        iv = encrypted_data[-16:]\n        cipher = AES.new(key, AES.MODE_CBC, iv)\n        decrypted = cipher.decrypt(encrypted_data[:16])\n\n        if decrypted[:len(known_header)] == known_header:\n            print(f\"[!] Key found! Timestamp: {ts}\")\n            return key\n\n    return None\n\n# Test 3: Check for ECB mode (pattern preservation)\ndef check_ecb_mode(encrypted_file):\n    with open(encrypted_file, \"rb\") as f:\n        data = f.read()\n    # ECB produces identical ciphertext for identical plaintext blocks\n    blocks = [data[i:i+16] for i in range(0, len(data), 16)]\n    unique = len(set(blocks))\n    total = len(blocks)\n    if unique \u003C total * 0.95:\n        print(f\"[!] ECB mode likely: {total-unique} duplicate blocks out of {total}\")\n```\n\n### Step 5: Attempt Key Recovery\n\nUse identified weaknesses for key recovery:\n\n```python\n# Recovery Method 1: Extract key from memory dump\n# Volatility plugin to scan for AES key schedules\n# vol3 -f memory.dmp windows.yarascan --yara-rule \"aes_key_schedule\"\n\n# Recovery Method 2: Known-plaintext attack (weak algorithms)\ndef xor_key_recovery(encrypted_file, known_plaintext):\n    \"\"\"Recover XOR key from known plaintext-ciphertext pair\"\"\"\n    with open(encrypted_file, \"rb\") as f:\n        ciphertext = f.read()\n\n    key = bytes(c ^ p for c, p in zip(ciphertext, known_plaintext))\n    # Find repeating key length\n    for key_len in range(1, 256):\n        candidate = key[:key_len]\n        if all(key[i] == candidate[i % key_len] for i in range(min(len(key), key_len * 4))):\n            print(f\"XOR key (length {key_len}): {candidate.hex()}\")\n            return candidate\n    return None\n\n# Recovery Method 3: Check NoMoreRansom for existing decryptors\n# https:\u002F\u002Fwww.nomoreransom.org\u002Fen\u002Fdecryption-tools.html\n```\n\n### Step 6: Document Encryption Analysis\n\nCompile findings into a structured report:\n\n```\nAnalysis should document:\n- Algorithm identified (AES, RSA, ChaCha20, custom)\n- Key size and mode of operation (CBC, CTR, ECB, GCM)\n- Key generation method (CSPRNG, predictable seed, static key)\n- Key storage location (appended to file, registry, C2 transmission)\n- File modification pattern (full encryption, partial, header-only)\n- Targeted file extensions\n- Ransom note format and payment infrastructure\n- Decryption feasibility assessment (possible\u002Fimpossible\u002Fpartial)\n- Recommended recovery approach\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Hybrid Encryption** | Combining symmetric (AES) for fast file encryption with asymmetric (RSA) for secure key wrapping; the standard ransomware approach |\n| **Key Wrapping** | Encrypting the per-file symmetric key with the attacker's RSA public key so only the attacker's private key can decrypt it |\n| **ECB Mode** | Electronic Codebook mode encrypts each block independently; preserves patterns in plaintext, a critical weakness enabling partial recovery |\n| **Known-Plaintext Attack** | Using a known original file and its encrypted version to derive the encryption key; effective against XOR and weak stream ciphers |\n| **Key Schedule** | The expanded form of an AES key in memory; scannable in memory dumps to recover encryption keys before they are erased |\n| **CSPRNG** | Cryptographically Secure Pseudo-Random Number Generator; ransomware using CryptGenRandom produces unpredictable keys |\n| **Partial Encryption** | Some ransomware only encrypts the first N bytes or every Nth block for speed; unencrypted portions may aid recovery |\n\n## Tools & Systems\n\n- **Ghidra**: Reverse engineering suite for analyzing ransomware encryption routines at the assembly level\n- **PyCryptodome**: Python cryptographic library for implementing and testing decryption routines\n- **NoMoreRansom.org**: Free decryption tool repository maintained by Europol and security vendors for known ransomware families\n- **Volatility**: Memory forensics framework for extracting encryption keys from RAM dumps of infected systems\n- **CryptoTester**: Tool for identifying cryptographic algorithms based on constants and code patterns\n\n## Common Scenarios\n\n### Scenario: Assessing Decryption Feasibility for a Ransomware Incident\n\n**Context**: An organization is hit with ransomware encrypting file servers. Management needs to know if decryption is possible without paying the ransom before making a recovery decision.\n\n**Approach**:\n1. Identify the ransomware family from ransom note, file extension, and sample hash (check ID Ransomware)\n2. Check NoMoreRansom.org for existing free decryptors for this family\n3. Reverse engineer the encryption routine in Ghidra to identify the algorithm and key management\n4. Test for implementation weaknesses (key reuse, predictable seeds, ECB mode)\n5. Check if PCAP from the incident captured the key transmission to C2 (if key was sent before encryption)\n6. Scan memory dumps from affected machines for AES key schedules in RAM\n7. Report findings: decryption possible\u002Fimpossible with specific technical justification\n\n**Pitfalls**:\n- Testing decryption methods on the only copy of encrypted files (always work on copies)\n- Assuming all files use the same key without verifying (some ransomware uses per-file keys)\n- Not checking for volume shadow copies (vssadmin) which ransomware may have failed to delete\n- Confusing the file encryption algorithm with the key wrapping algorithm in reports\n\n## Output Format\n\n```\nRANSOMWARE ENCRYPTION ANALYSIS\n================================\nSample:           lockbit3.exe\nFamily:           LockBit 3.0 \u002F LockBit Black\nSHA-256:          abc123def456...\n\nENCRYPTION SCHEME\nFile Cipher:      AES-256-CTR (per-file unique key)\nKey Wrapping:     RSA-2048 (public key embedded in binary)\nKey Generation:   CryptGenRandom (CSPRNG - unpredictable)\nIV Generation:    Random 16 bytes per file\nFile Structure:   [encrypted_data][rsa_encrypted_key(256B)][iv(16B)][magic(8B)]\n\nTARGETED EXTENSIONS\nTotal:            412 extensions targeted\nCategories:       Documents (.doc, .xls, .pdf), Databases (.sql, .mdb),\n                  Archives (.zip, .7z), Source code (.py, .java, .cs)\nExcluded:         .exe, .dll, .sys, .lnk (system files preserved)\n\nIMPLEMENTATION ANALYSIS\nKey Strength:     STRONG - per-file random keys, no reuse\nMode Security:    STRONG - CTR mode with unique nonces\nKey Storage:      RSA-encrypted key appended to each file\nShadow Copies:    Deleted via vssadmin and WMI\n\nDECRYPTION FEASIBILITY\nWithout Key:      NOT POSSIBLE\n  - No implementation flaws identified\n  - RSA-2048 key wrapping prevents brute force\n  - CSPRNG prevents key prediction\n  - No existing free decryptor available\n\nRECOVERY OPTIONS\n1. Restore from offline backups (recommended)\n2. Check for volume shadow copies (low probability - ransomware deletes them)\n3. Memory forensics if machine was not rebooted (key may persist in RAM)\n4. Negotiate with attacker (last resort - no guarantee of decryption)\n```\n",{"name":5,"tags":44,"capec":45,"model":23,"tools":46,"domain":34,"maxTurns":50,"nist_csf":51,"subdomain":56,"description":7,"mitre_attack":57},[25,22,32,30,38],[],[47,33,48,49],"Read","Glob","Grep",20,[52,53,54,55],"DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01","malware-analysis",[58],"T1486","main","a91f1293287ffa9f4f1b8f486cd6e835a1568c84","skills\u002Fmalware\u002Ffamily\u002Fransomware\u002Fdetect","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace","https:\u002F\u002Fgithub.com\u002FDCx7C5","#Python","2026-09-01 11:21:00",{"source":8,"skillName":5,"commands":67,"prompt":77,"zipAvailable":78},[68,71,74],{"tool":69,"command":70},"npx","npx skills add DCx7C5\u002Fai-marketplace --skill family-ransomware-detect",{"tool":72,"command":73},"bunx","bunx skills add DCx7C5\u002Fai-marketplace --skill family-ransomware-detect",{"tool":75,"command":76},"pnpm","pnpm dlx skills add DCx7C5\u002Fai-marketplace --skill family-ransomware-detect","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fmalware\u002Ffamily\u002Fransomware\u002Fdetect\u002FSKILL.md",true,[80],{"path":81,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":84,"sourceHtmlUrl":85},"index.json","REFERENCE","参考文档",687,"https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fmalware\u002Ffamily\u002Fransomware\u002Fdetect\u002Findex.json",[87,109,129,150,172,188],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":39},"01M71HAPZ01KQ30RKTB0FFSQ05","services-wmi-persistence-detect","Detect WMI event subscription persistence by enumerating ActiveScriptEventConsumer, CommandLineEventConsumer, and permanent subscriptions in the WMI repository.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fservices\u002Fwmi\u002Fpersistence\u002Fdetect\u002FSKILL.md",[],[94,21,95,96,97,29,37,98,99,100,101,102,103,104,105,106,107,34,108],"services","services wmi persistence detect","wmi","persistence","process","activescript","event","subscriptions","commandline-consumer","repository","subscription","event-subscription","t1546.003","forensics","process-forensics",{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":39},"01M71HAK6JTTTS229T17WJMMCG","services-wmi-exec-exploit","Perform lateral movement across Windows networks using WMI-based remote execution techniques including Impacket wmiexec.py, CrackMapExec, and native WMI commands for stealthy post-exploitation during red team engagements.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fservices\u002Fwmi\u002Fexec\u002Fexploit\u002FSKILL.md",[],[116,94,117,96,118,119,120,34,33,31,121,122,123,124,29,125,126,26,127,128],"exploit","services wmi exec exploit","exec","remote","traffic","team","across","crackmapexec","native","command","lateral movement","lateral-movement","Impacket",{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":135,"publishedAt":39},"01M71HAG6MHKNQV8KDZKMT4886","registry-artifact-extract","Extract and analyze Windows Registry hives to uncover user activity, installed software, autostart entries, and evidence of system compromise.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fregistry\u002Fartifact\u002Fextract\u002FSKILL.md",[],[136,137,138,139,140,141,34,33,142,31,143,144,29,26,145,146,147,148,149,23],"artifact","registry","registry artifact extract","extract","evidence-collection","artifact-analysis","collection","analyze","uncover","software","activity","digital-forensics","windows-registry","regripper",{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":39},"01M71HACR4A8XTWTTSXK4124AA","processes-token-impersonate-detect","Detect Windows token impersonation and privilege abuse including SeImpersonatePrivilege exploitation via Potato attacks and token stealing techniques.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Ftoken\u002Fimpersonate\u002Fdetect\u002FSKILL.md",[],[21,157,158,159,160,161,162,37,163,34,108,164,165,166,167,168,169,170,171,29],"processes token impersonate detect","token","processes","attacks","windows","escalation","techniques","privilege-escalation","seimpersonate","token-impersonation","printspoofer","exploitation","potato","impersonation","via",{"skillNo":173,"name":174,"nameZh":6,"description":175,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":176,"categories":177,"keywords":178,"publishedAt":39},"01M71HAABSB4Z6QFSXEG00R4RK","processes-thread-injection-detect","Detect Windows thread injection techniques including CreateRemoteThread, QueueUserAPC, NtCreateThreadEx, and thread hijacking via process memory analysis.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Fthread\u002Finjection\u002Fdetect\u002FSKILL.md",[],[179,180,21,181,159,161,182,37,183,163,34,108,31,184,185,186,187,171,29,98],"thread","processes thread injection detect","injection","memory","process-injection","api","apc-injection","thread-injection","nt-api",{"skillNo":189,"name":190,"nameZh":6,"description":191,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":192,"categories":193,"keywords":194,"publishedAt":39},"01M71HA7H311V5G14WMX58HQSS","processes-hollow-technique-detect","Detect process hollowing (RunPE) by identifying processes with mismatched image paths between PEB and VAD tree, or unmapped PE headers in memory.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Fhollow\u002Ftechnique\u002Fdetect\u002FSKILL.md",[],[195,21,159,196,182,37,197,198,34,108,199,200,201,202,203,204,29,98,205,206],"processes hollow technique detect","tree","memory-forensics","process-hollow","peb","runpe","image","pe-header","in memory","with","mismatched","headers"]