Skip to content

masscan Executor

Category: Discovery and Reconnaissance Script: masscan.py Integration: CLI Faraday Plugin: Raw JSON Website: robertdavidgraham/masscan

Description

Runs a masscan port scan against the given targets and imports the results into Faraday. Each scanned IP becomes a host, with one service per port that masscan reports. No vulnerabilities are created.

Prerequisites

  • masscan installed and available in the agent's PATH (checked with masscan --version)
  • Privileges to send raw packets (masscan usually runs as root or with the CAP_NET_RAW capability)
  • Network access from the agent to the targets, and authorization to scan them

Configuration

Environment Variables (Setup)

This executor does not require setup environment variables.

Execution Arguments

Parameter Type Mandatory Description
MASSCAN_TARGET string Yes Targets to scan: an IP, a CIDR or a range (e.g., 10.0.0.0/24)
MASSCAN_PORTS string Yes Ports to scan, in masscan syntax (e.g., 22,80,443,8000-8100 or U:53,T:1-1024)
MASSCAN_RATE integer No Transmit rate in packets per second (default: 1000)
MASSCAN_EXCLUDE string No IPs, ranges or CIDRs to skip (e.g., 10.0.0.1,10.0.0.128/25)

YAML Configuration Example

executors:
  masscan:
    repo_executor: masscan.py
    max_size: 65536
    varenvs: {}
    params:
      MASSCAN_TARGET:
        mandatory: true
        type: string
        base: string
      MASSCAN_PORTS:
        mandatory: true
        type: string
        base: string
      MASSCAN_RATE:
        mandatory: false
        type: integer
        base: integer
      MASSCAN_EXCLUDE:
        mandatory: false
        type: string
        base: string

How It Works

  1. Runs masscan -oJ <file> -p <ports> --rate <rate> <targets>, adding --exclude when MASSCAN_EXCLUDE is set
  2. Reads the JSON output file line by line
  3. Creates one host per IP and one service per reported port, with the tcp or udp protocol and the open or closed status
  4. Sends the hosts and services to Faraday

Notes

  • The service name is the port number, because masscan does not identify the service. Run [[executor-nmap]] on the results if you need service detection.
  • Only IPs with at least one reported port are imported. No hostnames and no vulnerabilities are created.
  • High rates can saturate the network or trigger security controls. Increase MASSCAN_RATE only on links that can handle it.
  • The shared agent parameters (AGENT_CONFIG_* tags and severity filters) are not applied by this executor.