Skip to main content
Glama
SlanyCukr

Bug Bounty MCP Server

by SlanyCukr

masscan_high_speed

Perform high-speed port scanning on target networks to identify open ports and services for security assessments and vulnerability discovery.

Instructions

Execute Masscan for high-speed port scanning.

Args: target: Target IP address or CIDR range ports: Port range to scan rate: Packet transmission rate banners: Enable banner grabbing exclude_file: File containing IPs to exclude include_file: File containing IPs to include output_format: Output format (list, xml, json) additional_args: Additional Masscan arguments

Returns: High-speed scan results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
additional_argsNo
bannersNo
exclude_fileNo
include_fileNo
output_formatNolist
portsNo1-65535
rateNo
targetYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler and registration for 'masscan_high_speed'. Proxies parameters to REST API endpoint '/api/masscan' for execution.
    def masscan_high_speed(
        target: str,
        ports: str = "1-65535",
        rate: int = 1000,
        banners: bool = False,
        exclude_file: str = "",
        include_file: str = "",
        output_format: str = "list",
        additional_args: str = "",
    ) -> dict[str, Any]:
        """Execute Masscan for high-speed port scanning.
    
        Args:
            target: Target IP address or CIDR range
            ports: Port range to scan
            rate: Packet transmission rate
            banners: Enable banner grabbing
            exclude_file: File containing IPs to exclude
            include_file: File containing IPs to include
            output_format: Output format (list, xml, json)
            additional_args: Additional Masscan arguments
    
        Returns:
            High-speed scan results
        """
        data = {
            "target": target,
            "ports": ports,
            "rate": rate,
            "banners": banners,
            "exclude_file": exclude_file,
            "include_file": include_file,
            "output_format": output_format,
            "additional_args": additional_args,
        }
    
        logger.info(f"🚀 Starting Masscan high-speed scan on {target}")
        result = api_client.safe_post("api/masscan", data)
    
        if result.get("success"):
            logger.info(f"✅ Masscan completed on {target}")
        else:
            logger.error("❌ Masscan failed")
    
        return result
  • Core REST API handler for masscan execution, called by MCP tool. Builds command, executes masscan, parses JSON output into findings.
    @tool(required_fields=["target"])
    def execute_masscan():
        """Execute Masscan and return structured port findings."""
        data = request.get_json()
        params = extract_masscan_params(data)
    
        logger.info("Executing Masscan on %s", params["target"])
    
        started_at = datetime.now()
        command = build_masscan_command(params)
        execution_result = execute_command(command, timeout=600)
        ended_at = datetime.now()
    
        return parse_masscan_output(execution_result, params, command, started_at, ended_at)
  • Helper function to safely construct the masscan command line from parameters.
    def build_masscan_command(params: dict[str, Any]) -> str:
        """Build a masscan command string with safe shell escaping."""
        cmd_parts: list[str] = ["masscan"]
    
        if params.get("ports"):
            cmd_parts.extend(["-p", params["ports"]])
    
        cmd_parts.extend(["--rate", str(params["rate"])])
    
        if params.get("banners"):
            cmd_parts.append("--banners")
    
        if params.get("interface"):
            cmd_parts.extend(["-e", params["interface"]])
    
        if params.get("router_mac"):
            cmd_parts.extend(["--router-mac", params["router_mac"]])
    
        if params.get("source_ip"):
            cmd_parts.extend(["--source-ip", params["source_ip"]])
    
        if params.get("exclude_file"):
            cmd_parts.extend(["--excludefile", params["exclude_file"]])
    
        if params.get("include_file"):
            cmd_parts.extend(["--includefile", params["include_file"]])
    
        additional_parts = (
            shlex.split(params["additional_args"]) if params.get("additional_args") else []
        )
    
        has_output_directive = any(
            part.startswith("-o") or part.startswith("--output")
            for part in additional_parts
        )
    
        if not has_output_directive:
            cmd_parts.extend(["-oJ", "-"])
    
        cmd_parts.extend(additional_parts)
    
        target = params.get("target")
        if target:
            for item in target.split():
                cmd_parts.append(item)
    
        return " ".join(shlex.quote(part) for part in cmd_parts)
  • Helper function to parse masscan execution output, handle errors, and structure findings with deduplication.
    def parse_masscan_output(
        execution_result: dict[str, Any],
        params: dict[str, Any],
        command: str,
        started_at: datetime,
        ended_at: datetime,
    ) -> dict[str, Any]:
        """Parse masscan JSON output into structured findings."""
        duration_ms = int((ended_at - started_at).total_seconds() * 1000)
    
        if not execution_result["success"]:
            error_message = (
                execution_result.get("stderr")
                or execution_result.get("error")
                or "Masscan execution failed"
            )
            error_response, status_code = create_error_response(
                error_message,
                stage="exec",
                details={
                    "return_code": execution_result.get("return_code"),
                    "command": execution_result.get("command", command),
                },
                status_code=500,
            )
            return {
                "success": False,
                "tool": "masscan",
                "params": params,
                "command": command,
                "started_at": started_at.isoformat(),
                "ended_at": ended_at.isoformat(),
                "duration_ms": duration_ms,
                "error": error_response,
                "findings": [],
                "stats": {"findings": 0, "dupes": 0, "payload_bytes": 0},
            }
    
        stdout = execution_result.get("stdout", "")
        try:
            findings, duplicates = _parse_masscan_findings(stdout)
        except MasscanParseError as exc:
            error_response, status_code = create_error_response(
                str(exc),
                stage="parse",
                details={
                    "command": execution_result.get("command", command),
                    "output_sample": stdout[:500],
                },
                status_code=500,
            )
            return {
                "success": False,
                "tool": "masscan",
                "params": params,
                "command": command,
                "started_at": started_at.isoformat(),
                "ended_at": ended_at.isoformat(),
                "duration_ms": duration_ms,
                "error": error_response,
                "findings": [],
                "stats": {"findings": 0, "dupes": 0, "payload_bytes": 0},
            }
    
        payload_bytes = len(stdout.encode("utf-8"))
        stats = create_stats(len(findings), duplicates, payload_bytes)
    
        return {
            "success": True,
            "tool": "masscan",
            "params": params,
            "command": command,
            "started_at": started_at.isoformat(),
            "ended_at": ended_at.isoformat(),
            "duration_ms": duration_ms,
            "findings": findings,
            "stats": stats,
        }
  • Helper to extract and validate/default masscan parameters from JSON request.
    def extract_masscan_params(data: dict[str, Any]) -> dict[str, Any]:
        """Extract parameters for masscan execution."""
        return {
            "target": data["target"],
            "ports": data.get("ports", "1-65535"),
            "rate": int(data.get("rate", 1000)),
            "banners": bool(data.get("banners", False)),
            "interface": data.get("interface"),
            "router_mac": data.get("router_mac"),
            "source_ip": data.get("source_ip"),
            "exclude_file": data.get("exclude_file"),
            "include_file": data.get("include_file"),
            "additional_args": data.get("additional_args", ""),
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'high-speed port scanning' and 'banner grabbing,' which hints at network activity, but fails to disclose critical traits such as potential network impact, permission requirements, rate limits, or safety considerations. The description is minimal and doesn't add meaningful context beyond the basic operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections for 'Args' and 'Returns,' making it easy to parse. It's front-loaded with the core purpose, and each sentence serves to document parameters or outputs without unnecessary fluff. However, the parameter explanations are very brief, bordering on under-specification in some cases.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of an 8-parameter tool with no annotations and 0% schema description coverage, the description is moderately complete. It covers all parameters and mentions the output, and an output schema exists, so return values don't need explanation. However, it lacks behavioral context and usage guidelines, leaving gaps for a tool that performs network scanning.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description lists all 8 parameters with brief explanations (e.g., 'Target IP address or CIDR range'), but the input schema has 0% description coverage, meaning parameters are undocumented in the schema. The description compensates by providing basic semantics for each parameter, though it lacks detailed format specifications or examples. This meets the baseline for adding value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Execute Masscan for high-speed port scanning,' which specifies the verb ('execute'), tool ('Masscan'), and key characteristic ('high-speed port scanning'). It distinguishes itself from sibling tools like 'nmap_scan' or 'rustscan_fast_scan' by explicitly mentioning 'Masscan' and 'high-speed,' though it doesn't explicitly contrast with them in the description text.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any specific contexts, prerequisites, or exclusions, nor does it reference sibling tools like 'nmap_scan' or 'rustscan_fast_scan' for comparison. The usage is implied only by the tool's name and description, lacking explicit instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SlanyCukr/bugbounty-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server