> Posted by: crypt_guard | Rank: Senior Member | Joined: 2023 [/I]
This guide is for analyzing ransomware behavior and building defenses. Don't run these samples on production systems.
Ransomware is the #1 threat to organizations right now.
Double extortion, RaaS (Ransomware as a Service), targeted attacks - the landscape has changed. Let me walk you through how modern ransomware operates and how to detect it.
---
βββ RANSOMWARE KILL CHAIN βββ[/B]
Code:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RANSOMWARE KILL CHAIN β
ββββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ¬ββββββββββ€
β RECON β INITIAL β PERSIST β ESCALATE β ENCRYPT β EXTORT β
β TARGET β ACCESS β ANCE β PRIV β FILES β DATA β
ββββββ¬ββββββ΄βββββ¬ββββββ΄βββββ¬ββββββ΄βββββ¬ββββββ΄βββββ¬ββββββ΄βββββ¬βββββ
β β β β β β
β’ Email β’ Phishing β’ Registry β’ Token β’ File β’ Crypto
lists links Run keys manipulation encryption note
β β’ Scheduled β’ UAC β’ Database β’ Threat
β Tasks bypass encryption to publish
β β’ Service β’ Exploit β’ SSD encryption
β creation patches β’ VM snapshots
β β’ WMI β’ DCSync
β event β’ Golden
β subscription ticket
---
βββ POPULAR RANSOMWARE FAMILY ANALYSIS βββ
LockBit 3.0 (LockCrypt):
Code:
# Infection vectors:
β’ RDP brute force (default credentials)
β’ EternalBlue exploit (MS17-010)
β’ Phishing emails with malicious attachments
β’ Supply chain compromise
# Technical characteristics:
- Python-based loader
- C++ main payload
- AES-256 + RSA-2048 encryption
- Drops .lockbit ransom note
- WMI persistence
- Disables Windows Defender
- Encrypts VSS (Volume Shadow Copies)
BlackCat (ALPHV):
Code:
# Key features:
- Rust-based (hard to reverse engineer)
- Polymorphic encryption
- Targeted exfiltration (selective files)
- Live-off-the-land techniques
- Anti-analysis techniques
- RDP connection hijacking
Conti (Discontinued but variants exist):
Code:
# Characteristics:
- Golang-based
- Domain Fronting for C2
- Mapped drive enumeration
- SQL Server backup file targeting
- Custom crypto modules
---
βββ RANSOMWARE DETECTION SIGNATURES βββ
Behavioral Indicators:
Code:
# File System Monitoring
β’ Rapid file modification (>100 files/sec)
β’ Unknown file extensions being added (.locked, .crypt, .enc)
β’ Ransom note files created (README*.txt, HOW_TO_DECRYPT*)
β’ Volume Shadow Copy deletion
β’ Shadow copy service stopped
# Process Monitoring
β’ crypt32.dll usage in unusual processes
β’ vssadmin.exe with delete shadows
β’ bcdedit.exe modifying boot configuration
β’ wmic.exe shadowcopy delete operations
β’ PsExec/Sysinternal tools usage
β’ PowerShell with encoded commands
YARA Rule for Ransomware Detection:
Code:
rule ransomware_generic {
meta:
description = "Generic ransomware detection rule"
author = "crypt_guard"
date = "2024-01-15"
strings:
$ransom_note = "Your files have been encrypted" ascii wide
$decrypt_url = "http://.*\\.onion/.*" ascii wide
$bitcoin_addr = "bc1[a-zA-Z0-9]{25,}" ascii wide
$ransom_ext = /\.(locked|crypt|enc|encrypt|xor)$/ ascii wide
$vssadmin = "vssadmin delete shadows" ascii wide
$bcdedit = "bcdedit /set {default} bootstatuspolicy ignoreallfailures" ascii wide
condition:
3 of them or (2 of them and filesize < 10MB)
}
---
βββ RANSOMWARE ANALYSIS FRAMEWORK βββ
Code:
#!/usr/bin/env python3
"""
Ransomware Behavior Analyzer
Sandbox analysis framework for ransomware samples
"""
import os
import subprocess
import hashlib
import json
import time
import shutil
from datetime import datetime
from pathlib import Path
import psutil
class RansomwareAnalyzer:
def __init__(self, sample_path, output_dir='analysis'):
self.sample_path = sample_path
self.output_dir = Path(output_dir)
self.output_dir.mkdir(exist_ok=True)
self.monitoring_threads = []
self.events = []
def analyze_static(self):
"""Static analysis of ransomware sample"""
print("[*] Running static analysis...")
# File information
file_info = {
'name': os.path.basename(self.sample_path),
'size': os.path.getsize(self.sample_path),
'sha256': hashlib.sha256(open(self.sample_path, 'rb').read()).hexdigest(),
'md5': hashlib.md5(open(self.sample_path, 'rb').read()).hexdigest(),
}
# Strings extraction
try:
result = subprocess.run(
['strings', self.sample_path],
capture_output=True, text=True
)
file_info['strings'] = result.stdout.split('\n')[:1000]
# Check for suspicious strings
suspicious_patterns = [
'ransom', 'bitcoin', 'decrypt', 'payment',
'onion', ' TOR ', '.onion', 'encrypt',
'vssadmin', 'bcdedit', 'cipher', 'wbadmin'
]
file_info['suspicious_strings'] = [
s for s in result.stdout.split('\n')
if any(p in s.upper() for p in suspicious_patterns)
]
except:
file_info['strings'] = []
file_info['suspicious_strings'] = []
# PE header analysis (for Windows executables)
if self.sample_path.endswith('.exe'):
file_info['pe_info'] = self.analyze_pe()
return file_info
def analyze_pe(self):
"""Analyze PE header for Windows executables"""
try:
result = subprocess.run(
['pefile', self.sample_path],
capture_output=True, text=True
)
return {'pe_analysis': result.stdout}
except:
return {}
def monitor_behavior(self, duration=60):
"""Monitor ransomware behavior during execution"""
print(f"[*] Monitoring for {duration} seconds...")
# Record initial state
initial_processes = set(p.pid for p in psutil.process_iter())
initial_files = set(str(p) for p in Path('/tmp').glob('*'))
# Execute the sample
try:
proc = subprocess.Popen(
[self.sample_path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
time.sleep(duration)
proc.kill()
except Exception as e:
print(f"[-] Execution error: {e}")
# Record final state
final_processes = set(p.pid for p in psutil.process_iter())
final_files = set(str(p) for p in Path('/tmp').glob('*'))
# Analyze changes
new_processes = final_processes - initial_processes
new_files = final_files - initial_files
return {
'new_processes': list(new_processes),
'new_files': list(new_files)[:100],
'duration': duration,
}
def generate_report(self):
"""Generate comprehensive analysis report"""
static = self.analyze_static()
behavioral = self.monitor_behavior()
report = {
'analysis_id': f"RANSOM-{datetime.now().timestamp():.0f}",
'timestamp': datetime.now().isoformat(),
'static_analysis': static,
'behavioral_analysis': behavioral,
'threat_assessment': self.assess_threat(static, behavioral),
}
# Save report
report_path = self.output_dir / f"report_{report['analysis_id']}.json"
with open(report_path, 'w') as f:
json.dump(report, f, indent=2)
print(f"[+] Report saved: {report_path}")
return report
def assess_threat(self, static, behavioral):
"""Assess threat level based on analysis"""
risk_score = 0
# Check suspicious strings
if static.get('suspicious_strings'):
risk_score += len(static['suspicious_strings']) * 10
# Check file modifications
if len(behavioral.get('new_files', [])) > 50:
risk_score += 30
# Check new processes
if len(behavioral.get('new_processes', [])) > 10:
risk_score += 20
# Determine threat level
if risk_score > 100:
return {'level': 'CRITICAL', 'score': risk_score}
elif risk_score > 50:
return {'level': 'HIGH', 'score': risk_score}
elif risk_score > 20:
return {'level': 'MEDIUM', 'score': risk_score}
else:
return {'level': 'LOW', 'score': risk_score}
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--sample', required=True, help='Ransomware sample path')
parser.add_argument('--output', default='analysis')
args = parser.parse_args()
analyzer = RansomwareAnalyzer(args.sample, args.output)
report = analyzer.generate_report()
print(json.dumps(report, indent=2))
---
βββ DEFENSE STRATEGIES βββ
Code:
1. BACKUP STRATEGY
β’ 3-2-1 rule: 3 copies, 2 media types, 1 offsite
β’ Immutable backups (write-once-read-many)
β’ Offline/air-gapped backups
β’ Regular restore testing
2. DETECTION
β’ Endpoint Detection & Response (EDR)
β’ File integrity monitoring
β’ Behavioral analysis
β’ Network traffic monitoring
3. PREVENTION
β’ Email filtering & sandboxing
β’ Web proxy with malware detection
β’ Application whitelisting
β’ Patch management
β’ User training
4. RESPONSE
β’ Incident response plan
β’ Isolation procedures
β’ Forensic preservation
β’ Communication plan
---
βββ RANSOMWARE IOCs βββ
Code:
# === File-based IOCs ===
*.locked (LockBit)
*.crypt (BlackCat)
*.enc ( encrypted files)
*.R00T (R00t ransomware)
*.darkness (DarkSide)
readme_decrypt.txt (various)
HOW_TO_DECRYPT.html (various)
# === Registry Keys ===
HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run
HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run
HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows\\Defender
# === Network IOCs ===
.onion domains (Tor hidden services)
Specific C2 IP ranges per family
DNS queries to random-looking domains (DGA)
---
βββ TL;DR βββ
Code:
β
Track the ransomware kill chain
β
Monitor for rapid file encryption
β
Watch for VSS deletion commands
β
Use YARA rules for detection
β
Implement 3-2-1 backup strategy
β
Test restore procedures regularly
---
What's your ransomware defense setup? Share below.
Next: Malware reverse engineering with Ghidra.
Last edited by crypt_guard; 45 minutes ago.
[SIG]ββββββββββββββββββββββββββββββββββββββββ
crypt_guard | Senior Member | Ransomware Researcher
ββββββββββββββββββββββββββββββββββββββββ[/SIG][/b][/b][/b][/b][/b][/b]