Lab-oriented nmap orchestration with classification, reporting, and runtime logs.
Project description
MangScan
MangScan is a lab-oriented port enumeration tool that wraps a two-phase nmap workflow, classifies discovered services, and generates technical reports in JSON and Markdown.
The project is organized as a Python package under src/mangscan, while main.py remains at the repository root as a compatibility entrypoint for local execution.
The repository is also prepared for packaging and release automation through pyproject.toml and GitHub Actions.
Overview
MangScan receives a single target from the command line, performs a full TCP port sweep to identify open ports, and then runs a second, more detailed collection only against those open ports. From the XML generated by nmap, the tool:
- extracts IP, hostname, host status, and exposed services
- identifies versions and basic output from default
nmapscripts - classifies each port into operational categories
- assigns a heuristic priority to findings
- generates simple host profile hypotheses
- exports a structured report for later review
Current Behavior
- CLI input with a single required argument:
target - Phase 1 discovery using
-Pn -p- --open -T3 - Phase 2 service enumeration using
-Pn -sV -sC -T3only on open ports found in phase 1 - XML parsing from
nmapoutput into Python objects - Heuristic classification by category:
webremote_accessdatabasenetwork_sharingother
- Automatic artifact generation in
output/:- phase 1 XML
- phase 2 XML
- final
JSONreport - final
Markdownreport
Project Structure
MangScan/
main.py
README.md
requirements.txt
src/
mangscan/
__init__.py
__main__.py
cli.py
config.py
core/
models.py
orchestrator.py
services/
classifier.py
parser.py
reporter.py
scanner.py
utils/
filesystem.py
Module Responsibilities
main.py- compatibility entrypoint for
python main.py <target> - injects
src/intosys.pathfor local execution
- compatibility entrypoint for
src/mangscan/cli.py- CLI parser and terminal output
src/mangscan/config.py- centralized
nmaparguments, output directory, and classification rules
- centralized
src/mangscan/core/models.py- core dataclasses for findings, artifacts, and final result
src/mangscan/core/orchestrator.py- end-to-end execution flow and artifact coordination
src/mangscan/services/scanner.pypython-nmapintegration and XML persistence
src/mangscan/services/parser.py- XML parsing into internal models
src/mangscan/services/classifier.py- heuristic categorization, prioritization, and host hypotheses
src/mangscan/services/reporter.py- JSON and Markdown report generation
src/mangscan/utils/filesystem.py- directory creation, timestamping, and port list serialization
Requirements
To run MangScan you need:
- Python 3.10+ recommended
nmapinstalled on the system and available inPATH- permission to scan only authorized environments
Current Python dependency:
python-nmap
Installation
1. Clone the repository
git clone <REPOSITORY_URL>
cd MangScan
2. Create and activate a virtual environment
Windows PowerShell:
python -m venv .venv
.venv\Scripts\Activate.ps1
Linux/macOS:
python3 -m venv .venv
source .venv/bin/activate
3. Install Python dependencies
pip install -r requirements.txt
4. Install Nmap on the system
MangScan depends on the actual nmap binary. Installing only python-nmap is not enough.
Verify that the command is available:
nmap --version
Usage
Basic execution:
python main.py 192.168.0.10
Execution with more verbose runtime logs:
python main.py 192.168.0.10 --log-level DEBUG
You can also run the package directly if src/ is on PYTHONPATH:
python -m mangscan 192.168.0.10
After installing the package, you can also use the console command:
mangscan 192.168.0.10
You can also use a hostname:
python main.py lab-host.local
At the end of execution, the CLI prints a short summary with:
- provided target
- identified IP
- open ports list
- total number of open ports
During execution, MangScan now also emits progress logs to the terminal and writes a per-run log file under output/logs/.
Generated Output
All artifacts are saved in output/, with names based on timestamp and target.
Examples of generated files:
output/
20260404_103000_192.168.0.10_phase1.xml
20260404_103000_192.168.0.10_phase2.xml
20260404_103000_192.168.0.10_report.json
20260404_103000_192.168.0.10_report.md
logs/
20260404_103000_192.168.0.10.log
The log file records the run lifecycle in more detail, including:
- scan start and end for each phase
- effective
nmaparguments - XML parsing milestones
- classification summary
- report generation paths
- exception stack traces on failure
Execution Flow
- The user provides an authorized host or IP address.
- The orchestrator creates a timestamp-based
run_id. - The tool runs Phase 1 to discover open TCP ports.
- The Phase 1 XML is parsed to build the list of open ports.
- If no open ports are found, execution ends with a minimal report.
- If open ports exist, the tool runs Phase 2 only against those ports.
- The detailed result is classified and enriched with hypotheses.
- The final report is written to disk in two formats.
Heuristic Classification
Service classification uses two strategies:
- Direct mapping based on known ports
- Inference based on the service name returned by
nmap
Currently mapped categories:
webremote_accessdatabasenetwork_sharingother
This classification is intentionally simple. It helps organize triage, but it does not replace manual technical analysis.
Limitations
- only one target per execution
- no automated tests yet
- no advanced CLI arguments or external configuration files
- heuristic classification, not validated real-world risk
- no UDP scanning, subnet scanning, or controlled parallelism
- no detailed logging or retry policy
- full dependency on a locally installed
nmap
Suggested Roadmap
- add tests for parser, classifier, and reporter
- add CLI flags for scan intensity, ports, output, and formats
- support multiple targets and CIDR ranges
- create an external configuration layer via
.envoryaml - add structured logging
- add
HTMLandCSVexport - implement historical comparison between executions
Packaging
MangScan is configured as a distributable Python package with a src/ layout and a console entrypoint named mangscan.
Local build commands:
python -m pip install --upgrade build
python -m build
Generated artifacts will be written to:
dist/
mangscan-0.1.0.tar.gz
mangscan-0.1.0-py3-none-any.whl
Local editable install:
pip install -e .
GitHub Release And PyPI Publishing
The repository includes a release workflow at .github/workflows/release.yml.
Release flow:
- Update
versioninpyproject.tomland__version__insrc/mangscan/__init__.py. - Commit the version bump.
- Create and push a tag matching the version, for example:
git tag v0.1.0
git push origin v0.1.0
When a tag matching v* is pushed, GitHub Actions will:
- validate that the tag matches the package version
- build the source distribution and wheel
- create a GitHub Release with generated notes
- attach the built artifacts to the release
- publish the package to PyPI
PyPI Setup Required Once
Before the automated publishing works, configure the project on PyPI as a Trusted Publisher for this repository.
Recommended values for the PyPI Trusted Publisher form:
- owner:
0xs3n4 - repository:
MangScan - workflow filename:
release.yml
If the project does not exist yet on PyPI, create it there first or use PyPI's pending publisher flow.
Ethical and Legal Use
MangScan should only be used:
- in your own labs
- against authorized assets
- in controlled research, defensive, or educational environments
Do not use this tool against third-party assets without explicit authorization. The user is fully responsible for how the tool is used and for any legal or ethical consequences resulting from that use.
License
- GPL-3.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mangscan-0.1.0.tar.gz.
File metadata
- Download URL: mangscan-0.1.0.tar.gz
- Upload date:
- Size: 52.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
260e4b30309c096d7b83a0c40bdde0e3e551c0df104a4b2feb95549e8b8c696c
|
|
| MD5 |
268839583dccd43c4a7e46c6c70edf22
|
|
| BLAKE2b-256 |
949623def259affbfef53678f15d423f8b72f64ae588d8f52ad81774c4f86103
|
Provenance
The following attestation bundles were made for mangscan-0.1.0.tar.gz:
Publisher:
release.yml on 0xs3n4/MangScan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mangscan-0.1.0.tar.gz -
Subject digest:
260e4b30309c096d7b83a0c40bdde0e3e551c0df104a4b2feb95549e8b8c696c - Sigstore transparency entry: 1235162418
- Sigstore integration time:
-
Permalink:
0xs3n4/MangScan@2679e96ecb99a50de8b181454ffe0d69df1a5535 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/0xs3n4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2679e96ecb99a50de8b181454ffe0d69df1a5535 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mangscan-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mangscan-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
986c212a873c5e15234e1eae74d95ce6b8282bb4cc53dc33e41074574a83ed9c
|
|
| MD5 |
67121703022f2523927eaa123566d1d1
|
|
| BLAKE2b-256 |
e9d8c81708800c5709674d70f9fd89c308608ac182f6a9bbe8e8568366c60cee
|
Provenance
The following attestation bundles were made for mangscan-0.1.0-py3-none-any.whl:
Publisher:
release.yml on 0xs3n4/MangScan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mangscan-0.1.0-py3-none-any.whl -
Subject digest:
986c212a873c5e15234e1eae74d95ce6b8282bb4cc53dc33e41074574a83ed9c - Sigstore transparency entry: 1235162497
- Sigstore integration time:
-
Permalink:
0xs3n4/MangScan@2679e96ecb99a50de8b181454ffe0d69df1a5535 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/0xs3n4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2679e96ecb99a50de8b181454ffe0d69df1a5535 -
Trigger Event:
push
-
Statement type: