Implementation:0xSteph Pentest ai Target Expander
| 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
- Repository: 0xSteph_Pentest_ai
- File: engine/target_expander.py
- Lines: 1-81
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")