daxlerboi/Windows-Security-Toolkit

GitHub: daxlerboi/Windows-Security-Toolkit

一个结合批处理工具和机器学习管道的 Windows 安全监控系统,用于实时异常检测和可视化警报。

Stars: 0 | Forks: 0

# Windows 安全工具包 [![Windows](https://img.shields.io/badge/Windows-supported-0078D4?logo=windows&logoColor=white)](https://www.microsoft.com/windows) [![Python](https://img.shields.io/badge/Python-used-3776AB?logo=python&logoColor=white)](https://www.python.org/) [![Batch](https://img.shields.io/badge/Batch-tools-222222)](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands) [![Streamlit](https://img.shields.io/badge/Streamlit-dashboard-FF4B4B?logo=streamlit&logoColor=white)](https://streamlit.io/) [![scikit--learn](https://img.shields.io/badge/scikit--learn-used-F7931E?logo=scikitlearn&logoColor=white)](https://scikit-learn.org/) 开发者:`daxler_boi` 一个结合了以下功能的混合型 Windows 安全与监控工具包: * 基于批处理的安全工具 * Python 遥测数据收集 * 机器学习异常检测 * 启发式风险分析 * 实时监控仪表盘 ## 概述 Windows 安全工具包旨在使用传统检测逻辑和基于机器学习的算法行为分析来监控和分析 Windows 系统。 该项目结合了: * 经典的 Windows 检查工具 * 实时进程遥测 * 异常检测 * 可疑行为分析 * 警报日志 * 监控仪表盘 ## 功能特性 ### 批处理安全工具 #### SecurityTool.bat 菜单驱动的 Windows 安全实用程序。 功能: * 网络检查 * 活跃连接分析 * 启动项检查 * 计划任务检查 * 防火墙检查 * 进程分析 * 系统情报报告 #### BasicRATScan.bat 专注于远程访问木马 (RAT) 和可疑活动的扫描器。 功能: * 可疑连接检测 * 端口分析 * 远程 IP 检查 * 风险评分 * 可疑进程捕猎 ## 机器学习监控器 `ML-Monitor/` 项目提供: * 进程遥测数据收集 * 基线学习 * 异常检测 * 启发式风险评分 * 持久性检查 * 实时监控 * 警报日志 * Streamlit 仪表盘 ## 文件夹结构 ``` Windows Security Toolkit/ ├── Batch Tools/ │ ├── SecurityTool.bat │ └── BasicRATScan.bat │ ├── ML-Monitor/ │ ├── collector/ │ │ ├── __init__.py │ │ ├── process_collector.py │ │ ├── persistence_collector.py │ │ ├── network_collector.py │ │ └── __pycache__/ │ │ │ ├── dashboard/ │ │ ├── __init__.py │ │ └── live_dashboard.py │ │ │ ├── data/ │ │ ├── baseline/ │ │ │ └── baseline_data.csv │ │ │ │ │ └── alerts/ │ │ └── alerts.log │ │ │ ├── ml/ │ │ ├── __init__.py │ │ ├── train_model.py │ │ ├── detect.py │ │ ├── anomaly_model.pkl │ │ ├── scaler.pkl │ │ └── __pycache__/ │ │ │ ├── rules/ │ │ ├── __init__.py │ │ ├── heuristic_engine.py │ │ ├── suspicious_paths.py │ │ └── __pycache__/ │ │ │ ├── utils/ │ │ ├── __init__.py │ │ ├── feature_extractor.py │ │ ├── hash_utils.py │ │ ├── logger.py │ │ └── __pycache__/ │ │ │ ├── collect_baseline.py │ ├── monitor.py │ └── requirements.txt │ ├── assets/ │ └── dashboard_screenshot.png │ ├── Batch Tools/ │ └── (batch processing utilities) │ ├── .git/ │ ├── .gitignore ├── LICENSE ├── README.md ├── logs/ ├── comments-backup/ └── venv/ (Python virtual environment) ``` ## 系统要求 安装依赖项: ``` pip install -r ML-Monitor/requirements.txt ``` ## 使用的 Python 库 * psutil * pandas * numpy * scikit-learn * joblib * streamlit * plotly * rich ## 安装说明 ### 克隆仓库 ``` git clone https://github.com/daxlerboi/Windows-Security-Toolkit ``` ### 进入项目目录 ``` cd "Windows Security Toolkit" ``` ### 创建虚拟环境 ``` python -m venv venv ``` ### 激活虚拟环境 #### CMD ``` venv\Scripts\activate ``` #### PowerShell ``` .\venv\Scripts\Activate.ps1 ``` ### 安装依赖项 ``` pip install -r ML-Monitor/requirements.txt ``` ## 完整执行流程 ## 步骤 1 — 进入 ML 监控器目录 ``` cd ML-Monitor ``` ## 步骤 2 — 收集基线数据 ``` python collect_baseline.py ``` 此操作收集正常的系统行为数据。 生成的数据集保存至: ``` data/baseline/baseline_data.csv ``` 收集期间建议进行以下操作: * 网页浏览 * 编程 * 游戏 * 多任务处理 * 正常 PC 使用 ## 步骤 3 — 训练机器学习模型 ``` python ml/train_model.py ``` 这将创建: ``` ml/anomaly_model.pkl ml/scaler.pkl ``` 该模型使用: * Isolation Forest * 特征缩放 * 异常检测 ## 步骤 4 — 启动实时监控 ``` python monitor.py ``` 监控器执行: * 进程检查 * 异常预测 * 启发式风险评分 * 警报生成 * 可疑路径检测 警报保存至: ``` data/alerts/alerts.log ``` ## 步骤 5 — 启动仪表盘 打开另一个终端: ``` cd dashboard ``` 然后执行: ``` streamlit run live_dashboard.py ``` 仪表盘 URL: ``` http://localhost:8501 ``` ## 主要代码组件 ## 基线数据收集器 文件: ``` collect_baseline.py ``` 主要目的: * 收集进程遥测数据 * 构建正常行为数据集 * 生成机器学习训练数据 示例: ``` processes = collect_processes() for process in processes: features = extract_features(process) writer.writerow(features) time.sleep(2) ``` ## 特征提取 文件: ``` utils/feature_extractor.py ``` 将原始遥测数据转换为机器学习特征。 示例: ``` return { "cpu": process.get("cpu", 0), "memory": process.get("memory", 0), "suspicious_path": suspicious_path } ``` ## 模型训练 文件: ``` ml/train_model.py ``` 示例: ``` df = pd.read_csv( "data/baseline/baseline_data.csv" ) X = df[['cpu', 'memory', 'suspicious_path']] scaler = StandardScaler() X_scaled = scaler.fit_transform(X) model = IsolationForest( contamination=0.02, random_state=42 ) model.fit(X_scaled) ``` 此操作训练异常检测模型。 ## 实时检测 文件: ``` ml/detect.py ``` 示例: ``` model = joblib.load( "ml/anomaly_model.pkl" ) scaler = joblib.load( "ml/scaler.pkl" ) prediction = model.predict(X_scaled) ``` ## 启发式风险引擎 文件: ``` rules/heuristic_engine.py ``` 启发式引擎为以下情况增加风险分值: * 可疑的可执行文件路径 * 高 CPU 使用率 * 异常的 RAM 使用量 * 可疑的进程名称 示例: ``` if cpu > 80: score += 3 if memory > 30: score += 3 ``` ## 实时监控引擎 文件: ``` monitor.py ``` 主监控循环: ``` processes = collect_processes() for process in processes: features = extract_features(process) prediction = predict_anomaly(features) risk = calculate_risk(process) if prediction == -1 or risk >= 5: alert = ( f"Suspicious Process | " f"{process['name']} | " f"PID={process['pid']}" ) log_alert(alert) ``` 这结合了: * 机器学习检测 * 启发式分析 * 警报日志 ## 仪表盘 文件: ``` dashboard/live_dashboard.py ``` 使用以下技术构建: * Streamlit * Pandas * Plotly 仪表盘包括: * 实时图表 * 进程指标 * 监控状态 * 活动表格 * 警报显示 ## 检测逻辑 工具包结合了两种检测系统。 ### 机器学习检测 Isolation Forest 检测异常的进程行为模式。 例如: * 异常的 CPU 峰值 * 奇怪的内存使用 * 不常见的可执行文件行为 ### 启发式检测 基于规则的逻辑检测: * 可疑目录 * LOLBins * 持久性指标 * 异常的资源使用 ## 未来改进计划 计划中的功能: * 实时网络遥测 * Windows 事件日志分析 * 注册表持久性扫描 * YARA 集成 * 实时仪表盘指标 * 恶意软件哈希查询 * 隔离引擎 * Discord/Telegram 警报 * GPU 遥测监控 ## 注意事项 * 主要为 Windows 系统设计 * 部分扫描可能需要管理员权限 * 大量使用 `psutil` 进行遥测数据收集 * Isolation Forest 是一种无监督的机器学习算法 * 仪表盘当前使用模拟的图表值,后续可连接到实时遥测数据 ## 贡献 欢迎贡献和改进。 潜在改进领域: * 更强的机器学习特征 * 改进的遥测数据收集 * 仪表盘增强 * 检测调优 * 持久性覆盖范围 * SIEM 集成 ## 联系方式 开发者:`daxler_boi` Windows 安全研究与机器学习辅助监控工具包。 ## 许可证 本项目采用 MIT 许可证 - 详情请见 LICENSE 文件。
标签:Kubernetes, Qt, 逆向工具