Loading...
Loading...
Analyze volatile memory (RAM) dumps for forensic investigation. Use when investigating malware infections, rootkits, process injection, credential theft, or any incident requiring analysis of system memory state. Supports Windows, Linux, and macOS memory images.
npx skill4agent add sherifeldeeb/agentskills memory-forensicsfrom memory_forensics import MemoryAnalyzer, ProcessScanner, MalwareDetector
# Initialize analyzer with memory image
analyzer = MemoryAnalyzer("/path/to/memory.raw")
# Get system profile
profile = analyzer.identify_profile()
print(f"Detected OS: {profile.os_name} {profile.version}")
# Scan for processes
scanner = ProcessScanner(analyzer)
processes = scanner.list_processes(include_hidden=True)
# Detect malware indicators
detector = MalwareDetector(analyzer)
findings = detector.scan_all()from memory_forensics import MemoryAcquisition
# Windows acquisition guidance
acquisition = MemoryAcquisition()
# Get tool recommendations
tools = acquisition.recommend_tools(
os_type="windows",
os_version="10",
acquisition_type="live"
)
# Generate acquisition command
cmd = acquisition.generate_command(
tool="winpmem",
output_path="E:\\evidence\\memory.raw",
format="raw"
)
print(f"Execute: {cmd}")
# Create acquisition documentation
doc = acquisition.create_documentation(
case_id="INC-2024-001",
examiner="John Doe",
target_hostname="WORKSTATION01",
acquisition_tool="WinPMEM 4.0",
hash_algorithm="SHA256"
)from memory_forensics import MemoryAnalyzer, ProcessScanner
analyzer = MemoryAnalyzer("/evidence/memory.raw")
scanner = ProcessScanner(analyzer)
# List all processes with details
processes = scanner.list_processes(
include_hidden=True,
include_terminated=False
)
for proc in processes:
print(f"PID: {proc.pid}, Name: {proc.name}, PPID: {proc.ppid}")
print(f" Created: {proc.create_time}")
print(f" Command Line: {proc.cmdline}")
print(f" Suspicious: {proc.is_suspicious}")
# Detect hidden processes
hidden = scanner.find_hidden_processes()
for proc in hidden:
print(f"HIDDEN: PID {proc.pid} - {proc.name}")
# Analyze process tree
tree = scanner.build_process_tree()
tree.print_tree()
# Find orphan processes
orphans = scanner.find_orphan_processes()
# Detect process hollowing
hollowed = scanner.detect_hollowing()
for proc in hollowed:
print(f"HOLLOWED: {proc.pid} - {proc.name}")
print(f" Image path mismatch: {proc.image_mismatch}")from memory_forensics import MemoryAnalyzer, ModuleScanner
analyzer = MemoryAnalyzer("/evidence/memory.raw")
module_scanner = ModuleScanner(analyzer)
# Analyze all loaded modules
modules = module_scanner.enumerate_modules(pid=4892)
for mod in modules:
print(f"Module: {mod.name}")
print(f" Base: 0x{mod.base_address:x}")
print(f" Size: {mod.size}")
print(f" Path: {mod.path}")
# Detect DLL injection
injections = module_scanner.detect_dll_injection()
for inj in injections:
print(f"INJECTION in PID {inj.target_pid}:")
print(f" Technique: {inj.technique}")
print(f" Injected DLL: {inj.dll_name}")
print(f" Source PID: {inj.source_pid}")
# Find unlinked modules
unlinked = module_scanner.find_unlinked_modules()
# Detect reflective DLL loading
reflective = module_scanner.detect_reflective_loading()
# Extract suspicious module
module_scanner.extract_module(
pid=4892,
module_name="suspicious.dll",
output_path="/evidence/extracted/"
)from memory_forensics import MemoryAnalyzer, NetworkScanner
analyzer = MemoryAnalyzer("/evidence/memory.raw")
net_scanner = NetworkScanner(analyzer)
# Get all network connections
connections = net_scanner.get_connections()
for conn in connections:
print(f"PID {conn.pid} ({conn.process_name}):")
print(f" Protocol: {conn.protocol}")
print(f" Local: {conn.local_addr}:{conn.local_port}")
print(f" Remote: {conn.remote_addr}:{conn.remote_port}")
print(f" State: {conn.state}")
# Find connections to suspicious IPs
suspicious = net_scanner.find_suspicious_connections(
threat_intel_feed="/feeds/malicious_ips.txt"
)
# Get listening ports
listening = net_scanner.get_listening_ports()
for port in listening:
print(f"Port {port.port}/{port.protocol} - PID {port.pid}")
# Detect covert channels
covert = net_scanner.detect_covert_channels()
# Export to CSV
net_scanner.export_connections("/evidence/network_connections.csv")from memory_forensics import MemoryAnalyzer, CredentialExtractor
analyzer = MemoryAnalyzer("/evidence/memory.raw")
cred_extractor = CredentialExtractor(analyzer)
# Extract all credentials
credentials = cred_extractor.extract_all()
# Get NTLM hashes
ntlm_hashes = cred_extractor.get_ntlm_hashes()
for cred in ntlm_hashes:
print(f"User: {cred.username}")
print(f"Domain: {cred.domain}")
print(f"NTLM Hash: {cred.ntlm_hash}")
# Extract Kerberos tickets
tickets = cred_extractor.get_kerberos_tickets()
for ticket in tickets:
print(f"Service: {ticket.service_name}")
print(f"Client: {ticket.client_name}")
print(f"Expiry: {ticket.expiry_time}")
# Find LSA secrets
lsa_secrets = cred_extractor.get_lsa_secrets()
# Extract cached domain credentials
cached = cred_extractor.get_cached_credentials()
# Export credentials report
cred_extractor.export_report("/evidence/credentials_report.json")from memory_forensics import MemoryAnalyzer, MalwareDetector
analyzer = MemoryAnalyzer("/evidence/memory.raw")
detector = MalwareDetector(analyzer)
# Run comprehensive malware scan
findings = detector.scan_all()
# Detect code injection
injections = detector.detect_code_injection()
for inj in injections:
print(f"Injection found in PID {inj.pid}:")
print(f" Type: {inj.injection_type}")
print(f" Address: 0x{inj.address:x}")
print(f" Size: {inj.size}")
# Scan with YARA rules
yara_matches = detector.scan_yara(
rules_path="/rules/malware_rules.yar"
)
for match in yara_matches:
print(f"YARA Match: {match.rule_name}")
print(f" PID: {match.pid}")
print(f" Offset: 0x{match.offset:x}")
# Detect API hooks
hooks = detector.detect_api_hooks()
for hook in hooks:
print(f"Hook: {hook.function_name}")
print(f" Original: 0x{hook.original_address:x}")
print(f" Hooked: 0x{hook.hook_address:x}")
# Check SSDT integrity
ssdt_mods = detector.check_ssdt()
# Detect DKOM (Direct Kernel Object Manipulation)
dkom = detector.detect_dkom()
# Export IOCs
detector.export_iocs("/evidence/memory_iocs.json")from memory_forensics import MemoryAnalyzer, RegistryAnalyzer
analyzer = MemoryAnalyzer("/evidence/memory.raw")
reg_analyzer = RegistryAnalyzer(analyzer)
# List available registry hives
hives = reg_analyzer.list_hives()
for hive in hives:
print(f"Hive: {hive.name} at 0x{hive.virtual_address:x}")
# Extract hive to file
reg_analyzer.extract_hive(
hive_name="SYSTEM",
output_path="/evidence/SYSTEM_hive"
)
# Query specific key
value = reg_analyzer.query_key(
hive="SOFTWARE",
key_path="Microsoft\\Windows\\CurrentVersion\\Run"
)
# Find persistence mechanisms
persistence = reg_analyzer.find_persistence()
for entry in persistence:
print(f"Persistence: {entry.location}")
print(f" Value: {entry.value}")
print(f" Type: {entry.persistence_type}")
# Get recently modified keys
recent = reg_analyzer.get_recent_modifications(hours=24)
# Search registry for pattern
matches = reg_analyzer.search(pattern="*.exe", include_values=True)from memory_forensics import MemoryAnalyzer, IOCExtractor
analyzer = MemoryAnalyzer("/evidence/memory.raw")
ioc_extractor = IOCExtractor(analyzer)
# Extract all IOCs
iocs = ioc_extractor.extract_all()
# Get URLs
urls = ioc_extractor.extract_urls()
for url in urls:
print(f"URL: {url.value}")
print(f" Found at: 0x{url.offset:x}")
print(f" Process: {url.process_name}")
# Get IP addresses
ips = ioc_extractor.extract_ips()
for ip in ips:
print(f"IP: {ip.value} ({ip.geo_location})")
# Get domains
domains = ioc_extractor.extract_domains()
# Get file paths
paths = ioc_extractor.extract_file_paths()
# Extract strings from specific process
proc_strings = ioc_extractor.extract_strings(
pid=4892,
min_length=4,
encoding="both" # ascii and unicode
)
# Correlate with threat intel
enriched = ioc_extractor.enrich_iocs(
threat_feed="/feeds/threat_intel.json"
)
# Export IOCs in STIX format
ioc_extractor.export_stix("/evidence/memory_iocs.stix")from memory_forensics import MemoryAnalyzer, RootkitDetector
analyzer = MemoryAnalyzer("/evidence/memory.raw")
rootkit_detector = RootkitDetector(analyzer)
# Run comprehensive rootkit scan
results = rootkit_detector.scan_all()
# Check for hidden drivers
hidden_drivers = rootkit_detector.find_hidden_drivers()
for driver in hidden_drivers:
print(f"Hidden Driver: {driver.name}")
print(f" Base: 0x{driver.base:x}")
print(f" Size: {driver.size}")
# Analyze SSDT
ssdt_hooks = rootkit_detector.analyze_ssdt()
for hook in ssdt_hooks:
print(f"SSDT Hook: {hook.function}")
print(f" Expected: 0x{hook.expected:x}")
print(f" Actual: 0x{hook.actual:x}")
# Check IDT (Interrupt Descriptor Table)
idt_mods = rootkit_detector.analyze_idt()
# Detect inline hooks in kernel
inline_hooks = rootkit_detector.detect_inline_hooks()
# Check kernel callbacks
callbacks = rootkit_detector.analyze_callbacks()
for cb in callbacks:
print(f"Callback: {cb.type}")
print(f" Address: 0x{cb.address:x}")
print(f" Module: {cb.module}")
# Generate rootkit report
rootkit_detector.generate_report("/evidence/rootkit_analysis.html")from memory_forensics import MemoryAnalyzer, MemoryTimeline
analyzer = MemoryAnalyzer("/evidence/memory.raw")
timeline = MemoryTimeline(analyzer)
# Generate comprehensive timeline
events = timeline.generate()
for event in events:
print(f"{event.timestamp}: {event.event_type}")
print(f" Source: {event.source}")
print(f" Details: {event.details}")
# Get process timeline
proc_timeline = timeline.get_process_timeline()
# Get network timeline
net_timeline = timeline.get_network_timeline()
# Find events around specific time
window = timeline.get_events_around(
timestamp="2024-01-15T10:30:00",
window_minutes=30
)
# Export to timeline format
timeline.export_csv("/evidence/memory_timeline.csv")
timeline.export_json("/evidence/memory_timeline.json")
# Generate visual timeline
timeline.generate_html_report("/evidence/timeline_report.html")| Variable | Description | Required | Default |
|---|---|---|---|
| Path to Volatility installation | No | System PATH |
| Default YARA rules directory | No | ./rules |
| Path to debug symbols | No | None |
| Threat intelligence feed URL | No | None |
| Option | Type | Description |
|---|---|---|
| string | Force specific OS profile |
| string | Output format (json, csv, html) |
| boolean | Enable verbose output |
| boolean | Enable YARA scanning |
| boolean | Enable parallel processing |
from memory_forensics import MemoryAnalyzer, ProcessScanner, MalwareDetector, NetworkScanner
# Load memory dump from infected system
analyzer = MemoryAnalyzer("/evidence/infected_host.raw")
# Step 1: Identify suspicious processes
scanner = ProcessScanner(analyzer)
suspicious = scanner.find_suspicious_processes()
print(f"Found {len(suspicious)} suspicious processes")
# Step 2: Check for known ransomware indicators
detector = MalwareDetector(analyzer)
ransomware_iocs = detector.scan_yara("/rules/ransomware.yar")
# Step 3: Identify C2 connections
net_scanner = NetworkScanner(analyzer)
external_conns = net_scanner.find_external_connections()
suspicious_c2 = net_scanner.check_against_threat_intel("/feeds/c2_ips.txt")
# Step 4: Extract encryption keys (if in memory)
keys = detector.find_crypto_keys()
# Step 5: Generate comprehensive report
analyzer.generate_report(
output_path="/evidence/ransomware_analysis.html",
include_timeline=True,
include_iocs=True
)from memory_forensics import MemoryAnalyzer, CredentialExtractor, ProcessScanner
analyzer = MemoryAnalyzer("/evidence/dc_memory.raw")
# Look for Mimikatz artifacts
scanner = ProcessScanner(analyzer)
mimikatz_indicators = scanner.search_command_lines(
patterns=["sekurlsa", "logonpasswords", "lsadump"]
)
# Extract compromised credentials
extractor = CredentialExtractor(analyzer)
credentials = extractor.extract_all()
# Check for Kerberos ticket theft (Golden/Silver ticket)
tickets = extractor.get_kerberos_tickets()
for ticket in tickets:
if ticket.is_suspicious():
print(f"ALERT: Suspicious ticket for {ticket.service_name}")
# Document affected accounts
extractor.generate_affected_accounts_report("/evidence/compromised_accounts.csv")from memory_forensics import MemoryAnalyzer, RootkitDetector, ModuleScanner
analyzer = MemoryAnalyzer("/evidence/server_memory.raw")
# Comprehensive rootkit analysis
rootkit_detector = RootkitDetector(analyzer)
# Check kernel integrity
integrity = rootkit_detector.verify_kernel_integrity()
if not integrity.is_clean:
print("ALERT: Kernel modifications detected!")
for mod in integrity.modifications:
print(f" - {mod.description}")
# Find hidden components
hidden_drivers = rootkit_detector.find_hidden_drivers()
hidden_processes = rootkit_detector.find_hidden_processes()
# Analyze all hooks
all_hooks = rootkit_detector.find_all_hooks()
# Generate remediation guidance
rootkit_detector.generate_remediation_guide("/evidence/rootkit_remediation.md")--profile