Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

maltrail

> 安全
Open source

Malicious traffic detection system

8.6K stars0 likes6 views
WebsiteGitHub

About

Malicious traffic detection system

Maltrail

Maltrail is a network traffic detection system that identifies communication with known malicious infrastructure and reports selected traffic anomalies. It matches domains, URLs, IP addresses, IP:port pairs, and User-Agent values observed on the network against a set of indicators called trails.

A detection is recorded as a single event containing the source, destination, protocol, matched trail, classification, and trail source:

"2026-08-07 09:14:22.117034" gw 10.13.13.2 57809 1.1.1.1 53 UDP DNS malware.bakewithdavid.com "asyncrat (malware)" (static)

Maltrail is designed for indicator-based network monitoring. Its heuristic detections supplement trail matching, but it is not a replacement for endpoint telemetry or a general-purpose intrusion prevention system.

Features

  • A full trail build combining more than 3,000 bundled static files, 42 public-feed integrations, and optional operator-supplied trails.
  • A multithreaded Rust sensor using libpcap, with optional Linux PACKET_FANOUT capture workers.
  • A Python server providing the reporting interface, event intake, and HTTP API.
  • Plain-text custom trails and whitelists that can be reviewed and version-controlled.
  • Heuristics for scanning, DNS exhaustion, DGA-like lookups, suspicious downloads, proxy probes, suspicious User-Agent values, and related network activity.
  • Local event logging, remote Maltrail logging, CEF over syslog, and Logstash JSON output.
  • Deployment validation with maltrail-sensor -T and optional Prometheus metrics.

Contents

  • Architecture
  • Reporting interface
  • Performance
  • Installation
    • Installer
    • Building from source
    • Systemd
    • Docker
  • Configuration
  • Trails
  • Events and API
  • Operations
    • Monitoring
    • Event retention
  • Documentation
  • Contributing
  • Project
    • License
    • Maintainers
    • Sponsors
    • Presentations and publications
    • Derived blacklist
    • Third-party integrations
    • Acknowledgements

Architecture

Maltrail consists of two independent processes that may run on the same host or on separate hosts:

   ┌──────────┐   events (UDP or file)   ┌──────────┐
   │  sensor  │ ───────────────────────► │  server  │ ◄── browser
   └──────────┘                          └──────────┘
    Rust                                  Python
    libpcap + PACKET_FANOUT               reporting UI + API
    trail matching + heuristics

The sensor captures traffic, performs trail matching and heuristic analysis, and produces events. It can write events locally (LOG_DIR), send them to a remote Maltrail server (LOG_SERVER), or do both. It can also emit CEF over syslog (SYSLOG_SERVER) and JSON to Logstash (LOGSTASH_SERVER).

The server receives and stores remote events, serves locally available event logs, and provides the web interface and API.

Reporting interface

Maltrail includes a browser-based reporting interface for exploring detected traffic, with live updates, field-aware search, retro hunting, geographic views, triage, saved views and export.

The interface is served by server.py at HTTP_ADDRESS:HTTP_PORT. It is plain JavaScript with a single third-party runtime dependency (PapaParse, for CSV parsing) and no build step. One day is viewed at a time, selected with a date picker that doubles as an event-density grid over the available daily logs. Events are streamed from /events and aggregated in the browser into threats — one row per distinct (source, trail) — shown in a sortable grid with a detail panel.

Feature Notes
Live mode Appended events are pushed over Server-Sent Events (/live) and merged into the current view. Falls back to polling byte ranges of the daily log when SSE is unavailable, or for sessions the stream cannot serve. New high-severity threats can raise a desktop notification and an audible alert; both can be muted
Search Field-scoped tokens (src: dst: port: proto: type: trail: info: family: tag: uid: sev: dir: status:; family:interlock pulls in interlock-1/-2, the shards one feed dump arrives split into) combined with space as AND, - to exclude, * wildcards, CIDR (src:10.0.0.0/8), and numeric ranges and comparisons (port:>1024, count:>=100). Active filters appear as removable chips
Retro hunt Searches all retained daily logs for one indicator (/hunt), not just the day in view. Bounded by a day limit, a wall-clock budget and a sample cap; a day the budget cut short is reported separately from the completed days rather than counted as a finished total. A per-day sidecar index (LOG_DIR/index/, USE_EVENT_INDEX) lets the sweep skip every non-matching line and makes /counts exact
World map Per-country event density for the selected day (/geo), placing the external endpoint of each event. Events that cannot be attributed to an external address are reported as unmapped rather than guessed. Set HOME_LAT / HOME_LON to draw origin arcs
Triage Per-threat status (new / investigating / resolved / false positive), free-text notes, tags, and hiding. Whitelist rules and OSINT pivots are available from the row context menu
Saved views Named filter presets
Export The current filtered view as CSV, JSON, or defanged indicators
Appearance Dark and light themes, and discrete text-size steps

Triage state, saved views, tags and appearance settings are stored in the browser (localStorage), not on the server: they are per-browser and per-origin, and are not shared between analysts.

Sessions restricted with a network filter see only events from their own networks, and that restriction applies to the counts, map and blacklist endpoints as well as to the event list.

Country and ASN enrichment for individual addresses is looked up at stat.ripe.net by the server, which caches the results and serves them to the interface from its own /ripe endpoint; the browser talks to nothing but Maltrail. Set DISABLE_RIPE_LOOKUPS to switch the outbound lookups off entirely. Without them — or on a host with no internet access — flags come from the local RIR table instead and everything else in the interface works offline.

Performance

Performance depends on processor, traffic composition, trail-set size, capture driver, and network interface. The figures below measure the sensor's packet-processing path in isolation; they are not end-to-end live-capture measurements.

Representative measurements on an AMD Ryzen 7 PRO 4750U with heuristics enabled and a 1.5 million-row trail set:

Traffic Time per packet
ICMP echo, 58 bytes 101 ns
TCP SYN, 70 bytes 302 ns
Bulk TLS, 1,473 bytes 402 ns
DNS query with a warm cache, 93 bytes 452 ns
Mixed traffic, 866-byte average 552 ns
HTTP request, 169 bytes 602 ns
DNS query with a unique name, 93 bytes 1,102 ns

Offline comparison runs using the same generated capture, configuration, and trail set measured a 14–37× lower steady-state per-packet cost than the retired Python sensor across the tested systems. Those figures separate whole-process time from steady state, because trail loading dominates a short replay. Detection itself is asserted separately, by the 42-case corpus in sensor/tests/replay.rs.

Measure it on the target system with:

bash
cargo bench --manifest-path sensor/Cargo.toml --bench hotpath

One capture worker is used by default. Additional workers can increase capture capacity, but Linux flow hashing divides per-source state between workers and therefore reduces the sensitivity of some scan heuristics. In the documented test, 91% of single-worker heuristic alerts remained with two workers, 86% with four, and 65% with eight. Exact trail matching was unchanged. Increase CAPTURE_FANOUT only when capture-drop metrics show that it is necessary.

Benchmark methodology, hardware results, profiler output, memory measurements, and live fanout checks are documented in sensor/docs/REPORT.md.

Installation

Installer

The installer is verified on twelve Linux distributions — Debian, Ubuntu, Fedora, Rocky, AlmaLinux, Arch, openSUSE Leap and Tumbleweed, and Alpine — plus FreeBSD, NetBSD, OpenBSD and macOS, on every release, with the full result recorded in docs/compat. Raspberry Pi OS and other 64-bit ARM systems use the aarch64 build; 32-bit ARM has no prebuilt sensor and must build it from source.

bash
curl -fsSL https://raw.githubusercontent.com/stamparm/maltrail/master/install.sh | sudo sh

It installs dependencies, creates a managed checkout under /opt/maltrail, verifies the checksum of the prebuilt sensor, creates an unprivileged maltrail account, installs systemd units, prepares the log and state directories, and starts the sensor and server. Re-running the installer upgrades the managed checkout.

Review the script before running it with elevated privileges. From an existing checkout, the dry run shows the commands without changing the system:

bash
sh install.sh --dry-run

Common installer options:

bash
sh install.sh --role sensor      # Install only the sensor
sh install.sh --ref 3.1.2        # Install a release tag instead of master
sh install.sh --no-service       # Install without changing systemd
sh install.sh --dry-run          # Print commands without applying them
sh install.sh --uninstall        # Remove the managed installation; keep logs and state

The dashboard is available at http://127.0.0.1:8338 after installation. Note that the shipped HTTP_ADDRESS is 0.0.0.0, so it is reachable on every interface, not only loopback — and the default credentials are admin / changeme!. Change USERS, and set HTTP_ADDRESS to 127.0.0.1 (or put the server behind a reverse proxy with TLS), before the host is on an untrusted network.

The initial trail build can take several minutes. The sensor does not detect trail matches until a valid trail set is available. The systemd unit runs the sensor's -T validation before startup so that missing privileges, an unwritable log directory, or an invalid trail set causes startup to fail visibly.

The installer test harness covers twelve distributions, and "it installed" is not the assertion: in each one the server is started and asked for /ping, the sensor is asked to validate itself with -T, the units are checked for paths that resolve, the installer is re-run to prove an upgrade keeps operator configuration, and --uninstall is run. Every result is recorded per platform in docs/compat, and the page there is generated from those rows rather than written by hand.

Alpine and other musl systems get a -musl sensor build. They used to be told the prebuilt binary was glibc-linked and to compile their own; the sensor builds and runs on musl natively, so that was a missing artefact rather than a platform limit.

Building from source

The sensor requires Rust 1.74 or newer, libpcap development headers, and the system's capability tools. The server and trail updater require Python 3.6 or newer.

Install the distribution packages:

bash
# Debian / Ubuntu / Raspberry Pi OS
sudo apt-get install cargo libpcap-dev libcap2-bin python3

# RHEL / Fedora
sudo dnf install cargo libpcap-devel libcap python3

# openSUSE / SLES
sudo zypper install cargo rust libpcap-devel libcap-progs python311

Then build and validate the sensor:

bash
git clone --depth 1 https://github.com/stamparm/maltrail.git

Issues· 37 open

View all issuesOpen on GitHub
  • #19631

    [TRAILS CHECK] Domain orphan records

    enhancementUpdated Sep 19, 2026
  • #19630

    [TRAIL CHECK] Green gate for orphan IP in http:// scheme

    bugUpdated Sep 19, 2026
  • #19624

    [TRAILS CHECK] ```# Reference: # Reference:``` as red gate

    enhancementUpdated Sep 7, 2026
  • #19623

    [UI] Icon for CUSTOM trails

    enhancementUpdated Sep 3, 2026
  • #19619

    [TRAILS TESTS] Checks for Amazon IPs

    enhancementUpdated Sep 1, 2026
  • #19618

    [TRAILS CHECK] Orphan spaces check

    enhancementUpdated Sep 1, 2026
  • #19615

    [Questions and Support] PROCESS_COUNT option

    questionsupportUpdated Sep 1, 2026
  • #19616

    [Questions and Support] Example of config pattern for fail2ban

    questionsupportUpdated Aug 31, 2026
  • #19609

    [Questions and Support] LAN traffic monitoring

    questionsupportUpdated Aug 31, 2026
  • #19614

    [Feature Request, HEATMAP] "Skip empty" func for days listing

    enhancementUpdated Aug 31, 2026

> Tags

Pythonattack-detectionintrusion-detectionmalwarenetwork-monitoring

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 30, 2026
Category安全
PricingOpen source

> Related tools

O
OWASP ZAP
开源 Web 应用安全扫描器
O
owasp-wstg-tracker
Simple web app to track OWASP WSTG security testing progress
H
homebridge-mi-gateway-security
XiaoMi Gateway Security plugin for HomeBridge.