NullAILab/nullai-network-covert-channel

GitHub: NullAILab/nullai-network-covert-channel

一个纯 Python 实现的网络隐写术库,提供四种基于标准协议字段的隐蔽通道编码方案及配套的启发式检测能力,适用于安全研究与攻防演练。

Stars: 0 | Forks: 0

# 网络隐蔽通道 ![Python](https://img.shields.io/badge/python-3.10%2B-blue) ![Tests](https://img.shields.io/badge/tests-43%20passed-brightgreen) ![License](https://img.shields.io/badge/license-MIT-green) 一个网络隐写术库,实现了四种将数据隐藏在标准协议字段内的隐蔽通道——IP TTL 值、TCP 初始序列号、DNS 查询标签和 HTTP 头部排序。包含启发式检测器和带宽计算器。 ## 功能特性 - **IP TTL 通道** — 在 TTL 字段中编码 1 字节/包;支持零字节 - **TCP ISN 通道** — 在 32 位初始序列号中编码 4 字节/包 - **DNS 查询通道** — 十六进制编码的子域名(最高可达 31 字节/查询) - **HTTP 头部排序通道** — 通过 8 个头部的 Lehmer 编码排列实现 1 字节/请求(8!=40320 种排列) - **隐蔽通道检测器** — 对 TTL 分布、ISN 方差、十六进制 DNS 标签和头部顺序多样性进行启发式分析 - **带宽计算器** — 每种通道的理论容量(比特/包,比特/秒) ## 项目结构 ``` 62-network-covert-channel/ ├── src/ │ ├── channels.py # TTLChannel, ISNChannel, DNSChannel, HTTPHeaderChannel │ ├── detector.py # CovertChannelDetector with heuristic analysis │ └── bandwidth.py # Channel capacity calculations └── tests/ └── test_covert_channels.py ``` ## 快速开始 ``` from src.channels import TTLChannel, ISNChannel, DNSChannel, HTTPHeaderChannel from src.detector import CovertChannelDetector from src.bandwidth import ttl_capacity, isn_capacity # TTL channel ch = TTLChannel() packets = ch.encode(b"secret message") recovered = ch.decode(packets) assert recovered == b"secret message" # DNS channel dns = DNSChannel() pkts = dns.encode(b"exfiltrated data") # pkts[0]['qname'] == '65786669...74.covert.local' # 检测 covert 流量 det = CovertChannelDetector() ttl_values = [42, 17, 200, 88, 133, 9, 77] # non-standard TTLs finding = det.analyse_ttl(ttl_values) if finding: print(f"Detected {finding.channel_type} (confidence={finding.confidence:.2f})") # Bandwidth cap = isn_capacity(pps=10) print(f"ISN channel: {cap.max_bps} bps at 10 pps") # 320 bps ``` ## 通道容量 | 通道 | 比特/包 | 示例 @ 10 pps | |---------|------------|-----------------| | IP TTL | 8 | 80 bps | | TCP ISN | 32 | 320 bps | | DNS 查询 | 248 (31 B) | 1240 bps | | HTTP 头部 | ~15.3 (log₂8!) | ~30.6 bps | ## 运行测试 ``` python -m pytest tests/ -v ``` ## 参考文献 - [TCP/IP 中的隐蔽通道 — Rowland 1997](https://dl.acm.org/doi/10.1145/263932.263949) - [DNS 隐蔽通道 — SANS](https://www.sans.org/white-papers/34152/) - [网络隐写术综述](https://ieeexplore.ieee.org/document/6461127)
标签:Covert Channel, DNS隐写, HTTP头隐写, IP TTL, IP 地址批量处理, Lehmer编码, Python, Steganography, TCP ISN, 信息隐藏, 内核驱动, 协议分析, 启发式检测, 安全测试, 安全规则引擎, 带宽计算, 攻击性安全, 数据包操作, 数据外发, 无后门, 权限提升, 网络协议, 网络安全, 网络隐写术, 隐私保护, 隐蔽通道