██╗ ██╗██╗██████╗ ██╗███████╗
██║ ██║██║██╔══██╗██║██╔════╝
███████║██║██████╔╝██║███████╗
██╔══██║██║██╔══██╗██║╚════██║
██║ ██║██║██║ ██║██║███████║
╚═╝ ╚═╝╚═╝╚═╝ ╚═╝╚═╝╚══════╝
HIRIS(Host Incident Response & Isolation System,主机事件响应与隔离系统)是一款 Linux 事件响应工具,它会在主机上搜寻攻击者并当场将其冻结。反弹 shell、Web shell、Meterpreter、无文件植入、暴力破解入侵:HIRIS 都能捕获它们,用 SIGSTOP 停止进程,切断攻击者的 IP,隔离二进制文件,并将一切记录到日志中以便回滚。
❗ 注意: HIRIS 的设计宗旨是不妨碍你的正常工作。它绝不会触碰自身的进程树、你的 SSH 会话、你的源 IP,也不会触碰
sshd、systemd和auditd等核心服务。
大多数工具只会告诉你攻击者已经入侵。而 HIRIS 会在他们仍身处其中时将其阻止。
它在启动时会扫描所有正在运行的进程,因此即使在 HIRIS 启动之前就已存在的 shell 也会被捕获,随后它会持续监视新出现的进程。一旦发现匹配项,响应计划会按顺序执行:
HIRIS iptables 链中,活动连接会通过 ss -K 被终止。SIGSTOP(或 cgroup v2 freezer)被停止。默认情况下不会杀死任何进程,因此证据会保留在内存中。hiris thaw 可以将其逆转。冻结会在 freeze_timeout(默认 1 小时)后自动解冻,以防启发式规则误判。
nc、socat 或 python 升级为 pty 的 shell 🐚。nginx、apache、php-fpm 等进程生成的 shell,或以 www-data 身份运行的 shell 🌐。/tmp 或 /dev/shm 中的 Meterpreter 和 msfvenom 载荷、无终端的 ssh_login 会话、postgres_login 超级用户会话 🎯。memfd_create 运行的进程、从 memfd 映射的代码,以及带有远程连接的大型匿名可执行内存 👻。postgres 或 mysqld(COPY ... FROM PROGRAM、UDF exec)生成的 shell 🗄️。/root/.ssh 使用 inotify 监视 📌。execve 时立即冻结进程,无轮询延迟 ⚡。hiris thaw 可根据日志撤销冻结和 iptables 规则 ↩️。/proc 的 Linux/proc/*/fd 需要它)iptables 和 sshiris ips 的 auditd克隆仓库:
git clone https://github.com/K3ysTr0K3R/HIRIS.git
cd HIRIS
安装它:
sudo pip install -e .
或者直接从文件夹运行,无需安装:
sudo python3 -m hiris --help
可选的 YARA 支持:
sudo pip install -e ".[yara]"
Usage: hiris [-h] [--version] [-v] {scan,respond,watch,ips,thaw} ...
Commands:
scan One-shot scan, print findings and the response plan
respond Scan and build the plan; --force applies it
watch Continuously monitor and respond
ips Inline IPS on the auditd execve stream
thaw Reverse a response journal
Global:
-v, --verbose -v for INFO logs, -vv for DEBUG
--version Show version and exit
watch:
--auto-respond Execute the response plan automatically (default: alert only)
--i-understand-the-risk
Required with --auto-respond
--kill After freezing, kill the process (irreversible)
--break-glass Strip unsafe actions instead of refusing the plan
--interval SECONDS Seconds between /proc polls (default: 2.0)
--sweep-interval SECONDS
Seconds between full-system sweeps (default: 60, 0 = startup only)
--network Also capture and inspect network traffic
--rules FILE Suricata-style rules file for --network
--interface IFACE Capture interface (default: any)
--config FILE Config file (default: /etc/hiris/config.yaml)
scan / respond:
--force (respond) Apply the plan: isolate, freeze, quarantine
--kill (respond) Kill after freezing (irreversible)
--json FILE Write the full report as JSON
--yara RULES YARA rules to scan executables with
--since-days N Persistence lookback window
--fail-on SEVERITY Exit non-zero if a finding is this severe or worse
仅告警,不进行任何改动:
sudo hiris watch
自动冻结攻击者:
sudo hiris watch --auto-respond --i-understand-the-risk
HIRIS 在监视时会显示实时状态行,并在捕获到目标时立即打印告警框:
╭─ ◆ CRITICAL ──────────────────────────────────────────── shell_socket_stdio 16:26:11 ─╮
│ Reverse shell: bash (pid 516) has stdio on a network socket │
│ │
│ bash pid 516 has its standard input/output connected to 10.10.14.7. Interactive │
│ shells should never read from a TCP socket. │
│ │
│ → 10.10.14.7 │
│ ⊘ pid 516 │
╰────────────────────────────────────────────────────────────────────────────────────────╯
⚡ froze 516 · isolated 10.10.14.7 · journal-1795814771.jsonl
[*] Monitoring system ⠹ 237 procs · 1 findings · 1 frozen · sweep in 42s · up 00:05:12
sudo hiris scan
sudo hiris respond --force
sudo hiris scan --json report.json --fail-on high
在 auditd 记录进程的 execve 时立即冻结该进程,而不是等待下一次 /proc 轮询:
sudo hiris ips --auto-respond --i-understand-the-risk
每次响应都会向 /var/lib/hiris/reports/ 写入一份日志。先预览回滚,然后应用它:
sudo hiris thaw /var/lib/hiris/reports/journal-1795814771.jsonl
sudo hiris thaw /var/lib/hiris/reports/journal-1795814771.jsonl --force
被隔离的二进制文件是故意留在磁盘上的:它们是证据。
HIRIS 读取 /etc/hiris/config.yaml。每个键都是可选的:
quarantine_dir: /var/lib/hiris/quarantine
report_dir: /var/lib/hiris/reports
freeze_method: sigstop
freeze_timeout: 3600
ignore_loopback: true
protected_uids: [1000]
protected_ttys: [/dev/pts/0]
watch_auto_respond: false
watch_kill: false
db_auto_respond: false
correlation_window_sec: 3600
memory_allow_comms: [myjitapp]
ssh_brute_threshold: 5
ssh_brute_window_sec: 300
auth_log_path: /var/log/auth.log
auth_log_paths:
5432: /var/log/postgresql/postgresql-18-main.log
network_auto_respond_sids: [2100498]
| 键 | 作用 |
|---|---|
freeze_method | sigstop、cgroup 或 both |
freeze_timeout | 冻结自动解冻前的秒数,0 表示永不自动解冻 |
ignore_loopback | 跳过 127.0.0.1 连接。设置 false 以针对 localhost 进行测试 |
protected_uids / protected_ttys | 永不冻结这些用户拥有的进程 |
db_auto_respond | 冻结 PostgreSQL 超级用户 TCP 会话(默认仅告警) |
correlation_window_sec | 暴力破解 IP 的记忆时长 |
memory_allow_comms | 允许拥有匿名可执行内存的额外 JIT 运行时 |
auth_log_paths | 额外需要监视暴力破解的按端口服务日志 |
network_auto_respond_sids | 在 --network 模式下允许触发响应的规则 SID |
contrib/ 中附带了一个 systemd 单元:
sudo cp -r . /opt/hiris
sudo cp contrib/hiris.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now hiris
实时观看:
journalctl -u hiris -f
先以仅告警模式运行几天,看看它原本会冻结哪些进程。有些 Web 应用确实会合法地执行 shell 命令。
HIRIS 会在其运行的机器上冻结甚至终止进程,并修改防火墙规则。启发式规则可能误判,从而阻止合法操作。请先在仅告警模式下测试,并自行承担使用风险。对于本工具造成的任何损害,我概不负责。