Alisha-chaudhary/CyberSec

GitHub: Alisha-chaudhary/CyberSec

基于 Python 和 MySQL 构建的网络安全学习工具包,涵盖日志分析、正则 IP 提取、访问控制自动化和 SQL 威胁狩猎,帮助安全入门者掌握 SOC 分析师的核心技能。

Stars: 0 | Forks: 0

# Python 与 SQL 安全工具包 总而言之,它反映了 SOC 分析师的日常工具包。实用。专注。源于实践,而非仅仅学习。 [![Python](https://img.shields.io/badge/Python-3.x-blue?logo=python)](https://python.org) [![SQL](https://img.shields.io/badge/SQL-MySQL-orange?logo=mysql)](https://mysql.com) [![License](https://img.shields.io/badge/License-MIT-green)](LICENSE) [![Google Cybersecurity Certificate](https://img.shields.io/badge/Google-Cybersecurity%20Certificate-4285F4?logo=google)](https://grow.google/certificates/cybersecurity/)
## 📁 仓库结构 ``` CyberSec/ ├── access-control-allowlist/ # IP allowlist management & automation ├── Cyber-Sec-Python-Toolkit/ # Core Python security scripts │ ├── algorithms/ # Security automation algorithms │ ├── conditionals/ # Access control logic │ ├── functions/ # Reusable security functions │ ├── log-analysis/ # Log parsing & anomaly detection │ ├── parsing-and-file-handling/ # File I/O for security data │ ├── python-basics/ # Foundational scripting practice │ ├── regular-expressions/ # Regex for IP & device ID extraction │ └── strings/ # String manipulation for security data └── CyberSec-SQL-Threat-Hunting-Toolkit/ ├── database-setup/ # Schema & mock data for a security DB ├── security-queries/ # SOC-style threat hunting queries ├── joins-and-relationships/ # Multi-table correlation queries ├── database-operations/ # CRUD operations for security records └── case-study-threat-investigation/ # End-to-end incident simulation ``` ## 🐍 Python 安全工具包 ### 访问控制与允许列表管理 保持大门整洁。自动更新 IP 允许列表,从而在无需手动清理的情况下保持安全策略的严密性。 - `update_allow_list.py` - 读取允许列表,从单独的移除列表中移除被标记的 IP,然后将清理后的版本写回 - `algorithm_update_allowlist.py` - 一种更加模块化的方法,将逻辑逐步分解 - `algorithm_remove_ips.py` - 专注于在修改列表时的安全迭代,避开常见的 Python 陷阱 **核心概念:** 文件 I/O、列表操作、防御性迭代、安全策略自动化 ### 日志分析与异常检测 模拟 SOC 分析师在海量日志中搜寻可疑行为时所执行操作的脚本。 - `flagged_activity_detector.py` - 扫描日志以查找已知的恶意 IP 地址并发出警报 - `ip_extraction_workflow.py` - 从原始日志字符串中提取 IP 地址以供下游分析 - `log_file_viewer.py` - 读取并显示带有过滤功能的结构化日志文件 **核心概念:** 字符串解析、条件逻辑、警报生成、日志摄取 ### 安全相关的正则表达式 正则表达式对于检测日志、网络流量和设备标识符中的模式至关重要。 | 脚本 | 用途 | |-----------------------------------------|------------------------------------------------------| | `regex_basic_ip_extractor.py` | 从原始文本中提取 IPv4 地址 | | `regex_valid_ip_extractor.py` | 根据适当的八位组范围(0–255)验证 IP | | `regex_variable_length_ip_extractor.py` | 处理具有可变长度八位组的 IP | | `regex_device_id_extractor.py` | 从日志中解析设备 ID 模式 | | `regex_flagged_ip_checker.py` | 将提取的 IP 与被标记的列表进行交叉比对 | ### 安全函数与算法 可重用、文档完善的 Python 函数,模拟了真实的安全自动化逻辑。 - `login_analysis_function.py` - 分析登录尝试数据并标记异常 - `algorithm_assign_user_device.py` - 模拟设备到用户的分配逻辑(资产管理) - `algorithm_join_and_write_file.py` - 连接数据集并写入输出(安全数据的 ETL 操作) ## 🗄️ SQL 威胁狩猎工具包 一个完整的基于 SQL 的威胁狩猎环境,包含逼真的安全数据库模式、模拟数据以及基于真实 SOC 工作流建模的调查查询。 ### 数据库模式 该模式模拟了典型的企业安全数据库: - `login_attempts` - 所有身份验证事件(成功与失败) - `users` - 用户帐户和角色 - `flagged_ips` - 已知的恶意或可疑 IP 地址 - `role_changes` - 权限更改审计日志 - `file_access` - 用于内部威胁检测的文件访问事件 ### 安全查询(SOC 实战就绪) | 查询 | 威胁场景 | |---|---| | `failed_login_counts.sql` | 暴力破解检测 —— 失败次数过多的用户 | | `top_suspicious_ips.sql` | IP 信誉 —— 失败尝试次数最多的 IP | | `successful_after_failed.sql` | 凭据填充 —— 在失败后成功的登录 | | `multiple_accounts_same_ip.sql` | 帐户接管 —— 一个 IP 针对多个帐户 | | `peak_failed_login_hours.sql` | 攻击时机 —— 识别攻击窗口 | | `flagged_ip_activity.sql` | 威胁情报关联 —— 日志中的已知恶意 IP | ### 多表威胁关联 ``` -- Example: Correlate failed logins with flagged IPs and user details SELECT u.username, l.ip_address, f.threat_level, COUNT(*) AS attempts FROM login_attempts l JOIN users u ON l.user_id = u.id JOIN flagged_ips f ON l.ip_address = f.ip_address WHERE l.status = 'FAILED' GROUP BY u.username, l.ip_address, f.threat_level ORDER BY attempts DESC; ``` ### 🔍 案例研究:完整的事件调查 一项模拟的端到端威胁调查,涵盖: 1. **事件概述** — 定义范围和时间线 2. **失败登录分析** — 识别攻击模式 3. **可疑 IP 关联** — 将 IP 映射到威胁情报 4. **权限提升追踪** — 检测横向移动 5. **最终事件报告** — 记录的发现(NIST IR 框架风格) ## 🛠️ 展示的技能 | 领域 | 技能 | |---|---| | **Python** | 文件 I/O、正则表达式、函数、算法、列表/字符串操作 | | **SQL** | JOIN 操作、聚合、子查询、多表关联 | | **安全运营** | 日志分析、访问控制、异常检测、事件响应文档 | | **威胁狩猎** | 暴力破解检测、IP 信誉、权限提升追踪 | | **框架** | NIST 网络安全框架、NIST 事件响应 | ## 📜 认证 该作品集是作为 **[Google 网络安全证书](https://grow.google/certificates/cybersecurity/)** 的一部分构建并对其进行扩展的 —— 这是一个涵盖威胁分析、网络安全、Linux、Python、SQL 和 SIEM 工具的专业级项目。 ## 🚀 如何运行 ``` # 克隆仓库 git clone https://github.com/Alisha-chaudhary/CyberSec.git cd CyberSec # 运行任意 Python 脚本(无需外部依赖) python3 Cyber-Sec-Python-Toolkit/log-analysis/flagged_activity_detector.py # 对于 SQL — 首先导入 schema 和数据 mysql -u root -p < CyberSec-SQL-Threat-Hunting-Toolkit/database-setup/create_tables.sql mysql -u root -p security_db < CyberSec-SQL-Threat-Hunting-Toolkit/database-setup/insert_mock_security_data.sql ``` ## 📬 联系方式 - 🔗 [LinkedIn](https://www.linkedin.com/in/alisha-chaudhary-/) *由好奇心、咖啡以及保护系统安全的真诚兴趣驱动而构建。 🔒*
标签:AMSI绕过, incident simulation, IP 地址批量处理, IP检测, Python, SOC分析师, SQL, Streamlit, 入门安全项目, 多线程, 威胁检测, 子域名变形, 安全工具包, 安全脚本, 安全运营, 异常检测, 扫描框架, 数据库查询, 文件处理, 无后门, 日志解析, 白名单管理, 端到端调查, 系统审计, 红队行动, 网络安全, 网络调试, 自动化, 访问控制, 证书伪造, 谷歌网络安全证书, 逆向工具, 隐私保护