
Building Soc Playbook For Ransomware
- 161 installs
- 27.3k repo stars
- Updated August 2, 2026
- mukul975/anthropic-cybersecurity-skills
Helps with ai & agent building tasks.
About
building-soc-playbook-for-ransomware is a Claude Code skill in the AI & Agent Building category.
- building-soc-playbook-for-ransomware
- AI & Agent Building
- AI-coding skill
Building Soc Playbook For Ransomware by the numbers
- 161 all-time installs (skills.sh)
- +5 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #3,231 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill building-soc-playbook-for-ransomwareAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 161 |
|---|---|
| repo stars | ★ 27.3k |
| Last updated | August 2, 2026 |
| Repository | mukul975/anthropic-cybersecurity-skills ↗ |
What it does
Helps with ai & agent building tasks.
Files
Building SOC Playbook for Ransomware
When to Use
Use this skill when:
- SOC teams need a standardized ransomware response playbook for Tier 1-3 analysts
- An organization lacks documented procedures for ransomware containment and recovery
- Tabletop exercises reveal gaps in ransomware response coordination
- Compliance requirements (NIST CSF, ISO 27001) mandate documented incident playbooks
Do not use during an active ransomware incident as the sole guide — have pre-built playbooks tested and rehearsed before incidents occur.
Prerequisites
- SIEM platform (Splunk ES, Elastic Security, or Sentinel) with endpoint and network data
- EDR solution (CrowdStrike, SentinelOne, or Microsoft Defender for Endpoint) with network isolation capability
- Backup infrastructure with tested recovery procedures and offline/immutable backups
- Communication plan with legal, executive leadership, and external IR retainer contacts
- MITRE ATT&CK knowledge for ransomware technique chains
Workflow
Step 1: Define Detection Triggers
Create SIEM detection rules for early ransomware indicators:
Mass File Encryption Detection (Splunk):
index=sysmon EventCode=11
| bin _time span=1m
| stats dc(TargetFilename) AS unique_files, values(TargetFilename) AS sample_files by Computer, Image, _time
| where unique_files > 100
| eval suspicious_extensions = if(match(mvjoin(sample_files, ","), "\.(encrypted|locked|crypt|enc|ransom)"), "YES", "NO")
| where suspicious_extensions="YES" OR unique_files > 500
| sort - unique_filesShadow Copy Deletion (T1490):
index=wineventlog sourcetype="WinEventLog:Security" OR index=sysmon EventCode=1
(CommandLine="*vssadmin*delete*shadows*" OR CommandLine="*wmic*shadowcopy*delete*"
OR CommandLine="*bcdedit*/set*recoveryenabled*no*" OR CommandLine="*wbadmin*delete*catalog*")
| table _time, Computer, User, ParentImage, Image, CommandLineRansomware Note File Creation:
index=sysmon EventCode=11
TargetFilename IN ("*README*.txt", "*DECRYPT*.txt", "*RANSOM*.txt", "*RECOVER*.html", "*HOW_TO*.txt")
| stats count by Computer, Image, TargetFilename
| where count > 5Elastic Security EQL variant:
sequence by host.name with maxspan=2m
[process where event.type == "start" and
process.args : ("*vssadmin*", "*delete*", "*shadows*")]
[file where event.type == "creation" and
file.name : ("*README*DECRYPT*", "*RANSOM*", "*HOW_TO_RECOVER*")]Step 2: Build Triage Decision Tree
RANSOMWARE ALERT TRIAGE
│
├── Is encryption actively occurring?
│ ├── YES → IMMEDIATE: Isolate host from network (Step 3)
│ │ Do NOT power off (preserve memory for forensics)
│ └── NO → Is this a pre-encryption indicator?
│ ├── Shadow copy deletion → HIGH PRIORITY: Isolate and investigate
│ ├── Known ransomware hash → HIGH PRIORITY: Block hash, scan enterprise
│ └── Suspicious process behavior → MEDIUM: Investigate, prepare isolation
│
├── How many hosts affected?
│ ├── Single host → Contained incident, follow host isolation procedure
│ ├── Multiple hosts (2-10) → Escalate to Tier 2, begin enterprise-wide scan
│ └── Enterprise-wide (>10) → Activate full IR team, engage external retainer
│
└── Is data exfiltration confirmed?
├── YES → Double extortion scenario, engage legal for breach notification
└── NO/UNKNOWN → Check for Cobalt Strike/C2 beacons, review outbound transfersStep 3: Containment Procedures
Network Isolation via EDR (CrowdStrike Falcon):
# Isolate host using CrowdStrike Falcon API
curl -X POST "https://api.crowdstrike.com/devices/entities/devices-actions/v2?action_name=contain" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"ids": ["device_id_here"]}'Network Isolation via Microsoft Defender for Endpoint:
# Isolate machine via MDE API
$headers = @{Authorization = "Bearer $token"}
$body = @{Comment = "Ransomware containment - IR-2024-0500"; IsolationType = "Full"} | ConvertTo-Json
Invoke-RestMethod -Uri "https://api.securitycenter.microsoft.com/api/machines/$machineId/isolate" `
-Method Post -Headers $headers -Body $body -ContentType "application/json"Firewall Emergency Rules:
# Palo Alto — Block SMB lateral spread
set rulebase security rules RansomwareContainment from Trust to Trust
set rulebase security rules RansomwareContainment application ms-ds-smb
set rulebase security rules RansomwareContainment action deny
set rulebase security rules RansomwareContainment disabled no
commitActive Directory Emergency Actions:
# Disable compromised account
Disable-ADAccount -Identity "compromised_user"
# Reset Kerberos TGT (if domain admin compromised)
# WARNING: This resets krbtgt and requires two resets 12+ hours apart
Reset-KrbtgtKeys -Server "DC-PRIMARY" -Force
# Block lateral movement by disabling remote services
Set-Service -Name "RemoteRegistry" -StartupType Disabled -Status StoppedStep 4: Evidence Collection and Preservation
Collect forensic artifacts before remediation:
# Capture running processes and network connections
Get-Process | Export-Csv "C:\IR\processes_$(hostname).csv"
Get-NetTCPConnection | Export-Csv "C:\IR\netstat_$(hostname).csv"
# Capture memory dump (if host still running)
winpmem_mini_x64.exe C:\IR\memory_$(hostname).raw
# Collect ransomware artifacts
Copy-Item "C:\Users\*\Desktop\*README*" "C:\IR\ransom_notes\" -Recurse
Copy-Item "C:\Users\*\Desktop\*.encrypted" "C:\IR\encrypted_samples\" -Force
# Capture event logs
wevtutil epl Security "C:\IR\Security_$(hostname).evtx"
wevtutil epl System "C:\IR\System_$(hostname).evtx"
wevtutil epl "Microsoft-Windows-Sysmon/Operational" "C:\IR\Sysmon_$(hostname).evtx"Step 5: Eradication and Recovery
Identify ransomware variant:
- Upload encrypted sample and ransom note to ID Ransomware (https://id-ransomware.malwarehunterteam.com/)
- Check No More Ransom Project (https://www.nomoreransom.org/) for available decryptors
- Search for ransomware family IOCs in MalwareBazaar
Enterprise-wide IOC scan in Splunk:
index=sysmon (EventCode=1 OR EventCode=11 OR EventCode=3)
(TargetFilename="*ransomware_binary_name*" OR sha256="KNOWN_HASH"
OR DestinationIp="C2_IP_ADDRESS" OR CommandLine="*malicious_command*")
| stats count by Computer, EventCode, Image, CommandLine
| sort - countRecovery from backups: 1. Verify backup integrity (offline/immutable backups not affected) 2. Rebuild affected systems from known-good images 3. Restore data from last clean backup 4. Validate restored systems before reconnecting to network 5. Monitor restored systems for 72 hours for reinfection
Step 6: Post-Incident Documentation
Structure the playbook conclusion with lessons learned:
POST-INCIDENT REVIEW TEMPLATE
1. Timeline of events (detection to full recovery)
2. Initial access vector identification
3. Dwell time analysis (time from initial compromise to encryption)
4. Detection gaps identified
5. Response effectiveness metrics (MTTD, MTTC, MTTR)
6. Playbook improvements recommended
7. New detection rules deployed
8. Backup and recovery procedure updatesKey Concepts
| Term | Definition |
|---|---|
| Double Extortion | Ransomware tactic combining data encryption with data theft, threatening public release if ransom unpaid |
| Dwell Time | Duration between initial compromise and detection — ransomware operators average 5-9 days before encryption |
| MTTC | Mean Time to Contain — time from detection to successful isolation of affected systems |
| Kill Chain | Ransomware progression: Initial Access -> Execution -> Persistence -> Privilege Escalation -> Lateral Movement -> Collection -> Exfiltration -> Impact |
| Immutable Backup | Backup storage that cannot be modified or deleted for a defined retention period (WORM storage) |
| RTO/RPO | Recovery Time Objective / Recovery Point Objective — maximum acceptable downtime and data loss thresholds |
Tools & Systems
- CrowdStrike Falcon / SentinelOne: EDR platforms with network isolation, process kill, and threat hunting capabilities
- Splunk ES / Elastic Security: SIEM platforms for detection rule deployment and enterprise-wide IOC scanning
- ID Ransomware: Online service identifying ransomware variants from encrypted file samples and ransom notes
- No More Ransom Project: Europol-backed initiative providing free decryption tools for known ransomware families
- Veeam / Rubrik: Enterprise backup solutions with immutable backup support and instant recovery capabilities
Common Scenarios
- LockBit Attack: Detected via SMB lateral movement and mass file encryption — isolate, scan for Cobalt Strike beacons
- BlackCat/ALPHV: Detected via ransomware note creation — check for data exfiltration via Rclone or Mega upload
- Conti/Royal: Detected via shadow copy deletion — check for prior BazarLoader/Emotet initial access
- RansomHub: Detected via anomalous process execution — investigate for compromised VPN or RDP credentials
- Play Ransomware: Detected via service account abuse — audit AD for newly created accounts and group membership changes
Output Format
RANSOMWARE PLAYBOOK EXECUTION — IR-2024-0500
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Phase 1 - Detection:
Alert: Mass file encryption detected on FILESERVER-03
Variant: LockBit 3.0 (confirmed via ID Ransomware)
MTTD: 12 minutes from first encryption to SOC alert
Phase 2 - Containment:
[DONE] FILESERVER-03 isolated via CrowdStrike at 14:35 UTC
[DONE] SMB blocked enterprise-wide via firewall emergency rule
[DONE] Compromised service account disabled in AD
MTTC: 23 minutes
Phase 3 - Eradication:
[DONE] 3 additional hosts with C2 beacon identified and isolated
[DONE] Cobalt Strike C2 domain (c2[.]evil[.]com) sinkholed
[DONE] Enterprise-wide IOC scan completed — no additional infections
Phase 4 - Recovery:
[DONE] FILESERVER-03 rebuilt from gold image
[DONE] Data restored from immutable Veeam backup (RPO: 4 hours)
[DONE] Systems monitored 72 hours — no reinfection
MTTR: 18 hours
Total Affected: 1 server, 3 workstations
Data Loss: 4 hours of file modifications (backup RPO)
Exfiltration: No evidence of data exfiltration confirmed
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. Please do not remove or change
the license header comment from a contributed file except when
necessary.
Copyright 2026 mukul975
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
API Reference: Ransomware Playbook Automation Agent
Overview
Automates ransomware incident response workflow: sample identification, host isolation via CrowdStrike, IOC extraction via MalwareBazaar, and enterprise-wide IOC scanning via Splunk.
Dependencies
| Package | Version | Purpose |
|---|---|---|
| requests | >=2.28 | HTTP API communication |
CLI Usage
python agent.py --incident-id IR-2024-0500 --sample encrypted_file.locked \
--device-id <device_id> --cs-token <token> \
--splunk-url https://splunk:8089 --splunk-key <key>Arguments
| Argument | Required | Description |
|---|---|---|
--incident-id | Yes | Incident ticket identifier |
--sample | No | Path to encrypted file sample for identification |
--device-id | No | CrowdStrike device ID to isolate |
--cs-token | No | CrowdStrike API bearer token |
--splunk-url | No | Splunk management URL |
--splunk-key | No | Splunk session key |
--output | No | Output report file (default: ransomware_ir_report.json) |
Key Functions
check_id_ransomware(sample_path)
Uploads encrypted file sample to ID Ransomware for variant identification.
query_nomoreransom(ransomware_family)
Checks the No More Ransom Project for available free decryptors.
query_malwarebazaar_hash(file_hash)
Queries Abuse.ch MalwareBazaar API for sample metadata and family attribution.
isolate_host_crowdstrike(api_base, token, device_id)
Isolates a host using the CrowdStrike Falcon contain action API.
search_iocs_splunk(splunk_url, session_key, ioc_list)
Searches Splunk Sysmon data for enterprise-wide IOC matches.
collect_iocs_from_sample(sample_path)
Computes SHA-256/MD5 hashes of a sample and enriches via MalwareBazaar.
External APIs Used
| API | Endpoint | Purpose |
|---|---|---|
| MalwareBazaar | https://mb-api.abuse.ch/api/v1/ | Hash lookup and family ID |
| CrowdStrike Falcon | /devices/entities/devices-actions/v2 | Host isolation |
| ID Ransomware | https://id-ransomware.malwarehunterteam.com/ | Variant identification |
| Splunk REST | /services/search/jobs | Enterprise IOC search |
#!/usr/bin/env python3
"""Ransomware Playbook Automation Agent - Automates SOC ransomware response steps."""
import json
import logging
import os
import argparse
import hashlib
from datetime import datetime
import requests
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
logger = logging.getLogger(__name__)
def check_id_ransomware(sample_path):
"""Upload encrypted file sample to ID Ransomware for variant identification."""
url = "https://id-ransomware.malwarehunterteam.com/index.php"
with open(sample_path, "rb") as f:
files = {"sampleUpload": (sample_path, f)}
resp = requests.post(url, files=files, timeout=60)
logger.info("ID Ransomware response status: %d", resp.status_code)
return resp.text
def query_nomoreransom(ransomware_family):
"""Check No More Ransom Project for available decryptors."""
url = f"https://www.nomoreransom.org/en/decryption-tools.html"
resp = requests.get(url, timeout=30)
if ransomware_family.lower() in resp.text.lower():
logger.info("Decryptor may be available for %s on No More Ransom", ransomware_family)
return True
logger.info("No decryptor found for %s", ransomware_family)
return False
def query_malwarebazaar_hash(file_hash):
"""Query MalwareBazaar for IOC details by SHA-256 hash."""
url = "https://mb-api.abuse.ch/api/v1/"
data = {"query": "get_info", "hash": file_hash}
resp = requests.post(url, data=data, timeout=30)
result = resp.json()
if result.get("query_status") == "ok":
sample = result["data"][0]
logger.info(
"MalwareBazaar match: %s (family: %s)",
sample.get("sha256_hash"),
sample.get("signature"),
)
return sample
return None
def isolate_host_crowdstrike(api_base, token, device_id):
"""Isolate a compromised host via CrowdStrike Falcon API."""
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
resp = requests.post(
f"{api_base}/devices/entities/devices-actions/v2?action_name=contain",
headers=headers,
json={"ids": [device_id]},
timeout=30,
)
resp.raise_for_status()
logger.info("Host %s isolated via CrowdStrike", device_id)
return resp.json()
def search_iocs_splunk(splunk_url, session_key, ioc_list):
"""Search Splunk for IOC matches across the enterprise."""
ioc_query = " OR ".join([f'"{ioc}"' for ioc in ioc_list])
query = (
f"search index=sysmon (EventCode=1 OR EventCode=11 OR EventCode=3) ({ioc_query}) "
"| stats count by Computer, EventCode, Image, CommandLine | sort - count"
)
resp = requests.post(
f"{splunk_url}/services/search/jobs",
headers={"Authorization": f"Splunk {session_key}"},
data={"search": f"search {query}", "output_mode": "json"},
verify=not os.environ.get("SKIP_TLS_VERIFY", "").lower() == "true", # Set SKIP_TLS_VERIFY=true for self-signed certs in lab environments
timeout=30,
)
return resp.json()
def generate_ir_report(incident_id, variant, affected_hosts, containment_actions, iocs):
"""Generate a structured ransomware incident response report."""
report = {
"incident_id": incident_id,
"timestamp": datetime.utcnow().isoformat(),
"ransomware_variant": variant,
"affected_hosts": affected_hosts,
"containment_actions": containment_actions,
"indicators_of_compromise": iocs,
"phases": {
"detection": "Completed",
"containment": "Completed" if containment_actions else "Pending",
"eradication": "Pending",
"recovery": "Pending",
},
}
print(json.dumps(report, indent=2))
return report
def collect_iocs_from_sample(sample_path):
"""Extract IOCs from a ransomware sample file hash."""
with open(sample_path, "rb") as f:
content = f.read()
sha256 = hashlib.sha256(content).hexdigest()
md5 = hashlib.md5(content).hexdigest()
logger.info("Sample SHA-256: %s", sha256)
logger.info("Sample MD5: %s", md5)
bazaar_info = query_malwarebazaar_hash(sha256)
iocs = {"sha256": sha256, "md5": md5}
if bazaar_info:
iocs["family"] = bazaar_info.get("signature", "unknown")
iocs["tags"] = bazaar_info.get("tags", [])
return iocs
def main():
parser = argparse.ArgumentParser(description="Ransomware Playbook Automation Agent")
parser.add_argument("--incident-id", required=True, help="Incident ticket ID")
parser.add_argument("--sample", help="Path to encrypted file sample")
parser.add_argument("--device-id", help="CrowdStrike device ID for isolation")
parser.add_argument("--cs-token", help="CrowdStrike API bearer token")
parser.add_argument("--splunk-url", help="Splunk management URL")
parser.add_argument("--splunk-key", help="Splunk session key")
parser.add_argument("--output", default="ransomware_ir_report.json")
args = parser.parse_args()
iocs = {}
variant = "Unknown"
containment_actions = []
if args.sample:
iocs = collect_iocs_from_sample(args.sample)
variant = iocs.get("family", "Unknown")
query_nomoreransom(variant)
if args.device_id and args.cs_token:
isolate_host_crowdstrike(
"https://api.crowdstrike.com", args.cs_token, args.device_id
)
containment_actions.append(f"Isolated device {args.device_id} via CrowdStrike")
if args.splunk_url and args.splunk_key and iocs:
search_iocs_splunk(args.splunk_url, args.splunk_key, [iocs.get("sha256", "")])
report = generate_ir_report(
args.incident_id, variant, [args.device_id] if args.device_id else [], containment_actions, iocs
)
with open(args.output, "w") as f:
json.dump(report, f, indent=2)
logger.info("IR report saved to %s", args.output)
if __name__ == "__main__":
main()