[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AB3FFASRVDQFGKFYRTQN2P":3,"skill-same:01M7AB3FFASRVDQFGKFYRTQN2P":126},{"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":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":71,"commitSha":72,"skillDirectory":73,"forksCount":14,"repositoryHtmlUrl":74,"repositoryHomepageUrl":6,"ownerHtmlUrl":75,"ownerBlogUrl":6,"ownerDescription":76,"updatedAt":77,"install":78,"resources":91},"01M7AB3FFASRVDQFGKFYRTQN2P","reverse-engineering-ransomware-encryption-routine",null,"Reverse engineer ransomware encryption routines to identify cryptographic algorithms, key generation flaws, and potential decryption opportunities using static and dynamic analysis.","NeelakshSaxena\u002FVayu","NeelakshSaxena","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F87892838?v=4","01M7A3B9YFS6F6N9DD1787DT86","Neelaksh Saxena","01M7A3B9ZKBT09MNMPX2XN69BY",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-ransomware-encryption-routine\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-ransomware-encryption-routine\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: reverse-engineering-ransomware-encryption-routine\ndescription: Reverse engineer ransomware encryption routines to identify cryptographic\n  algorithms, key generation flaws, and potential decryption opportunities using static\n  and dynamic analysis.\ndomain: cybersecurity\nsubdomain: malware-analysis\ntags:\n- ransomware\n- encryption\n- reverse-engineering\n- cryptanalysis\n- aes\n- rsa\n- decryption\n- malware-analysis\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nd3fend_techniques:\n- File Metadata Consistency Validation\n- Content Format Conversion\n- File Content Analysis\n- Platform Hardening\n- File Format Verification\nnist_csf:\n- DE.AE-02\n- RS.AN-03\n- ID.RA-01\n- DE.CM-01\nmitre_attack:\n- T1027\n- T1055\n- T1140\n- T1497\n- T1486\nmitre_f3:\n  version: '1.1'\n  tactics:\n  - monetization\n  - positioning\n  techniques:\n  - id: F1018\n    name: Convert to Cryptocurrency\n    tactic: monetization\n    source: f3\n  - id: F1047\n    name: Transfer of funds\n    tactic: monetization\n    source: f3\n  - id: T1219\n    name: Remote Access Tools\n    tactic: positioning\n    source: attack\n---\n# Reverse Engineering Ransomware Encryption Routine\n\n## Overview\n\nModern ransomware uses hybrid encryption combining symmetric algorithms (AES-256-CBC\u002FCTR, ChaCha20, Salsa20) for file encryption with asymmetric algorithms (RSA-2048\u002F4096, Curve25519) for key protection. The encryption routine typically generates a random symmetric key per file, encrypts file contents, then encrypts the symmetric key with the attacker's embedded public key. Reverse engineering these routines identifies the specific algorithms, key derivation methods, initialization vectors, file targeting patterns, and potential implementation flaws that could enable decryption without paying the ransom. Notable examples include Rhysida (AES-256-CTR + RSA-4096), Qilin.B (AES-256-CTR with AES-NI or ChaCha20 fallback), and Medusa (AES-256 + RSA).\n\n\n## When to Use\n\n- When performing authorized security testing that involves reverse engineering ransomware encryption routine\n- When analyzing malware samples or attack artifacts in a controlled environment\n- When conducting red team exercises or penetration testing engagements\n- When building detection capabilities based on offensive technique understanding\n\n## Prerequisites\n\n- IDA Pro or Ghidra for static disassembly\n- x64dbg\u002FWinDbg for dynamic debugging\n- Python 3.9+ with `pycryptodome`, `pefile`\n- Understanding of AES, RSA, ChaCha20, Curve25519 algorithms\n- Knowledge of Windows CryptoAPI and CNG (BCrypt) functions\n- Sandbox environment for safe execution\n\n## Key Concepts\n\n### Hybrid Encryption Model\n\nRansomware generates a unique AES key and IV for each file. The file content is encrypted with this symmetric key. The symmetric key is then encrypted with the attacker's RSA public key (embedded in the binary or fetched from C2). The encrypted key is appended or prepended to the encrypted file. Only the attacker holding the RSA private key can decrypt the per-file symmetric keys.\n\n### Cryptographic API Identification\n\nWindows ransomware typically uses CryptoAPI (`CryptAcquireContext`, `CryptGenKey`, `CryptEncrypt`) or CNG (`BCryptGenerateSymmetricKey`, `BCryptEncrypt`). Some use OpenSSL or custom implementations. Identifying these API calls provides immediate insight into the algorithm, key size, and mode of operation.\n\n### Implementation Flaws\n\nDecryption opportunities arise from: hardcoded encryption keys, weak PRNG for key generation (using `GetTickCount` or `time()` as seed), reuse of IVs across files, ECB mode usage, keys remaining in memory post-encryption, and race conditions where keys can be captured during encryption.\n\n## Workflow\n\n### Step 1: Identify Cryptographic Functions\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"Identify cryptographic functions in ransomware PE files.\"\"\"\nimport pefile\nimport sys\n\nCRYPTO_APIS = {\n    # Windows CryptoAPI\n    \"CryptAcquireContextA\": \"CryptoAPI context acquisition\",\n    \"CryptAcquireContextW\": \"CryptoAPI context acquisition\",\n    \"CryptGenKey\": \"Key generation\",\n    \"CryptDeriveKey\": \"Key derivation\",\n    \"CryptEncrypt\": \"Encryption operation\",\n    \"CryptDecrypt\": \"Decryption operation\",\n    \"CryptImportKey\": \"Key import (public key?)\",\n    \"CryptExportKey\": \"Key export\",\n    \"CryptGenRandom\": \"Random number generation\",\n    \"CryptCreateHash\": \"Hash creation\",\n    \"CryptHashData\": \"Hashing operation\",\n    # Windows CNG (BCrypt)\n    \"BCryptOpenAlgorithmProvider\": \"CNG algorithm initialization\",\n    \"BCryptGenerateSymmetricKey\": \"CNG symmetric key generation\",\n    \"BCryptEncrypt\": \"CNG encryption\",\n    \"BCryptDecrypt\": \"CNG decryption\",\n    \"BCryptGenerateKeyPair\": \"CNG key pair generation\",\n    \"BCryptImportKeyPair\": \"CNG key import\",\n    # OpenSSL\n    \"EVP_EncryptInit_ex\": \"OpenSSL encrypt init\",\n    \"EVP_EncryptUpdate\": \"OpenSSL encrypt update\",\n    \"EVP_EncryptFinal_ex\": \"OpenSSL encrypt final\",\n    \"RSA_public_encrypt\": \"OpenSSL RSA encryption\",\n    \"AES_set_encrypt_key\": \"OpenSSL AES key setup\",\n    # File operations\n    \"CreateFileW\": \"File open (target files)\",\n    \"ReadFile\": \"File read (before encryption)\",\n    \"WriteFile\": \"File write (after encryption)\",\n    \"FindFirstFileW\": \"File enumeration (targeting)\",\n    \"FindNextFileW\": \"File enumeration\",\n    \"MoveFileW\": \"File rename (extension change)\",\n    \"DeleteFileW\": \"File deletion (originals)\",\n}\n\nAES_SBOX = bytes([\n    0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,\n    0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,\n])\n\nCHACHA20_CONSTANT = b\"expand 32-byte k\"\n\n\ndef analyze_imports(filepath):\n    \"\"\"Analyze PE imports for cryptographic APIs.\"\"\"\n    try:\n        pe = pefile.PE(filepath)\n    except pefile.PEFormatError:\n        print(\"[-] Not a valid PE file\")\n        return\n\n    print(\"[+] Cryptographic API Analysis\")\n    print(\"=\" * 60)\n\n    crypto_imports = []\n    if hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):\n        for entry in pe.DIRECTORY_ENTRY_IMPORT:\n            dll = entry.dll.decode('utf-8', errors='replace')\n            for imp in entry.imports:\n                if imp.name:\n                    name = imp.name.decode('utf-8', errors='replace')\n                    if name in CRYPTO_APIS:\n                        desc = CRYPTO_APIS[name]\n                        crypto_imports.append((dll, name, desc))\n                        print(f\"  [{dll}] {name}: {desc}\")\n\n    if not crypto_imports:\n        print(\"  No known crypto APIs found in imports\")\n        print(\"  Malware may use custom implementation or dynamic loading\")\n\n    return crypto_imports\n\n\ndef find_crypto_constants(filepath):\n    \"\"\"Search for embedded cryptographic constants.\"\"\"\n    with open(filepath, 'rb') as f:\n        data = f.read()\n\n    print(\"\\n[+] Cryptographic Constants Search\")\n    print(\"=\" * 60)\n\n    # AES S-Box\n    offset = data.find(AES_SBOX)\n    if offset != -1:\n        print(f\"  AES S-Box found at offset 0x{offset:x}\")\n\n    # ChaCha20\u002FSalsa20 constant\n    offset = data.find(CHACHA20_CONSTANT)\n    if offset != -1:\n        print(f\"  ChaCha20 constant at offset 0x{offset:x}\")\n\n    # RSA public key markers\n    rsa_markers = [\n        b'-----BEGIN PUBLIC KEY-----',\n        b'-----BEGIN RSA PUBLIC KEY-----',\n        b'\\x30\\x82',  # ASN.1 SEQUENCE\n    ]\n    for marker in rsa_markers:\n        offset = data.find(marker)\n        if offset != -1:\n            print(f\"  RSA key marker at offset 0x{offset:x}\")\n\n    # Common ransomware file extension patterns\n    import re\n    ext_pattern = re.compile(rb'\\.\\w{3,10}(?=\\x00)', re.IGNORECASE)\n    extensions = set()\n    for match in ext_pattern.finditer(data):\n        ext = match.group().decode('ascii', errors='replace').lower()\n        target_exts = [\n            '.doc', '.docx', '.xls', '.xlsx', '.pdf', '.ppt',\n            '.jpg', '.png', '.sql', '.mdb', '.bak', '.zip',\n        ]\n        if ext in target_exts:\n            extensions.add(ext)\n\n    if extensions:\n        print(f\"\\n  Target file extensions: {', '.join(sorted(extensions))}\")\n\n\nif __name__ == \"__main__\":\n    if len(sys.argv) \u003C 2:\n        print(f\"Usage: {sys.argv[0]} \u003Cransomware_sample>\")\n        sys.exit(1)\n\n    analyze_imports(sys.argv[1])\n    find_crypto_constants(sys.argv[1])\n```\n\n### Step 2: Analyze Encryption Flow\n\n```python\ndef analyze_encryption_pattern(filepath):\n    \"\"\"Analyze file encryption patterns from ransomware artifacts.\"\"\"\n    import os\n    import struct\n\n    with open(filepath, 'rb') as f:\n        data = f.read()\n\n    file_size = len(data)\n    print(f\"\\n[+] Encrypted File Analysis: {filepath}\")\n    print(f\"  Size: {file_size:,} bytes\")\n\n    # Check for appended key material (common pattern)\n    # Many ransomware families append encrypted key at end of file\n    tail_sizes = [256, 512, 1024, 2048]  # Common RSA ciphertext sizes\n    for size in tail_sizes:\n        if file_size > size + 16:\n            tail = data[-size:]\n            # High entropy suggests encrypted data\n            entropy = calculate_entropy(tail)\n            if entropy > 7.5:\n                print(f\"  Possible encrypted key ({size} bytes) \"\n                      f\"at end of file (entropy: {entropy:.2f})\")\n\n    # Check for header modifications\n    # Many ransomware prepend metadata\n    header = data[:64]\n    print(f\"  First 16 bytes: {header[:16].hex()}\")\n\n    # Check if original file header is preserved\n    known_headers = {\n        b'PK': 'ZIP\u002FOffice',\n        b'\\x89PNG': 'PNG',\n        b'\\xff\\xd8\\xff': 'JPEG',\n        b'%PDF': 'PDF',\n        b'\\xd0\\xcf\\x11\\xe0': 'OLE (DOC\u002FXLS)',\n    }\n    for magic, ftype in known_headers.items():\n        if header.startswith(magic):\n            print(f\"  Original format preserved: {ftype}\")\n            break\n    else:\n        print(\"  Original header destroyed\u002Fencrypted\")\n\n\ndef calculate_entropy(data):\n    \"\"\"Calculate Shannon entropy of data.\"\"\"\n    from collections import Counter\n    import math\n\n    if not data:\n        return 0\n\n    freq = Counter(data)\n    length = len(data)\n    entropy = -sum(\n        (count \u002F length) * math.log2(count \u002F length)\n        for count in freq.values()\n    )\n    return entropy\n```\n\n## Validation Criteria\n\n- Cryptographic algorithms identified (AES, RSA, ChaCha20, etc.)\n- Key size and mode of operation determined\n- Key generation method analyzed for potential weaknesses\n- Per-file key encryption scheme documented\n- File targeting patterns and extension list extracted\n- Embedded public keys extracted for infrastructure correlation\n- Potential decryption opportunities assessed\n\n## References\n\n- [Morphisec - Breaking Down Ransomware Encryption](https:\u002F\u002Fwww.morphisec.com\u002Fblog\u002Fbreaking-down-ransomware-encryption-key-strategies-algorithms-and-implementation-trends\u002F)\n- [Emsisoft - Ransomware Encryption Methods](https:\u002F\u002Fwww.emsisoft.com\u002Fen\u002Fblog\u002F27649\u002Fransomware-encryption-methods\u002F)\n- [Halcyon Ransomware Power Rankings Q4-2024](https:\u002F\u002Fwww.halcyon.ai\u002Fraas-mq\u002Fpower-rankings-ransomware-malicious-quartile-q4-2024)\n- [No More Ransom Project](https:\u002F\u002Fwww.nomoreransom.org\u002F)\n- [MITRE ATT&CK T1486 - Data Encrypted for Impact](https:\u002F\u002Fattack.mitre.org\u002Ftechniques\u002FT1486\u002F)\n","# Reverse Engineering Ransomware Encryption Routine\n\n## Overview\n\nModern ransomware uses hybrid encryption combining symmetric algorithms (AES-256-CBC\u002FCTR, ChaCha20, Salsa20) for file encryption with asymmetric algorithms (RSA-2048\u002F4096, Curve25519) for key protection. The encryption routine typically generates a random symmetric key per file, encrypts file contents, then encrypts the symmetric key with the attacker's embedded public key. Reverse engineering these routines identifies the specific algorithms, key derivation methods, initialization vectors, file targeting patterns, and potential implementation flaws that could enable decryption without paying the ransom. Notable examples include Rhysida (AES-256-CTR + RSA-4096), Qilin.B (AES-256-CTR with AES-NI or ChaCha20 fallback), and Medusa (AES-256 + RSA).\n\n\n## When to Use\n\n- When performing authorized security testing that involves reverse engineering ransomware encryption routine\n- When analyzing malware samples or attack artifacts in a controlled environment\n- When conducting red team exercises or penetration testing engagements\n- When building detection capabilities based on offensive technique understanding\n\n## Prerequisites\n\n- IDA Pro or Ghidra for static disassembly\n- x64dbg\u002FWinDbg for dynamic debugging\n- Python 3.9+ with `pycryptodome`, `pefile`\n- Understanding of AES, RSA, ChaCha20, Curve25519 algorithms\n- Knowledge of Windows CryptoAPI and CNG (BCrypt) functions\n- Sandbox environment for safe execution\n\n## Key Concepts\n\n### Hybrid Encryption Model\n\nRansomware generates a unique AES key and IV for each file. The file content is encrypted with this symmetric key. The symmetric key is then encrypted with the attacker's RSA public key (embedded in the binary or fetched from C2). The encrypted key is appended or prepended to the encrypted file. Only the attacker holding the RSA private key can decrypt the per-file symmetric keys.\n\n### Cryptographic API Identification\n\nWindows ransomware typically uses CryptoAPI (`CryptAcquireContext`, `CryptGenKey`, `CryptEncrypt`) or CNG (`BCryptGenerateSymmetricKey`, `BCryptEncrypt`). Some use OpenSSL or custom implementations. Identifying these API calls provides immediate insight into the algorithm, key size, and mode of operation.\n\n### Implementation Flaws\n\nDecryption opportunities arise from: hardcoded encryption keys, weak PRNG for key generation (using `GetTickCount` or `time()` as seed), reuse of IVs across files, ECB mode usage, keys remaining in memory post-encryption, and race conditions where keys can be captured during encryption.\n\n## Workflow\n\n### Step 1: Identify Cryptographic Functions\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"Identify cryptographic functions in ransomware PE files.\"\"\"\nimport pefile\nimport sys\n\nCRYPTO_APIS = {\n    # Windows CryptoAPI\n    \"CryptAcquireContextA\": \"CryptoAPI context acquisition\",\n    \"CryptAcquireContextW\": \"CryptoAPI context acquisition\",\n    \"CryptGenKey\": \"Key generation\",\n    \"CryptDeriveKey\": \"Key derivation\",\n    \"CryptEncrypt\": \"Encryption operation\",\n    \"CryptDecrypt\": \"Decryption operation\",\n    \"CryptImportKey\": \"Key import (public key?)\",\n    \"CryptExportKey\": \"Key export\",\n    \"CryptGenRandom\": \"Random number generation\",\n    \"CryptCreateHash\": \"Hash creation\",\n    \"CryptHashData\": \"Hashing operation\",\n    # Windows CNG (BCrypt)\n    \"BCryptOpenAlgorithmProvider\": \"CNG algorithm initialization\",\n    \"BCryptGenerateSymmetricKey\": \"CNG symmetric key generation\",\n    \"BCryptEncrypt\": \"CNG encryption\",\n    \"BCryptDecrypt\": \"CNG decryption\",\n    \"BCryptGenerateKeyPair\": \"CNG key pair generation\",\n    \"BCryptImportKeyPair\": \"CNG key import\",\n    # OpenSSL\n    \"EVP_EncryptInit_ex\": \"OpenSSL encrypt init\",\n    \"EVP_EncryptUpdate\": \"OpenSSL encrypt update\",\n    \"EVP_EncryptFinal_ex\": \"OpenSSL encrypt final\",\n    \"RSA_public_encrypt\": \"OpenSSL RSA encryption\",\n    \"AES_set_encrypt_key\": \"OpenSSL AES key setup\",\n    # File operations\n    \"CreateFileW\": \"File open (target files)\",\n    \"ReadFile\": \"File read (before encryption)\",\n    \"WriteFile\": \"File write (after encryption)\",\n    \"FindFirstFileW\": \"File enumeration (targeting)\",\n    \"FindNextFileW\": \"File enumeration\",\n    \"MoveFileW\": \"File rename (extension change)\",\n    \"DeleteFileW\": \"File deletion (originals)\",\n}\n\nAES_SBOX = bytes([\n    0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,\n    0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,\n])\n\nCHACHA20_CONSTANT = b\"expand 32-byte k\"\n\n\ndef analyze_imports(filepath):\n    \"\"\"Analyze PE imports for cryptographic APIs.\"\"\"\n    try:\n        pe = pefile.PE(filepath)\n    except pefile.PEFormatError:\n        print(\"[-] Not a valid PE file\")\n        return\n\n    print(\"[+] Cryptographic API Analysis\")\n    print(\"=\" * 60)\n\n    crypto_imports = []\n    if hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):\n        for entry in pe.DIRECTORY_ENTRY_IMPORT:\n            dll = entry.dll.decode('utf-8', errors='replace')\n            for imp in entry.imports:\n                if imp.name:\n                    name = imp.name.decode('utf-8', errors='replace')\n                    if name in CRYPTO_APIS:\n                        desc = CRYPTO_APIS[name]\n                        crypto_imports.append((dll, name, desc))\n                        print(f\"  [{dll}] {name}: {desc}\")\n\n    if not crypto_imports:\n        print(\"  No known crypto APIs found in imports\")\n        print(\"  Malware may use custom implementation or dynamic loading\")\n\n    return crypto_imports\n\n\ndef find_crypto_constants(filepath):\n    \"\"\"Search for embedded cryptographic constants.\"\"\"\n    with open(filepath, 'rb') as f:\n        data = f.read()\n\n    print(\"\\n[+] Cryptographic Constants Search\")\n    print(\"=\" * 60)\n\n    # AES S-Box\n    offset = data.find(AES_SBOX)\n    if offset != -1:\n        print(f\"  AES S-Box found at offset 0x{offset:x}\")\n\n    # ChaCha20\u002FSalsa20 constant\n    offset = data.find(CHACHA20_CONSTANT)\n    if offset != -1:\n        print(f\"  ChaCha20 constant at offset 0x{offset:x}\")\n\n    # RSA public key markers\n    rsa_markers = [\n        b'-----BEGIN PUBLIC KEY-----',\n        b'-----BEGIN RSA PUBLIC KEY-----',\n        b'\\x30\\x82',  # ASN.1 SEQUENCE\n    ]\n    for marker in rsa_markers:\n        offset = data.find(marker)\n        if offset != -1:\n            print(f\"  RSA key marker at offset 0x{offset:x}\")\n\n    # Common ransomware file extension patterns\n    import re\n    ext_pattern = re.compile(rb'\\.\\w{3,10}(?=\\x00)', re.IGNORECASE)\n    extensions = set()\n    for match in ext_pattern.finditer(data):\n        ext = match.group().decode('ascii', errors='replace').lower()\n        target_exts = [\n            '.doc', '.docx', '.xls', '.xlsx', '.pdf', '.ppt',\n            '.jpg', '.png', '.sql', '.mdb', '.bak', '.zip',\n        ]\n        if ext in target_exts:\n            extensions.add(ext)\n\n    if extensions:\n        print(f\"\\n  Target file extensions: {', '.join(sorted(extensions))}\")\n\n\nif __name__ == \"__main__\":\n    if len(sys.argv) \u003C 2:\n        print(f\"Usage: {sys.argv[0]} \u003Cransomware_sample>\")\n        sys.exit(1)\n\n    analyze_imports(sys.argv[1])\n    find_crypto_constants(sys.argv[1])\n```\n\n### Step 2: Analyze Encryption Flow\n\n```python\ndef analyze_encryption_pattern(filepath):\n    \"\"\"Analyze file encryption patterns from ransomware artifacts.\"\"\"\n    import os\n    import struct\n\n    with open(filepath, 'rb') as f:\n        data = f.read()\n\n    file_size = len(data)\n    print(f\"\\n[+] Encrypted File Analysis: {filepath}\")\n    print(f\"  Size: {file_size:,} bytes\")\n\n    # Check for appended key material (common pattern)\n    # Many ransomware families append encrypted key at end of file\n    tail_sizes = [256, 512, 1024, 2048]  # Common RSA ciphertext sizes\n    for size in tail_sizes:\n        if file_size > size + 16:\n            tail = data[-size:]\n            # High entropy suggests encrypted data\n            entropy = calculate_entropy(tail)\n            if entropy > 7.5:\n                print(f\"  Possible encrypted key ({size} bytes) \"\n                      f\"at end of file (entropy: {entropy:.2f})\")\n\n    # Check for header modifications\n    # Many ransomware prepend metadata\n    header = data[:64]\n    print(f\"  First 16 bytes: {header[:16].hex()}\")\n\n    # Check if original file header is preserved\n    known_headers = {\n        b'PK': 'ZIP\u002FOffice',\n        b'\\x89PNG': 'PNG',\n        b'\\xff\\xd8\\xff': 'JPEG',\n        b'%PDF': 'PDF',\n        b'\\xd0\\xcf\\x11\\xe0': 'OLE (DOC\u002FXLS)',\n    }\n    for magic, ftype in known_headers.items():\n        if header.startswith(magic):\n            print(f\"  Original format preserved: {ftype}\")\n            break\n    else:\n        print(\"  Original header destroyed\u002Fencrypted\")\n\n\ndef calculate_entropy(data):\n    \"\"\"Calculate Shannon entropy of data.\"\"\"\n    from collections import Counter\n    import math\n\n    if not data:\n        return 0\n\n    freq = Counter(data)\n    length = len(data)\n    entropy = -sum(\n        (count \u002F length) * math.log2(count \u002F length)\n        for count in freq.values()\n    )\n    return entropy\n```\n\n## Validation Criteria\n\n- Cryptographic algorithms identified (AES, RSA, ChaCha20, etc.)\n- Key size and mode of operation determined\n- Key generation method analyzed for potential weaknesses\n- Per-file key encryption scheme documented\n- File targeting patterns and extension list extracted\n- Embedded public keys extracted for infrastructure correlation\n- Potential decryption opportunities assessed\n\n## References\n\n- [Morphisec - Breaking Down Ransomware Encryption](https:\u002F\u002Fwww.morphisec.com\u002Fblog\u002Fbreaking-down-ransomware-encryption-key-strategies-algorithms-and-implementation-trends\u002F)\n- [Emsisoft - Ransomware Encryption Methods](https:\u002F\u002Fwww.emsisoft.com\u002Fen\u002Fblog\u002F27649\u002Fransomware-encryption-methods\u002F)\n- [Halcyon Ransomware Power Rankings Q4-2024](https:\u002F\u002Fwww.halcyon.ai\u002Fraas-mq\u002Fpower-rankings-ransomware-malicious-quartile-q4-2024)\n- [No More Ransom Project](https:\u002F\u002Fwww.nomoreransom.org\u002F)\n- [MITRE ATT&CK T1486 - Data Encrypted for Impact](https:\u002F\u002Fattack.mitre.org\u002Ftechniques\u002FT1486\u002F)\n",{"name":5,"tags":25,"author":34,"domain":35,"license":15,"version":36,"mitre_f3":37,"nist_csf":54,"subdomain":33,"description":7,"mitre_attack":59,"d3fend_techniques":65},[26,27,28,29,30,31,32,33],"ransomware","encryption","reverse-engineering","cryptanalysis","aes","rsa","decryption","malware-analysis","mahipal","cybersecurity","1.0",{"tactics":38,"version":41,"techniques":42},[39,40],"monetization","positioning","1.1",[43,47,50],{"id":44,"name":45,"source":46,"tactic":39},"F1018","Convert to Cryptocurrency","f3",{"id":48,"name":49,"source":46,"tactic":39},"F1047","Transfer of funds",{"id":51,"name":52,"source":53,"tactic":40},"T1219","Remote Access Tools","attack",[55,56,57,58],"DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01",[60,61,62,63,64],"T1027","T1055","T1140","T1497","T1486",[66,67,68,69,70],"File Metadata Consistency Validation","Content Format Conversion","File Content Analysis","Platform Hardening","File Format Verification","main","7540bbccf0c1ded6156a467b02c95b61ad62413f",".agents\u002Fskills\u002Freverse-engineering-ransomware-encryption-routine","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena","Currently exploring the intersection of tech","2026-09-11 03:02:31",{"source":8,"skillName":5,"commands":79,"prompt":89,"zipAvailable":90},[80,83,86],{"tool":81,"command":82},"npx","npx skills add NeelakshSaxena\u002FVayu --skill reverse-engineering-ransomware-encryption-routine",{"tool":84,"command":85},"bunx","bunx skills add NeelakshSaxena\u002FVayu --skill reverse-engineering-ransomware-encryption-routine",{"tool":87,"command":88},"pnpm","pnpm dlx skills add NeelakshSaxena\u002FVayu --skill reverse-engineering-ransomware-encryption-routine","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-ransomware-encryption-routine\u002FSKILL.md",true,[92,98,102,108,112,116,122],{"path":93,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":96,"sourceHtmlUrl":97},"assets\u002Ftemplate.md","ASSET","资产文件",849,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-ransomware-encryption-routine\u002Fassets\u002Ftemplate.md",{"path":99,"resourceType":99,"resourceTypeDesc":100,"sizeBytes":101,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":103,"resourceType":104,"resourceTypeDesc":105,"sizeBytes":106,"sourceHtmlUrl":107},"references\u002Fapi-reference.md","REFERENCE","参考文档",1902,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-ransomware-encryption-routine\u002Freferences\u002Fapi-reference.md",{"path":109,"resourceType":104,"resourceTypeDesc":105,"sizeBytes":110,"sourceHtmlUrl":111},"references\u002Fstandards.md",1168,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-ransomware-encryption-routine\u002Freferences\u002Fstandards.md",{"path":113,"resourceType":104,"resourceTypeDesc":105,"sizeBytes":114,"sourceHtmlUrl":115},"references\u002Fworkflows.md",1698,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-ransomware-encryption-routine\u002Freferences\u002Fworkflows.md",{"path":117,"resourceType":118,"resourceTypeDesc":119,"sizeBytes":120,"sourceHtmlUrl":121},"scripts\u002Fagent.py","SCRIPT","脚本",6767,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-ransomware-encryption-routine\u002Fscripts\u002Fagent.py",{"path":123,"resourceType":118,"resourceTypeDesc":119,"sizeBytes":124,"sourceHtmlUrl":125},"scripts\u002Fprocess.py",5561,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-ransomware-encryption-routine\u002Fscripts\u002Fprocess.py",[127,134,141,148,155,162],{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":20},"01M7ACCCVNCFKMA9X6D15X6G98","runpodctl","Runpod CLI for managing GPU\u002FCPU workloads from the terminal — pods, serverless endpoints, templates, network volumes, Hub deploys, models, SSH, and file transfer (send\u002Freceive). Use for terminal\u002FCI\u002Fscripting, Hub browse\u002Fdeploy, SSH setup, `doctor`, or when the Runpod MCP tools are not connected. For structured tool calls in an MCP-enabled session, prefer runpod-mcp.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpodctl\u002FSKILL.md",[],[],{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":138,"categories":139,"keywords":140,"publishedAt":20},"01M7ACC63SRHEA5KMCHSMZK2TC","runpod","Start here for any Runpod task — running GPU\u002FCPU pods, deploying serverless endpoints, templates, network volumes, building images, or understanding how Runpod works. Routes to the right skill (runpod-mcp, runpodctl, flash, companion-clis, runpod-usage, runpod-templates, runpod-migrate) and indexes two dozen live-verified end-to-end examples (golden paths) — use it when the lane is unclear, and for any multi-step or provisioning task even when it is not.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod\u002FSKILL.md",[],[],{"skillNo":142,"name":143,"nameZh":6,"description":144,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":145,"categories":146,"keywords":147,"publishedAt":20},"01M7ACC0Q1C89N9BZBV91CTQTF","runpod-usage","How Runpod works and how to work it — pods vs serverless, GPU\u002FVRAM selection, storage, building a container, networking, plus the agentic pod development loop (provision → ssh-exec → set up → poll readiness) and on-pod install hygiene (uv\u002Fapt). Use to answer \"how does X work\", \"which GPU\", \"how do I build a container\", or \"how do I stand up a workload on a pod\". Guidance, not a tool — execute with runpodctl, runpod-mcp, or flash.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-usage\u002FSKILL.md",[],[],{"skillNo":149,"name":150,"nameZh":6,"description":151,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":152,"categories":153,"keywords":154,"publishedAt":20},"01M7ACBRPE345GF5GM5B8P8RRC","runpod-templates","Runpod's official prebuilt pod templates (ComfyUI, PyTorch, and others): what each image ships, which ports and paths it uses, how to pick one, how to pin a version, and what is missing on first boot. Use when a task says \"run \u003CX> on a pod\" and an official template already covers it, instead of building an image — and when a user needs help with or wants to fix something about a Runpod template they are already running (won't boot, can't reach the UI, missing models, wrong CUDA line, broken ComfyUI workflow metadata on imported workflows): start here and route onward. Deploy with runpodctl or runpod-mcp; end-to-end walkthroughs live in the runpod router's golden paths.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-templates\u002FSKILL.md",[],[],{"skillNo":156,"name":157,"nameZh":6,"description":158,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":159,"categories":160,"keywords":161,"publishedAt":20},"01M7ACBJATHKVX1TWES2F44GY8","runpod-migrate","Migrate a codebase from the Runpod GraphQL API or REST v1 to REST v2 — inventory which parts use which API version, rewrite the call sites, flag breaking changes, and verify. Use when someone asks to move to v2, asks what v2 would change, or asks which Runpod API their code is on. For managing infrastructure rather than migrating code, use runpod-mcp or runpodctl.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-migrate\u002FSKILL.md",[],[],{"skillNo":163,"name":164,"nameZh":6,"description":165,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":166,"categories":167,"keywords":168,"publishedAt":20},"01M7ACBC7GHVH6T9YEAPCG2AP8","runpod-mcp","Manage Runpod infrastructure — pods, serverless endpoints, jobs, templates, network volumes, container-registry auth, GPU\u002FCPU catalog, and billing — via the Runpod MCP server's structured tool calls. Use when the Runpod MCP tools (create-pod, list-endpoints, …) are connected in this session, or to connect them (hosted OAuth or local npx). Prefer this over runpodctl for plain infra CRUD when MCP is available; use runpodctl for the terminal, file transfer, or SSH setup.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-mcp\u002FSKILL.md",[],[]]