What it does. Deploys and monitors ransomware canary files using Python's watchdog library, placing decoy files mimicking high-value targets (financial records, credentials, database exports) where ransomware enumerates first, and alerting via email, Slack, or syslog on any read/modify/rename/delete. Use for early-warning ransomware detection on file servers, NAS, or endpoints, or to supplement EDR where agents can't be deployed. Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).
Install
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill deploying-ransomware-canary-files, or copy the skill folder into ~/.claude/skills/deploying-ransomware-canary-files/.
- Raw file:
curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/deploying-ransomware-canary-files/SKILL.md
SKILL.md (verbatim)
name: deploying-ransomware-canary-files
description: Deploys and monitors ransomware canary files using Python's watchdog library, placing decoy files mimicking high-value targets (financial records, credentials, database exports) where ransomware enumerates first, and alerting via email, Slack, or syslog on any read/modify/rename/delete. Use for early-warning ransomware detection on file servers, NAS, or endpoints, or to supplement EDR where agents can't be deployed.
domain: cybersecurity
subdomain: ransomware-defense
tags:
- ransomware
- canary-files
- watchdog
- detection
- early-warning
- deception
- defense
version: 1.0.0
author: mahipal
license: Apache-2.0
nist_csf:
- PR.DS-11
- RS.MA-01
- RC.RP-01
- PR.IR-01
mitre_attack:
- T1486
- T1083
- T1490
- T1485
mitre_f3:
version: '1.1'
tactics:
- monetization
techniques:
- id: F1018
name: Convert to Cryptocurrency
tactic: monetization
source: f3
- id: F1017
name: Conversion to Physical Monetary Instruments
tactic: monetization
source: f3
- id: F1025.003
name: 'Electronic Funds Transfer: Wire Transfer'
tactic: monetization
source: f3
Deploying Ransomware Canary Files
When to Use
- Deploying proactive ransomware detection on file servers, NAS devices, or endpoint systems
- Building an early-warning system that detects ransomware before it encrypts business-critical data
- Supplementing EDR solutions with lightweight canary file monitoring on systems where agents cannot be deployed
- Testing ransomware incident response procedures by simulating canary file triggers
- Monitoring shared drives, home directories, and backup volumes for unauthorized file operations
Do not use as a replacement for endpoint protection, backup strategy, or network segmentation. Canary files are a detection layer, not a prevention mechanism.
Prerequisites
- Python 3.8+ with pip
- watchdog library (pip install watchdog)
- Write access to directories where canary files will be placed
- SMTP server credentials or Slack webhook URL for alerting
- Administrative access for placing canaries in system directories
Workflow
Step 1: Generate Canary Files
Create decoy files with realistic names and content that attract ransomware scanners. Files should have names like Passwords.xlsx, Financial_Report_2026.docx, backup_credentials.csv and contain plausible-looking but fake data. Place them in directories ransomware typically targets first: user desktops, Documents folders, network share roots, and backup paths.
Step 2: Deploy Filesystem Monitor
Use Python's watchdog library with a custom FileSystemEventHandler that watches canary file paths. The handler triggers on on_modified, on_deleted, on_moved, and on_created events for canary files. Any legitimate user or process should never touch these files, so any interaction is a high-confidence indicator of ransomware or unauthorized access.
Wire the filesystem monitor to multiple alert channels: email via SMTP, Slack webhook POST, syslog forwarding to SIEM, and local log file. Include the triggering event type, file path, timestamp, and process information (when available) in alert payloads.
Step 4: Validate and Test
Simulate ransomware behavior by programmatically modifying, renaming, and deleting canary files to verify the detection pipeline fires correctly. Measure time-to-alert and validate alert delivery across all configured channels.
Key Concepts
| Term |
Definition |
| Canary File |
A decoy file placed in a monitored directory that triggers an alert when accessed, modified, or deleted |
| Watchdog |
Python library that monitors filesystem events using OS-native APIs (inotify on Linux, FSEvents on macOS, ReadDirectoryChangesW on Windows) |
| Honey File |
Synonym for canary file; a fake document designed to attract and detect malicious activity |
| Entropy Check |
Measuring randomness in file content to detect encryption (ransomware produces high-entropy output) |
- watchdog: Python filesystem monitoring library using OS-native event APIs
- smtplib: Python standard library for SMTP email alerting
- requests: HTTP library for Slack webhook integration
- hashlib: SHA-256 hashing for canary file integrity verification
- psutil: Process information gathering when canary file access is detected
RANSOMWARE CANARY ALERT
========================
Timestamp: 2026-03-11T14:23:07Z
Event: FILE_MODIFIED
Canary File: /srv/shares/finance/Passwords.xlsx
Directory: /srv/shares/finance
SHA-256 Before: a3f2...8b4c
SHA-256 After: 7e91...2d3f
Alert Channels: [email, slack, syslog]
Action: Investigate immediately - potential ransomware activity
Other files in this skill
references/api-reference.md (verbatim)
API Reference: Deploying Ransomware Canary Files
Canary File Deployment
| Function |
Parameters |
Returns |
deploy_canary_files(target_dirs, custom_files) |
List of directories, optional custom file dict |
Manifest with deployed file paths and hashes |
compute_sha256(filepath) |
File path string |
SHA-256 hex digest |
compute_entropy(filepath) |
File path string |
Shannon entropy float (0-8) |
Monitoring Functions
| Function |
Parameters |
Returns |
start_monitoring(manifest_path, config) |
Path to manifest JSON, alert config dict |
Blocks until interrupted |
verify_canary_integrity(manifest_path) |
Path to manifest JSON |
Dict with intact/modified/missing counts |
simulate_ransomware_test(manifest_path) |
Path to manifest JSON |
List of test results |
CanaryFileHandler Events
| Event |
Handler Method |
Trigger |
| File modified |
on_modified(event) |
Content change detected |
| File deleted |
on_deleted(event) |
Canary file removed |
| File renamed |
on_moved(event) |
Canary file renamed or moved |
| New file created |
on_created(event) |
Ransom note detection in monitored dirs |
Alert Channels
| Channel |
Function |
Required Config |
| Slack |
send_slack_alert(data, webhook_url) |
slack_webhook URL |
| Email |
send_email_alert(data, host, port, sender, recipients) |
SMTP server details |
| Syslog |
send_syslog_alert(data, server, port) |
Syslog server address |
| File |
Automatic |
Writes to canary_alerts.jsonl |
Ransomware Extension Detection
| Extensions Monitored |
.encrypted, .locked, .lockbit, .crypt, .enc |
.ransom, .pay, .aes, .rsa, .cry |
.ryk, .revil, .conti, .hive, .black, .basta |
CLI Usage
# Deploy canary files
python agent.py --action deploy --dirs /srv/shares /home/admin/Documents
# Monitor canary files with Slack alerts
python agent.py --action monitor --slack-webhook https://hooks.slack.com/...
# Verify canary file integrity
python agent.py --action verify
# Test detection pipeline
python agent.py --action test
Python Libraries
| Library |
Version |
Purpose |
watchdog |
>=3.0 |
Filesystem event monitoring |
requests |
>=2.28 |
Slack webhook integration |
psutil |
>=5.9 |
Process information gathering |
hashlib |
stdlib |
SHA-256 file hashing |
smtplib |
stdlib |
SMTP email alerts |
References
Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.