Chuyển đến nội dung
Skillpedia
Agent35k · #7865

detecting-ransomware-encryption-behavior

Skill này làm gì

Hệ thống này phát hiện ngay khi ransomware đang mã hóa tệp của bạn. Nó theo dõi cách tệp bị thay đổi và việc nội dung tệp trở nên rất ngẫu nhiên (entropy cao), là dấu hiệu của quá trình mã hóa.

Khi nào nên dùng

  • ✓Khi xây dựng hệ thống để bắt các loại ransomware mới.
  • ✓Khi giám sát máy chủ tệp và máy tính để chống mã hóa hàng loạt.
  • ✓Khi điều tra một chương trình hoạt động đáng ngờ, chẳng hạn mã hóa nhiều tệp trong thời gian ngắn.

Liên kết skill

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-ransomware-encryption-behavior/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-ransomware-encryption-behavior/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy kiểm tra hoạt động mã hóa ransomware theo thời gian thực.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ phân tích mức ngẫu nhiên của nội dung tệp (entropy) và theo dõi cách chương trình truy cập và sửa đổi tệp. Nếu một chương trình bắt đầu thay đổi nhiều tệp nhanh chóng và nội dung trở nên rất ngẫu nhiên, hệ thống sẽ cảnh báo khả năng mã hóa.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Detecting Ransomware Encryption Behavior

When to Use

  • Building or tuning a behavioral detection layer for ransomware that catches unknown/zero-day variants
  • Monitoring file servers and endpoints for mass encryption activity that evades signature-based detection
  • Implementing entropy-based detection to identify when files are being replaced with encrypted (high-entropy) content
  • Analyzing suspicious process behavior patterns: rapid sequential file opens, writes, renames, and deletes
  • Validating EDR detection rules against actual ransomware encryption patterns during red team exercises

Do not use entropy analysis alone as the only detection signal. Compressed files (ZIP, JPEG, MP4) naturally have high entropy and will cause false positives. Always combine entropy with behavioral signals like I/O rate and file rename patterns.

Prerequisites

  • Python 3.8+ with watchdog and psutil libraries
  • Administrative access for process monitoring and file system event capture
  • Understanding of Shannon entropy and its application to file content analysis
  • Windows: Sysmon installed for detailed process and file system event logging
  • Linux: auditd configured for file access monitoring, or inotify-based watchers
  • Baseline entropy values for common file types in the monitored environment

Workflow

Step 1: Establish Entropy Baselines

Calculate normal entropy ranges for files in the environment:

Entropy Baselines by File Type:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
File Type       Normal Entropy    Encrypted Entropy
.docx           3.5 - 6.5        7.8 - 8.0
.xlsx           4.0 - 6.8        7.8 - 8.0
.pdf            5.0 - 7.2        7.8 - 8.0
.txt            2.0 - 5.0        7.8 - 8.0
.csv            2.0 - 5.5        7.8 - 8.0
.sql            2.5 - 5.0        7.8 - 8.0
.jpg/.png       7.0 - 7.9        7.9 - 8.0 (hard to distinguish)
.zip/.7z        7.5 - 8.0        7.9 - 8.0 (hard to distinguish)

Key insight: Text-based files show the largest entropy jump when encrypted,
making them the best candidates for entropy-based detection.

Step 2: Implement Real-Time Entropy Monitoring

Monitor file writes and calculate entropy of new content:

import math
from collections import Counter

def shannon_entropy(data):
    """Calculate Shannon entropy of byte data (0.0 to 8.0 scale)."""
    if not data:
        return 0.0
    freq = Counter(data)
    length = len(data)
    return -sum((c / length) * math.log2(c / length) for c in freq.values())

def is_encryption_entropy(data, threshold=7.5):
    """Check if data entropy indicates encryption."""
    entropy = shannon_entropy(data)
    return entropy >= threshold, entropy

Step 3: Monitor File System I/O Patterns

Track process-level file operations for ransomware patterns:

Ransomware I/O Behavior Signatures:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. Rapid sequential file modification:
   - >20 files modified per minute by single process
   - Read original → Write encrypted → Rename with new extension
   - Pattern: CreateFile → ReadFile → WriteFile → CloseHandle → MoveFile

2. File extension changes:
   - Original: report.docx → Encrypted: report.docx.locked
   - Many extensions changed within short time window

3. Ransom note creation:
   - Same text file (README.txt, DECRYPT.html) created in multiple directories
   - Created immediately after file encryption in each directory

4. Shadow copy deletion:
   - vssadmin.exe delete shadows /all /quiet
   - wmic.exe shadowcopy delete
   - PowerShell: Get-WmiObject Win32_Shadowcopy | Remove-WmiObject

5. Entropy spike pattern:
   - File read: entropy 3.5 (normal document)
   - File write: entropy 7.9 (encrypted content)
   - Delta > 3.0 is strong ransomware indicator

Step 4: Implement Behavioral Scoring

Combine multiple signals into a composite ransomware score:

def calculate_ransomware_score(process_metrics):
    """Score process behavior for ransomware likelihood (0-100)."""
    score = 0

    # High file modification rate
    files_per_min = process_metrics.get("files_modified_per_minute", 0)
    if files_per_min > 50:
        score += 30
    elif files_per_min > 20:
        score += 15

    # Entropy increase in written files
    avg_entropy_delta = process_metrics.get("avg_entropy_delta", 0)
    if avg_entropy_delta > 3.0:
        score += 30
    elif avg_entropy_delta > 2.0:
        score += 15

    # File extension changes

…
Câu hỏi thường gặp

Entropy là gì?

Entropy đo mức độ ngẫu nhiên hoặc khó đoán của nội dung tệp. Tệp thông thường có entropy có thể dự đoán, còn tệp đã mã hóa hoặc nén có entropy cao, trông ngẫu nhiên hơn.

Tại sao không chỉ dùng phân tích entropy?

Các tệp nén (như ZIP hoặc JPEG) cũng có entropy cao và có thể gây báo động giả. Cần kết hợp phân tích entropy với các dấu hiệu khác, như tốc độ sửa tệp và mẫu đổi tên.

Cần điều kiện gì để dùng công cụ này?

Bạn cần một môi trường có Python, các thư viện cụ thể (watchdog, psutil), quyền quản trị để giám sát hệ thống, và tùy hệ điều hành là các công cụ như Sysmon (Windows) hoặc auditd (Linux).

Chi tiết

Mô tả gốc của tác giả

Detects ransomware encryption activity in real time using entropy analysis, file system I/O monitoring (Sysmon, watchdog, psutil), and behavioral scoring to identify mass file modification, abnormal entropy spikes in written data, and suspicious process behavior characteristic of encryption routines. Use when building real-time ransomware detection, tuning entropy thresholds, or investigating susp

repo: mukul975/Anthropic-Cybersecurity-Skills

Độ phổ biến

Sao GitHub
35k
Vị trí xếp hạng
#7865
Giấy phép
Apache-2.0
Cập nhật
31/8/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự