#!/usr/bin/env python3 """ LNK File and Jump List Forensic Analyzer Parses LNK file headers and extracts forensic metadata including target paths, timestamps, volume information, and machine identifiers. """ import struct import os import sys import json import csv from datetime import datetime, timedelta from pathlib import Path FILETIME_EPOCH = datetime(1601, 1, 1) def filetime_to_datetime(ft_bytes: bytes): """Convert Windows FILETIME to datetime.""" ft = struct.unpack(" dict: """Parse a Windows LNK file and extract forensic metadata.""" with open(filepath, "rb") as f: data = f.read() if len(data) < 76: return {"error": "File too small for LNK header"} header_size = struct.unpack(" str: """Scan a directory for LNK files and generate analysis report.""" os.makedirs(output_dir, exist_ok=True) results = [] for root, dirs, files in os.walk(lnk_dir): for fname in files: if fname.lower().endswith(".lnk"): filepath = os.path.join(root, fname) parsed = parse_lnk_file(filepath) results.append(parsed) report_path = os.path.join(output_dir, "lnk_analysis_report.json") with open(report_path, "w") as f: json.dump({ "analysis_timestamp": datetime.now().isoformat(), "source_directory": lnk_dir, "total_lnk_files": len(results), "files": results }, f, indent=2, default=str) print(f"[*] Analyzed {len(results)} LNK files") print(f"[*] Report: {report_path}") return report_path def main(): if len(sys.argv) < 3: print("Usage: python process.py ") sys.exit(1) scan_directory(sys.argv[1], sys.argv[2]) if __name__ == "__main__": main()