Multi-phase forensic analysis platform integrating ML-driven malware detection, NTFS timeline reconstruction, LLM-powered threat analysis, and automated case reporting.
AegisAI PIPELINE
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Suspicious Input (PE/APK/Scripts/Docs) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Phase 1: Detection & Quarantine β
β YARA (1000+ rules) β PE Analysis β Doc2Vec β Stats ML β
ββββββοΏ½οΏ½βββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Phase 2: Metadata Extraction β
β EXIF β Zone.Identifier β Browser Forensics β Hashing β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Phase 3: Path Reconstruction β
β MFT Timeline β USN Journal β Attack Chain Mapping β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Phase 4: Reporting & Case Management β
β SQLite Case DB β Chain-of-Custody β IOC β MITRE ATT&CK β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Advanced Modules οΏ½οΏ½οΏ½
β MirGuard (GAT + Contrastive) β GenDFIR (FAISS + LLM) β
β ZORA (Threat Prediction - 89% accuracy) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Architected FAISS-backed vector store for forensic log retrieval, enabling LLM context injection for accelerated timeline extractions.
Audit Logs βββΊ LogEmbedder (384-dim) βββΊ FAISS IndexFlatL2
β
Query Log βββΊ Embed βββΊ Similarity Search βββββββ
β
βΌ
Top-K Similar Incidents (RAG Context)
β
βΌ
LLM Timeline Reconstruction
# HybridDetection/gendfir/vector_database.py
class VectorDatabase:
"""FAISS-backed vector store for forensic log RAG retrieval"""
def __init__(self, embedding_dim: int = 384):
self.embedding_dim = embedding_dim
self.embedder = LogEmbedder(embedding_dim=embedding_dim)
if FAISS_AVAILABLE:
self.index = faiss.IndexFlatL2(embedding_dim)
self.use_faiss = True
else:
self.index = None
self.use_faiss = False
self.fallback_embeddings = []
self.logs = []
self.metadata = []
def search(self, query_log: Dict, top_k: int = 5) -> List[Tuple[Dict, float, Dict]]:
"""Retrieve similar forensic logs for LLM context augmentation"""
query_embedding = self.embedder.embed(query_log).reshape(1, -1)
if self.use_faiss:
distances, indices = self.index.search(query_embedding, top_k)
results = [
(self.logs[idx], float(dist), self.metadata[idx])
for dist, idx in zip(distances[0], indices[0])
if idx < len(self.logs)
]
return resultsDesigned normalized relational schemas supporting multi-case forensic tracking with full evidence lifecycle and chain-of-custody.
ββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ
β cases βββ1:Nβββ evidence β β tasks β
ββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ
β case_id (PK) β β evidence_id (PK) β β task_id (PK) β
β case_number β β case_id (FK) β β case_id (FK) β
β case_name β β evidence_number β β task_name β
β status β β file_path β β assigned_to β
β examiner β β md5/sha1/sha256 β β status β
β priority β β collected_by οΏ½οΏ½οΏ½ β priority β
ββββββββββββββββ β status β ββββββββββββββββ
ββββββββββββββββββββ
# Phase4-Reporting/scripts/case_manager.py
def init_database(self):
"""Initialize SQLite database with forensic schema"""
conn = sqlite3.connect(self.db_path)
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS cases (
case_id TEXT PRIMARY KEY,
case_number TEXT UNIQUE NOT NULL,
case_name TEXT NOT NULL,
description TEXT,
status TEXT NOT NULL,
priority TEXT,
created_date TEXT NOT NULL,
closed_date TEXT,
examiner TEXT,
notes TEXT,
metadata TEXT
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS evidence (
evidence_id TEXT PRIMARY KEY,
case_id TEXT NOT NULL,
evidence_number TEXT NOT NULL,
file_path TEXT NOT NULL,
file_name TEXT NOT NULL,
file_size INTEGER,
file_type TEXT,
md5_hash TEXT,
sha1_hash TEXT,
sha256_hash TEXT,
collected_date TEXT NOT NULL,
collected_by TEXT,
description TEXT,
status TEXT NOT NULL,
FOREIGN KEY (case_id) REFERENCES cases(case_id)
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS tasks (
task_id TEXT PRIMARY KEY,
case_id TEXT NOT NULL,
task_name TEXT NOT NULL,
assigned_to TEXT,
status TEXT NOT NULL,
priority TEXT,
created_date TEXT NOT NULL,
due_date TEXT,
completed_date TEXT,
FOREIGN KEY (case_id) REFERENCES cases(case_id)
)
""")
conn.commit()Built multi-layer GAT encoder generating graph-level embeddings from system provenance graphs, trained with NT-Xent contrastive loss, anomalies isolated via K-Means cluster distance thresholding.
Audit Logs βββΊ Provenance Graph Construction
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β GAT Encoder (3 layers, 4 heads) β
β node_features βββΊ GATConv βββΊ BN βββΊ β
β ELU βββΊ Dropout βββΊ ... βββΊ Pool β
βββββββββββββββββββ¬ββββββββββββββββββββββββ
β 256-dim graph embedding
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β Contrastive Learning (NT-Xent) β
β Positive pairs: augmented views β
β Negative pairs: different graphs β
βββββββββββββββββββ¬ββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β K-Means Anomaly Detection β
β Cluster assignment βββΊ Distance to β
β centroid βββΊ Threshold βββΊ Anomaly? β
βββββββββββββββββββββββββββββββββββββββββββ
# HybridDetection/mirguard/gat_encoder.py
class GATEncoder(nn.Module):
"""Graph Attention Network encoder for provenance graphs"""
def __init__(self, node_feature_dim: int = 64, hidden_dim: int = 128,
embedding_dim: int = 256, num_heads: int = 4,
num_layers: int = 3, dropout: float = 0.2):
super(GATEncoder, self).__init__()
self.convs = nn.ModuleList()
self.convs.append(
GATConv(node_feature_dim, hidden_dim, heads=num_heads, dropout=dropout)
)
for _ in range(num_layers - 2):
self.convs.append(
GATConv(hidden_dim * num_heads, hidden_dim, heads=num_heads, dropout=dropout)
)
self.convs.append(
GATConv(hidden_dim * num_heads, embedding_dim, heads=1, dropout=dropout)
)
def forward(self, data):
x, edge_index, batch = data.x, data.edge_index, data.batch
for i, conv in enumerate(self.convs[:-1]):
x = conv(x, edge_index)
x = self.batch_norms[i](x)
x = F.elu(x)
x = F.dropout(x, p=self.dropout, training=self.training)
x = self.convs[-1](x, edge_index)
return global_mean_pool(x, batch)
class ContrastiveLoss(nn.Module):
"""NT-Xent contrastive loss for graph anomaly separation"""
def __init__(self, temperature: float = 0.5):
super(ContrastiveLoss, self).__init__()
self.temperature = temperature
def forward(self, embeddings1, embeddings2):
batch_size = embeddings1.shape[0]
embeddings1 = F.normalize(embeddings1, dim=1)
embeddings2 = F.normalize(embeddings2, dim=1)
embeddings = torch.cat([embeddings1, embeddings2], dim=0)
similarity_matrix = torch.matmul(embeddings, embeddings.T) / self.temperature
labels = torch.arange(batch_size, device=embeddings.device)
labels = torch.cat([labels + batch_size, labels], dim=0)
mask = torch.eye(2 * batch_size, dtype=torch.bool, device=embeddings.device)
similarity_matrix = similarity_matrix.masked_fill(mask, -float('inf'))
return F.cross_entropy(similarity_matrix, labels)Created statistical feature extraction pipeline computing 13 divergence metrics (KL, Jensen-Shannon, Canberra, etc.) across byte 1-4 gram histograms for ML-based malware classification.
Binary File βββΊ Byte Stream
β
βββββββββββββββΌββββββββββββββ
βΌ βΌ βΌ
1-gram hist 2-gram hist 3-gram hist
(256 bins) (65536 bins) (truncated)
β β β
βΌ βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββ
οΏ½οΏ½ 13 Statistical Features per gram: β
β KL-Divergence β Jensen-Shannon β β
β Canberra β Manhattan β Chebyshev β β
β Entropy β Correlation β ... β
ββββββββββββββββββββ¬ββββββββββββββββββββ
βΌ
52-dim Feature Vector βββΊ ML Classifier
# Phase1-Detection/scripts/statistical_features.py
def extract_ngram_histogram(self, data: bytes, n: int) -> np.ndarray:
"""Extract normalized n-gram frequency histogram from byte data"""
if len(data) < n:
return np.zeros(256**n if n <= 2 else self.max_ngram_size)
ngrams = []
for i in range(len(data) - n + 1):
ngram = sum(data[i+j] * (256**(n-1-j)) for j in range(n))
ngrams.append(ngram)
counter = Counter(ngrams)
if n <= 2:
histogram = np.zeros(256**n)
for ngram, count in counter.items():
histogram[ngram] = count
else:
histogram = np.zeros(self.max_ngram_size)
for ngram, count in counter.items():
histogram[ngram % self.max_ngram_size] += count
total = histogram.sum()
if total > 0:
histogram = histogram / total
return histogram
def kullback_leibler_divergence(self, hist: np.ndarray, ref: np.ndarray) -> float:
"""KL Divergence: D_KL(P||Q) = sum(p_i * log(p_i / q_i))"""
epsilon = 1e-10
hist = hist + epsilon
ref = ref + epsilon
return np.sum(hist * np.log(hist / ref))
def extract_13_features(self, hist: np.ndarray, ref: np.ndarray) -> List[float]:
"""Extract 13 statistical divergence features from histogram pair"""
return [
self.simpsons_index(hist),
self.canberra_distance(hist, ref),
self.minkowski_distance(hist, ref, lambda_param=3),
self.manhattan_distance(hist, ref),
self.chebyshev_distance(hist, ref),
self.bray_curtis_distance(hist, ref),
self.angular_separation(hist, ref),
self.correlation_coefficient(hist, ref),
self.entropy(hist),
self.kullback_leibler_divergence(hist, ref),
self.jensen_shannon_divergence(hist, ref),
self.itakura_saito_divergence(hist, ref),
self.total_variation(hist, ref)
]Built Doc2Vec vectorization pipeline converting APK hex dumps (Manifest + DEX) into 400-dimensional embeddings for SVM-driven malware classification.
APK File βββΊ ZipExtract
β
ββββββββββββ΄βββββββββββ
βΌ βΌ
AndroidManifest.xml classes.dex
β β
βΌ βΌ
bytes.hex() bytes.hex()
β β
βΌ βΌ
8-char token chunks 8-char token chunks
β β
βΌ βΌ
Doc2Vec (200-dim) Doc2Vec (200-dim)
β β
ββββββββββββ¬βββββββββββ
βΌ
400-dim Combined Vector βββΊ SVM Classifier
# Phase1-Detection/scripts/android_doc2vec.py
class AndroidDoc2VecExtractor:
"""Vectorizes Android APK hex dumps for SVM malware classification"""
def __init__(self, model_path: Optional[str] = None, vector_size: int = 200):
self.vector_size = vector_size
if model_path and os.path.exists(model_path):
self.model = Doc2Vec.load(model_path)
else:
self.model = self._create_mock_model()
def extract_apk_components(self, apk_path: str) -> Tuple[Optional[str], Optional[str]]:
"""Extract Manifest and DEX as hex strings from APK"""
manifest_content = None
dex_hex_content = None
with zipfile.ZipFile(apk_path, 'r') as apk_zip:
if 'AndroidManifest.xml' in apk_zip.namelist():
manifest_content = apk_zip.read('AndroidManifest.xml').hex()
for name in apk_zip.namelist():
if name.endswith('.dex'):
dex_hex_content = apk_zip.read(name).hex()
break
return manifest_content, dex_hex_content
def hexdump_to_tokens(self, hex_string: str, chunk_size: int = 8) -> list:
"""Convert hex string to token sequence for Doc2Vec"""
return [hex_string[i:i+chunk_size]
for i in range(0, len(hex_string), chunk_size)
if len(hex_string[i:i+chunk_size]) == chunk_size]
def extract_apk_features(self, apk_path: str) -> np.ndarray:
"""Generate 400-dim feature vector (200 Manifest + 200 DEX)"""
manifest_content, dex_content = self.extract_apk_components(apk_path)
manifest_vector = (self.infer_vector(manifest_content)
if manifest_content else np.zeros(self.vector_size))
dex_vector = (self.infer_vector(dex_content)
if dex_content else np.zeros(self.vector_size))
return np.concatenate([manifest_vector, dex_vector])# Phase 1: Detect malware
python Phase1-Detection/scripts/integrated_detector.py --file suspect.exe --format json
# Phase 2: Extract metadata
python Phase2-Metadata/scripts/metadata_extractor.py --file suspect.exe --assess-risk
# Phase 3: Reconstruct attack path
python Phase3-PathReconstruction/scripts/mft_timeline_extractor.py --mft C:\$MFT --focus-file suspect.exe
# Phase 4: Generate unified report
python Phase4-Reporting/scripts/unified_report.py
# ZORA: Predict attacker next moves
python ZORA/zora_predictor.py --observed-techniques T1486,T1059.001git clone <repository_url>
cd AegisAI
pip install -r Phase1-Detection/requirements.txt
pip install -r Phase2-Metadata/requirements.txt
pip install -r Phase3-PathReconstruction/requirements.txt
pip install -r Phase4-Reporting/requirements.txt
pip install torch torch-geometric networkx faiss-cpu # HybridDetectionRequirements: Python 3.8+ | 8GB RAM min | Admin access for MFT extraction
AegisAI/
βββ Phase1-Detection/ # YARA, PE, Doc2Vec, Statistical ML
βββ Phase2-Metadata/ # EXIF, Zone.ID, Browser Forensics
βββ Phase3-PathReconstruction/ # MFT Timeline, Attack Chains
βββ Phase4-Reporting/ # SQLite Case DB, Chain-of-Custody, Reports
βββ HybridDetection/
β βββ mirguard/ # GAT Encoder, Contrastive Learning, K-Means
β βββ gendfir/ # FAISS Vector DB, LLM RAG Pipeline
βββ ZORA/ # Threat Prediction Engine (89% accuracy)