Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xSteph Pentest ai Target Expander

From Leeroopedia
Knowledge Sources
Domains Target_Management, CIDR, Expansion
Last Updated 2026-10-23 00:00 GMT

Overview

Concrete tool for expanding target arguments into concrete target lists supporting single hosts, comma-separated, CIDR, and file input, provided by the pentest-ai engine.

Description

The target_expander module expands target strings into lists of individual targets. It supports single targets, comma-separated lists, CIDR notation (excludes network and broadcast addresses), and file input (one target per line with # comments). Capped at 4096 expanded targets to prevent runaway expansion.

Usage

Import this module when you need to parse target arguments from CLI or playbook input. Used by the orchestrator and CLI.

Code Reference

Source Location

Signature

MAX_EXPANDED_TARGETS = 4096

def expand_target(raw: str) -> list[str]: ...
def load_targets_file(path: str | Path) -> list[str]: ...

Import

from engine.target_expander import expand_target, load_targets_file

I/O Contract

Inputs

Name Type Required Description
raw str Yes Single host, comma-separated, or CIDR
path Path Yes (file) Path to targets file

Outputs

Name Type Description
targets list[str] Expanded list of individual targets

Usage Examples

Expand Targets

from engine.target_expander import expand_target

# Single target
print(expand_target("example.com"))  # ["example.com"]

# Comma-separated
print(expand_target("10.0.0.1,10.0.0.2,example.com"))

# CIDR
targets = expand_target("10.0.0.0/24")
print(f"{len(targets)} hosts")  # 254 hosts

# From file
from engine.target_expander import load_targets_file
targets = load_targets_file("targets.txt")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment