Scripting Python, automating analysis workflows, dan building custom tools mempercepat investigasi dan mengurangi human error dalam forensik

Setelah di episode 24 kita membahas OSINT & digital investigation, pada episode ini kita masuk ke forensic automation & tooling — scripting Python untuk mengotomasi tugas-tugas forensik yang berulang, membangun custom tools, dan menciptakan workflows yang konsisten dan terdokumentasi.
Mengapa automation penting dalam forensik? Karena banyak tugas forensik bersifat repetitif: hashing ratusan file, parsing log yang sama, atau menghasilkan laporan dengan format seragam. Automation mengurangi human error dan mempercepat investigasi.
# Forensic analysis libraries
import hashlib # Hashing
import struct # Binary parsing
import sqlite3 # SQLite analysis
import pefile # PE analysis (Windows executables)
import yara # Pattern matchingimport hashlib
import os
import json
def hash_directory(directory):
results = {}
for root, dirs, files in os.walk(directory):
for filename in files:
filepath = os.path.join(root, filename)
sha256 = hashlib.sha256()
with open(filepath, 'rb') as f:
for chunk in iter(lambda: f.read(8192), b''):
sha256.update(chunk)
results[filepath] = sha256.hexdigest()
return results
evidence = hash_directory('/evidence/files/')
with open('/evidence/hashes.json', 'w') as f:
json.dump(evidence, f, indent=2)import re
from datetime import datetime
log_pattern = r'(\S+) \S+ \S+ \[([^\]]+)\] "(\S+) (\S+) \S+" (\d+) (\d+)'
with open('/evidence/access.log') as f:
for line in f:
match = re.match(log_pattern, line)
if match:
ip, timestamp, method, url, status, size = match.groups()
if int(status) >= 400: # Filter error responses
print(f"{timestamp} | {ip} | {method} {url} | {status}")#!/bin/bash
CASE=$1
EVIDENCE="/evidence/$CASE"
# 1. Hash evidence
echo "[1/5] Hashing evidence..."
find $EVIDENCE -type f -exec sha256sum {} \; > $EVIDENCE/hashes.txt
# 2. Extract strings
echo "[2/5] Extracting strings..."
find $EVIDENCE -type f -exec strings {} \; > $EVIDENCE/all_strings.txt
# 3. YARA scanning
echo "[3/5] YARA scanning..."
find $EVIDENCE -type f -exec yara -r rules/ {} \; > $EVIDENCE/yara_results.txt
# 4. Generate timeline
echo "[4/5] Generating timeline..."
log2timeline.py --storage-file $EVIDENCE/timeline.plaso $EVIDENCE/disk.raw
# 5. Generate report
echo "[5/5] Generating report..."
python3 generate_report.py $CASE > $EVIDENCE/report.htmlKetika tools yang ada tidak memenuhi kebutuhan spesifik:
import struct
from datetime import datetime, timedelta
def parse_windows_timestamp(filetime):
"""Convert Windows FILETIME to datetime"""
timestamp = filetime
epoch = datetime(1601, 1, 1)
return epoch + timedelta(microseconds=timestamp // 10)
# Contoh penggunaan
print(parse_windows_timestamp(132987654000000000))import subprocess
import json
def analyze_memory(dump_path):
results = {}
# Process list
output = subprocess.run(
['volatility3', '-f', dump_path, 'linux.pslist'],
capture_output=True, text=True
)
results['processes'] = output.stdout
# Network connections
output = subprocess.run(
['volatility3', '-f', dump_path, 'linux.netscan'],
capture_output=True, text=True
)
results['network'] = output.stdout
return resultsTip
Mulailah dengan script sederhana yang mengotomasi satu tugas berulang. Setelah nyaman, kembangkan menjadi workflow pipeline yang lebih kompleks. Automation harus bertumbuh seiring pengalaman.
Inti yang harus dibawa pulang:
Di episode 26 selanjutnya kita akan membahas ekosistem & tren modern 2026 — cloud forensics wajib, AI-assisted triage, dan kombinasi IR + forensik. Siapkan wawasan industri kalian!