Skip to content

About

Scanning Agent running with Plum-Island

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

56 Commits

Folders and files

Repository files navigation

d4-Plum-Island

Proactive Land Uncovering & Monitoring

Pathogen Agent

d4-Plum-Island

*Beta version*

Description

This this tool is the working agent designed to work with Plum-Island

Technical requirements

Python 3.10 or > Git installed at runtime and a Git checkout, so the agent can report its tag or commit hash.

Supported scanners

Configure banner sources with python src/agent.py -s --masscan-ip-v4 ADDRESS and/or --masscan-ip-v6 ADDRESS. The legacy --masscan-ip ADDRESS option selects the corresponding family automatically. Reserve an unused address on the local subnet outside the kernel's interfaces. The agent checks its format and warns if it is assigned to a kernel interface; setup and startup continue. Setup mode (-s) displays warnings even with debug: none. The operator must verify that no other device uses the address and that it is reachable on the network. Restart the agent to announce it to Island. Clear a family with --masscan-ip-v4 "" or --masscan-ip-v6 "". Masscan uses --source-ip for banner jobs, which must use the same address family. Without this setting, the agent receives Masscan port checks only. No firewall configuration is required by Plum.

IPv4/IPv6 availability is detected independently from external connectivity and Masscan binary support. Island must supply scan_family: ipv4 or ipv6 for each Masscan job. Only matching targets are scanned; an empty family slice completes without invoking Masscan. Unresolved hostnames are skipped with a warning; remaining targets are scanned. If none remain, the job completes with an empty result instead of returning to the queue.

Nmap and Masscan. At startup, the agent enables every supported executable found on PATH unless it is explicitly disabled in the configuration. It exits before requesting work when no scanner remains available.

With an Island version that predates Masscan support, the agent uses Nmap only. Nmap must be installed and enabled in the agent configuration. Restart the agent after upgrading Island so it can detect the new scanner protocol.

Installation

Installation should stay simple.

Setup

sudo apt-get install nmap masscan git clone https://github.com/D4-project/Plum-Agent.git
cd Plum-Agent
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Run the agent as a normal service account. Masscan needs raw-socket access on Linux; grant it to the executable instead of running the whole agent as root:

sudo setcap cap_net_raw=eip /usr/bin/masscan
getcap /usr/bin/masscan

The agent verifies this at startup and prints the command for the executable it actually found when the capability is missing.

nmap2json dependency

Plum-Agent and current Plum-Island require nmap2json>=2611.4. The agent checks this minimum version and the hostname conversion API before registering or requesting jobs. Version 2611.4 is published on PyPI. Install the requirements in the agent virtual environment:

python -m pip install -r requirements.txt
python -m pip check

Versions older than 2611.4 do not meet this minimum. Preserve complete received banners; existing Nmap truncation cannot be reversed. Masscan's FTP parser removes carriage returns before producing XML; retain its output without adding bytes. Island derives the standard banner and observed http-headers fields for search and tagging. Volatile protocol clocks are masked only before hashing. Existing historical hashes are not migrated automatically.

Scan activity counters

Updated Island job responses request report_target_count: true. The agent then reports PORTS_TARGETED with the completed result, including nonresponding targets. Masscan counts the union of its already resolved targets and requested TCP ports; Nmap uses the XML host total and scaninfo port counts. These are intended IP/transport/port pairs, not packet counts. No extra DNS lookup or scan is issued. Missing Nmap metadata or an unsuccessful Nmap exit leaves the count unknown. The optional field is omitted for older controllers, preserving compatibility. Restart the agent after updating its code. Older agents keep working with a new Island: completed jobs and open ports are counted, while targeted ports show unknown.

Configuration

cd src
python agent.py -s -island HOSTOFISLAND -agentkey XXXTHETOKENKEYXXXX

Optional GMT scan window:

scanhours: 14-16

Or from the command line:

python agent.py -s -scanhours 14-16

Optional parallel scan jobs:

scanparallel: 1
nmap_scanparallel: 3
masscan_scanparallel: 4

Or from the command line:

python agent.py -s -scanparallel 1 --nmap-scanparallel 3 --masscan-scanparallel 4

scanparallel is the fallback per scanner (default 1), not a total ceiling. Each explicit per-scanner limit takes priority, even above scanparallel. The example allows 3 Nmap and 4 Masscan jobs simultaneously (7 total). Per-scanner overrides must be integers >= 1. A fallback of 0 pauses scanners without an explicit override. CLI values override YAML and are saved by setup. These limits control simultaneous scan processes, not internal scanner threads or packet rates. Restart the agent after changing them. Use nmap_disabled or masscan_disabled to disable a scanner. If Island supplies a job whose scanner is at capacity, the agent holds at most one pending job and waits before requesting another. This can temporarily leave capacity unused for the other scanner; pending jobs are released on shutdown.

Optional daily log retention:

logrotation: 30

Or from the command line:

python agent.py -s -logrotation 30

Installed tools are enabled by default. Disable one without changing the agent identity or UID:

nmap_disabled: true
# masscan_disabled: true

Masscan defaults to 1,000 packets per second. The local operator may change the limit without changing profiles on Island:

masscan_rate: 5000

With Masscan enabled, the agent resolves hostname jobs locally, scans every distinct returned address and converts Masscan XML through nmap2json. The profile's Detect protocol option adds --banners; without it, Masscan only reports port state. Interrupted jobs are returned to Island and restart from the beginning on the next compatible agent.

Choose the output mode in src/config/config.yaml:

debug: none

none (default) shows agent INFO, WARNING and ERROR messages, with scanner progress hidden. info / -v also shows Nmap and Masscan output at INFO level and enables Nmap verbosity (-v). debug / -vv adds agent DEBUG messages, Nmap debugging (-d, --script-trace) and Masscan verbosity (-vv), displaying scanner output at DEBUG level. Both CLI options override the YAML mode. Existing debug: false and debug: true values still select none and debug respectively.

Profile-level Nmap parameters

Queued jobs may include optional nmap_additional_params, for example:

{"nmap_additional_params": "--min-hostgroup 32 --host-timeout 5m"}

The agent tokenizes this string with shell-style quoting, then passes each token directly to Nmap as an argv item. It never invokes a shell. Values are limited to 4096 characters. Shell-control syntax, the -- option terminator, malformed quoting, and parameters that replace agent-managed ports, XML output, or NSE selection are rejected before Nmap starts.

Profile values override matching agent defaults. Both --option value and --option=value forms are supported. Missing, null, and empty values retain the agent defaults, so jobs from older Plum-Island versions remain compatible. Removing the field from a profile rolls behavior back to those defaults. Updated Plum-Island responses remain compatible with older agents because the field is additive.

Nmap command logging

In info and debug modes, before each scan starts, the agent logs an INFO command preview capped at 132 characters. Longer commands end with a truncation marker containing the full character count. When debug is enabled, a separate DEBUG record contains the complete executable and final argv. Arguments use shell-safe quoting for reproduction, but the scan still executes the original argv list without invoking a shell. Both records include the shortened job UID so commands remain attributable during parallel scans.

When debug is enabled, troubleshooting diagnostics also report active APP_VERSION, whether nmap_additional_params reached the agent, its type, and parsed option names. Raw profile values are excluded from these diagnostics. A missing field means legacy defaults are expected; a present field with defaults still active indicates payload shape, queue, or deployment-version mismatch.

Command records are unredacted. Do not place passwords, tokens, or other secrets in Nmap arguments such as --script-args; INFO may expose their preview and DEBUG exposes the complete command. Restrict access to the log directory and configure logrotation to match the required retention period. Rolling back to a release before this feature removes both records without changing scan behavior.

Execution

python agent -d

Help

$ ./agent.py --help
usage: agent.py [-h] (-o | -d | -s) [-island ISLAND] [-agentkey AGENTKEY] [-ipext IPEXT]
                [-scanhours SCANHOURS] [-scanparallel SCANPARALLEL]
                [-logrotation LOGROTATION] [-v]

Plum Discovery Agent

options:
  -h, --help          show this help message and exit
  -o, --once          Run Once
  -d, --daemon        Run Endlessly
  -s, --setup         Setup configuration only
  -island ISLAND      Hostname or IP of the Plum Island controller
  -agentkey AGENTKEY  Agent Key
  -ipext IPEXT        Force External IP
  -scanhours SCANHOURS
                      GMT scan window in HH-HH format, example 14-16
  -scanparallel SCANPARALLEL
                      Default parallel jobs per scanner, default 1
  --nmap-scanparallel NMAP_SCANPARALLEL
                      Maximum simultaneous Nmap jobs; overrides scanparallel
  --masscan-scanparallel MASSCAN_SCANPARALLEL
                      Maximum simultaneous Masscan jobs; overrides scanparallel
  -logrotation LOGROTATION
                      Daily log retention in days, default 30
  -v, --verbose       -v: scanner output, -vv: full debug (overrides config)

Masscan host reports carry "engine": "masscan" through nmap2json 2611.4. Nmap output is unchanged. Island searches engine:masscan / engine:nmap; unmarked reports default to Nmap, without migrating or rewriting history. Engine provenance does not change deduplication hashes.

Nmap is deliberately not marked because it is the historical default: explicitly marking it would require a backfill and redundant index memberships for millions of existing reports. Island searches Nmap as candidate UIDs minus marked Masscan UIDs, with no engine migration or history rewrite. Historical Masscan reports without a marker are also considered Nmap by this rule.

About

Scanning Agent running with Plum-Island

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages