acquiring-disk-image-w…
Create forensically sound bit-for-bit disk images using dd and dcfldd while preserving evidence integrity through
Analyzes encryption algorithms, key management, and file encryption routines used by ransomware families to
$ npx -y skills add Mikaru0Mystic/sectinel --skill analyzing-ransomware-encryption-mechanisms --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/analyzing-ransomware-encryption-mechanismsContext preview
The summary Claude sees to decide when to auto-load this skill.
Analyzes encryption algorithms, key management, and file encryption routines used by ransomware families to
name: analyzing-ransomware-encryption-mechanisms description: '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. ' domain: cybersecurity subdomain: malware-analysis tags: - malware - ransomware - encryption - cryptanalysis - reverse-engineering version: 1.0.0 author: mahipal license: Apache-2.0 nist_csf: - DE.AE-02 - RS.AN-03 - ID.RA-01 - DE.CM-01
**Do not use** for production data recovery operations without first verifying the decryption method on test copies of encrypted files.
Determine which cryptographic algorithm the ransomware uses:
# Check for Windows Crypto API usage in imports
import pefile
pe = pefile.PE("ransomware.exe")
crypto_apis = {
"CryptAcquireContextA": "Windows CryptoAPI",
"CryptAcquireContextW": "Windows CryptoAPI",
"CryptGenKey": "Windows CryptoAPI key generation",
"CryptEncrypt": "Windows CryptoAPI encryption",
"CryptImportKey": "Windows CryptoAPI key import",
"BCryptOpenAlgorithmProvider": "Windows CNG (modern crypto)",
"BCryptEncrypt": "Windows CNG encryption",
"BCryptGenerateKeyPair": "Windows CNG asymmetric key gen",
}
print("Crypto API Imports:")
for entry in pe.DIRECTORY_ENTRY_IMPORT:
for imp in entry.imports:
if imp.name and imp.name.decode() in crypto_apis:
print(f" {entry.dll.decode()} -> {imp.name.decode()}: {crypto_apis[imp.name.decode()]}")Common Ransomware Encryption Schemes: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ AES-256-CBC + RSA-2048: Most common hybrid scheme (LockBit, REvil, Conti) AES-256-CTR + RSA-4096: Stream cipher mode variant (BlackCat/ALPHV) ChaCha20 + RSA-4096: Modern stream cipher (Hive, Royal) Salsa20 + ECDH: Curve25519 key exchange (Babuk) AES-128-ECB: Weak mode - potential decryption via known-plaintext XOR-only: Trivial encryption - always recoverable Custom algorithm: Often contains implementation flaws
Reverse engineer how encryption keys are generated and stored:
Key Management Patterns in Ransomware: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1. STRONG (no recovery possible without key): - Per-file AES key generated with CryptGenRandom - AES key encrypted with embedded RSA public key - Encrypted key appended to each file or stored separately - RSA private key held only by attacker's C2 server 2. WEAK (potential recovery): - AES key derived from predictable seed (timestamp, PID) - Same AES key used for all files (single key compromise = full recovery) - Key transmitted to C2 before encryption starts (PCAP may contain key) - XOR with short repeating key (brute-forceable) - PRNG seeded with GetTickCount or time() (limited keyspace) 3. FLAWED IMPLEMENTATION: - ECB mode (preserves plaintext patterns) - Initialization vector (IV) reuse across files - Key stored in plaintext in memory (recoverable from memory dump) - Partial encryption (only first N bytes encrypted)
Reverse engineer the file processing logic:
// Typical ransomware file encryption flow (decompiled pseudo-code from Ghidra):
void encrypt_file(char *filepath) {
// 1. Check file extension against target list
if (!is_target_extension(filepath)) return;
// 2. Generate per-file AES key (32 bytes for AES-256)
BYTE aes_key[32];
CryptGenRandom(hProv, 32, aes_key);
// 3. Generate random IV (16 bytes)
BYTE iv[16];
CryptGenRandom(hProv, 16, iv);
// 4. Read file contents
HANDLE hFile = CreateFile(filepath, GENERIC_READ, ...);
BYTE *plaintext = read_entire_file(hFile);
// 5. Encrypt with AES-256-CBC
aes_cbc_encrypt(plaintext, file_size, aes_key, iv);
// 6. Encrypt AES key with RSA public key
BYTE encrypted_key[256]; // RSA-2048 output
rsa_encrypt(aes_key, 32, rsa_pubkey, encrypted_key);
// 7. Write: encrypted_data + encrypted_key + IV to file
write_file(filepath, encrypted_data, encrypted_key, iv);
// 8. Rename file with ransomware extension
rename_file(filepath, strcat(filepath, ".locked"));
}Test the implementation for exploitable flaws:
from Crypto.Cipher import AES
import os
import struct
# Test 1: Check if same key is used for multiple files
# Compare encrypted versions of known files
def check_key_reuse(file1_enc, file2_enc):
with open(file1_enc, "rb") as f:Open-source security arsenal for AI coding agents: 784 cybersecurity skills, scanner integrations, and a security MCP for Claude Code, Cursor, opencode, Gemini CLI, Cline, and any agentskills.io agent. Mapped to OWASP, MITRE ATT&CK, NIST CSF, D3FEND, ATLAS.
Repo: Mikaru0Mystic/sectinel
Create forensically sound bit-for-bit disk images using dd and dcfldd while preserving evidence integrity through
Detect dangerous ACL misconfigurations in Active Directory using ldap3 to identify GenericAll, WriteDACL, and
Perform static analysis of Android APK malware samples using apktool for decompilation, jadx for Java source
Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect BOLA/IDOR attacks, rate limit bypass,
Analyze advanced persistent threat (APT) group techniques using MITRE ATT&CK Navigator to create layered heatmaps
Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query to detect suspicious administrative