防护思路
点击放大

> [!IMPORTANT]
> Herodium is a de Linux security framework for testing, research, and controlled deployments.
>
> It works with system-le such as ClamA, AppArmor, Fail2Ban, Maltrail, ZRAM, systemd, and iptables/ipset.
> Test it in a , or non-critical system before using it on a daily-driver or production machine.
>
> Herodium is a flexible foundation. Review and tune the configuration for your own system.
---
Herodium is a de Linux security project designed as a seed framework for building and testing broader defensi.
It runs as a pri background engine and combines multiple defensi into one modular system: real-time file monitoring, removable media scanning, process and command-line inspection, optional Falco-based runtime behavior monitoring, optional network response logic, optional AppArmor policy application, optional system hardening, scheduled antivirus scanning, and supporting operational tools.
This repository is not positioned as a polished enterprise security suite. Its purpose is to provide a practical, extensible foundation that de and security researchers can inspect, modify, and expand.
Herodium currently focuses on these areas:
clamd Unix socket.quarantinedeletealert(device, inode) no longer matches the object that produced theERROR+ policy: only ERROR, CRITICAL, ALERT, and EMERGENCY Falco rules are loaded and e. Lower-se WARNING, NOTICE, INFO, and DEBUG rules are intentionally excluded to avoid routine host activity becoming an alert flood./var/log/herodium/falco-events.jsonl; Herodium and consumes the stream through a persistent cursor, a bounded queue, and a rate-limited dispatcher.iptables / ip6tables.sysctl hardening rules.Herodium is designed for Debian-based Linux systems that use:
aptsystemdThe current installer flow is oriented toward:
and similar Debian/Ubuntu-based distributions.
Root pri are required for installation and normal runtime operation.
Herodium can optionally be used together withauto-cpufreq on physical
systems.
Although auto-cpufreq was designed primarily for laptops, practical testing
with Herodium on a physical workstation showed impro and thermal
efficiency without a noticeable reduction in Herodium performance.
auto-cpufreq dynamically manages CPU frequency scaling, go, and turbo
boost according to system load, CPU temperature, and power state. This can
complement Herodium's own targeted ClamA controls, particularly on
laptops and workstations where lower power consumption, reduced heat, and
quieter operation are desirable.
This integration is optional and is not a Herodium dependency. Results may vary
depending on:
Avoid running multiple tools that manage the same CPU frequency or power
settings unless they have been configured specifically to coexist. In
particular, check for potential conflicts with tools or services such as TLP,power-profiles-daemon, or other go utilities.
Clone the official repository and run its installer:
Install and enable the persistent auto-cpufreq daemon:
Review the current CPU, temperature, go, and power-management status:
For production or long-running Herodium deployments, compare scan completion
times, CPU temperature, system responsi, and queue behavior before and
after enabling auto-cpufreq.
##
##
##
sudo)The main installer entrypoint, installer/install.sh, intentionally remains
non-executable. Invoke it through sudo bash so archi and
source-control mode changes cannot alter the documented installation path.
The interacti currently guides you through:
Depending on your selections, the installer may configure:
/opt/herodium/opt/herodium/venvherodium.servicemaltrail-sensor.serviceherodium-maltrail-update.serviceherodium-maltrail-update.timerinstaller/supply-chain-lock.json--offline)installer/supply-chain-lock.jsonfalco-modern-bpf.service with the modern eBPF driverERROR+ rule policy and alert-only Herodium consumption/etc/falco/config.d/herodium.yaml/etc/falco/rules.d/herodium-rules.yaml/var/log/herodium/falco-events.jsonl/var/lib/herodium/falco/etc/logrotate.d/herodium-falcoherodium-scheduled-scan.serviceherodium-scheduled-scan.timer/var/log/herodium/etc/herodium/scheduled_scan.confHerodium itself is built under /opt/herodium.stage while the currently active
service continues using /opt/herodium. The installer creates a stable source
manifest, copies only regular source files into the root-owned stage, and
that both the source and staged snapshot match before dependency work
begins.
The staged en is new for every installation. Packaging tools
are pinned with SHA-256 hashes in installer/python-tools.lock; runtime
packages are pinned with SHA-256 hashes in herodium/requirements.lock. Pip is
run in isolated mode with user and system configuration disabled,--require-hashes, --no-deps, and the explicit PyPI simple index. The active/opt/herodium/venv is ne in place.
Before acti, the installer the exact installed distribution
set, imports, Python syntax, YAML configuration, pip check, permissions, and
a content manifest. Existing root-owned configuration is preserved and updated
inside the stage. Mutable quarantine contents are copied only after the old
service has been stopped.
Acti rotates /opt/herodium to /opt/herodium.previous and renames the
fully stage into place. The new service must reach Herodium'sPROTECTED health state before the transaction can be committed. A failure or
interrupt before commit restores the previous deployment, service unit,
enabled state, and acti automatically. The deployment
manifest is retained under /var/lib/herodium/supply-chain for operator audit.
Falco provides the runtime-behavior layer that file-content scanning alone cannot
provide. Herodium uses ClamAV to inspect files and process-related file content;
Falco independently obser activity from the kernel and applies Falco
rules to security-relevant behavior. The integration is deliberately one-way:
Falco detects and emits events, while Herodium , correlates, logs, and
optionally notifies. Falco is ne to perform Herodium enforcement
actions such as killing processes, quarantining files, or blocking network
traffic.
The current supply-chain lock pins Falco 0.44.1, its official DEB repository,
the expected signing-key fingerprint, and the modern_ebpf driver. The
installer downloads the signing key as data, the exact trusted
fingerprint, installs the exact package non-interactively, applies an
APT hold, and disables the falcoctl automatic artifact-follow service. This
keeps executable/rule changes tied to an explicit Herodium source and lock-file
update instead of an unattended rules update. Falco's modern eBPF driver is
bundled with Falco and is the upstream default driver on supported systems.
Herodium intentionally configures Falco with:
Falco therefore loads and e only rules with a priority at least as
severe as ERROR: ERROR, CRITICAL, ALERT, and EMERGENCY. This is a
high-signal endpoint policy rather than a full Falco telemetry feed. Rules atWARNING, NOTICE, INFO, and DEBUG are intentionally not active in this
integration because normal desktop and administrati can otherwise
produce excessi. Herodium applies an independent ERROR minimum in
its dispatcher as defense in depth.
Herodium also ships a small local Falco rules file. The current custom rule
detects writes below /etc/systemd/system and classifies them as ERROR, which
keeps persistence-relevant systemd changes under the high-signal
policy. Upstream Falco rules at ERROR or higher remain a as well.
The JSON parser rejects malformed or o records, duplicate JSON keys,
unsupported nesting, invalid priorities, and other out-of-contract input. The
Falco JSONL file itself is root-owned and mode 0600; because it is Falco's
sensor stream, upstream rules may include fields such as command-line context
in that file. Herodium deliberately does not copy raw Falco output or rawproc.cmdline into its processed herodium.log alert summaries. The reader
uses a root-owned persistent cursor at/var/lib/herodium/falco/cursor.json, starts at end-of-file on a clean first
installation, handles rename rotation and copy/truncation safely, waits for
partial records, and bounds work per poll. The monitor queue is bounded, and the
dispatcher drains bounded batches with a bounded alert cache and cooldown.
The event log is rotated daily, retained for se, capped by a
25 MiB maxsize, and reopened by signalling Falco after rotation. The event
stream is intentionally preser normal upgrades, while the cursor is
preserved so old events are not replayed. During an in-place Herodium upgrade,
the installer temporarily quiesces a Herodium-managed Falco sensor after the
Herodium consumer stops and resumes/ Falco only after installer-managed
systemd writes are complete. This prevents the installer from generating its
own persistence alerts without adding a broad rule exception or discarding the
persistent cursor.
Herodium records Falco ownership in the private root-owned marker:
The marker distinguishes a Falco package/repository installed by Herodium from
a pre-existing Falco deployment. The installer refuses to silently claim or
reconfigure unowned Falco assets. On uninstall, Herodium purges Falco and its
repository only when the ownership marker is valid and explicitly states that
Herodium created them; otherwise external Falco state is preserved. Herodium's
own Falco config, rules, logrotate policy, cursor, and ownership state are
remo to that ownership contract.
Operational checks:
Herodium does not install Maltrail from a moving branch. The installer reads an
immutable upstream repository, full commit identifier, and expected license
SHA-256 from installer/supply-chain-lock.json. It fetches only that commit,
the fetched object database, checks the license hash, extracts a
content-only deployment, and activates it only after the service passes a
health check. The prior /opt/maltrail deployment is retained as/opt/maltrail.previous for immediate rollback.
The sensor starts with --offline and uses an explicit root-owned configuration
at /etc/maltrail/maltrail.conf. This keeps packet capture isolated from network
retrieval and prevents the long-running sensor from modifying its own inputs.
Runtime trail state remains namespaced by the pinned code commit.
IOC trails are refreshed separately by herodium-maltrail-update.timer, once
per 24 hours with a randomized delay. The updater executes only the feed modules
from the pinned Maltrail code snapshot, disables feed modules that do not expose
an HTTPS URL, restores normal TLS certificate , and rejects custom
remote/update-ser for the automated path.
Each refresh is built under a private staging HOME. The resulting CSV must pass
strict UTF-8/CS, bounded row and file-size limits, and a
catastrophic-shrink guard relative to the currently active list. A valid
candidate is copied atomically into the acti directory. If the sensor
was running, it is restarted and must return with a non-zero MainPID; otherwise
the previous trails.csv is restored automatically. The last successful
metadata record is stored at:
Run an immediate controlled refresh and inspect its timer with:
Maltrail source code still changes only through an explicitsupply-chain-lock.json update and a new Herodium release. Trail data is
therefore current and mutable, while executable code remains re and
immutable.
Herodium runs scheduled Rkhunter checks and may update Rkhunter threat-data files,
but it never runs rkhunter --propupd automatically. The file-properties
baseline represents trusted local system state and must only be changed after an
operator has in the current warnings and that the changes are
authorized.
Review the current warnings without changing the baseline:
After in and all relevant changes, perform an explicit,
audited baseline update:
The update command requires root pri, an explicit acknowledgement, and a
non-empty reason. It serializes operations with scheduled Rkhunter work and
writes an audit record to:
Common paths used by the current implementation:
Falco's structured event stream can be inspected separately from Herodium's
processed alerts:
Primary runtime configuration is stored in:
Important keys include:
li.enabledirectories.watch_pathsdirectories.ignore_prefixesdirectories.ignore_user_cacheclamaclamamemory_scan.intermemory_scan.whitelistmaltrail.enablemaltrail.block_trafficmaltrail.log_pathmaltrail.clean_interfalco.enablefalco.mode (alert_only only)falco.efalco.cursor_pathfalco.start_positionfalco.queue_max_sizefalco.dispatch.minimum_priorityfalco.dispatch.notification_minimum_priorityfalco.dispatch.alert_cooldown_secondsperformance.enable_zramperformance.cpu_limit_percenthardening.enableips.enableapparmor.levelmemory_scan.whitelist is an executable identity allowlist, not a process-name
allowlist. Entries must be absolute paths. At startup, Memory Hunter resolves each
existing entry and accepts it only when it is a root-owned regular executable with
no group/world write bits. Herodium pins the executable (device, inode) identity
and, before skipping a li, requires /proc/<pid>/exe to refer to that
same object. A copied or renamed binary such as /tmp/firefox is therefore not
trusted merely because its basename or process name resembles a legitimate tool.
After changing the YAML file:
The installer writes scheduled scan settings to:
After changing scheduled scan service or timer behavior:
Out of the box, the current default configuration includes:
/home/tmp/etc/var/www/opt/herodium/quarantinequarantineERROR+ minimum1 — OS default / no Herodium AppArmor changesMain operational logs:
/var/log/herodium/herodium.log/var/log/herodium/scheduled_scan.log/var/log/herodium/falco-events.jsonl when Falco is enabledherodium.log contains the bounded, processed Falco alert summary. The raw
Falco JSONL stream is kept separately for the reader contract and does not mean
that every Falco record will be surfaced as a Herodium alert; the dispatcher
still enforces its configured minimum priority and cooldown.
If Maltrail is installed, related logs are typically stored under:
/var/log/maltrail/To remo and clean up its installed files and service units:
The uninstaller removes:
It can also optionally remo packages installed by the project. A
pre-existing or unowned Falco installation is deliberately preser
than silently purged or reconfigured.
This project is best understood as a starting point for:
The codebase is intentionally modular so indi components can be replaced, extended, or stripped down depending on the use case.
The installer preserves and restores the prior Herodium unit, CLI tools, scheduled-scan assets, deployment manifest, logrotate policy, ClamA and service/socket/updater state, the previous pinned Maltrail deployment, and Herodium-managed Falco transaction state until the acti transaction passes final health checks. During upgrades a managed Falco sensor is quiesced only for installer-owned systemd writes and is re before Herodium starts. Maltrail is stopped with SIGINT so its main process can terminate worker processes cleanly before the timeout. Mutable operator configuration is excluded from the immutable deployment manifest.
Timeshift snapshots are created as on-demand snapshots in a headless command en without desktop notification helpers and are by listing the resulting snapshot before installation continues. This avoids treating a successful snapshot as failed because of an asynchronous desktop-notification error.
A controlled rollback can be requested explicitly by running the installer with HERODIUM_INSTALLER_TEST_FAILPOINT=after_final_ and HERODIUM_INSTALLER_TEST_ACKNOWLEDGE=ROLLBACK-TEST. This test intentionally fails after all final service checks and must restore the previous deployment and service state; it is not enabled during normal installation. The rollback transaction covers deployed code and installer-managed acti assets. General dependency packages installed before acti are not automatically removed, while a Falco package created by the current uncommitted Falco transaction is purged during Falco rollback. A Timeshift snapshot created before acti is ne by rollback.
开发语言:Python
Star 数:36
该项目属于防护思路方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕Herodium is a developer-oriented Linux security project designed as a seed framework for building and testing broader defensive tooling.展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。
从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。
1. 下载源码压缩包,解压到本地环境。
2. 根据项目类型准备对应的运行环境与依赖。
3. 按照 README 中的步骤完成配置与部署。
4. 在隔离的测试环境中运行验证,避免影响生产系统。
本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。
| 资源标题 | herodium - Herodium is a developer-oriented Linux security pr |
| 所属分类 | 防护思路 |
| 发布作者 | admin |
| 发布时间 | 2026-10-06 00:09:41 |
| 下载权限 | 免费下载 |
| 附件数量 | 2 个下载链接 |
| 浏览次数 | 480 |
| 讨论数量 | 0 |
| 主题状态 | 正常讨论中 |