A netcat-style TCP connect sweep in a single, dependency-free Python file.
Project description
tcpsweep
A netcat-style TCP connect sweep in a single, dependency-free Python file.
tcpsweep sends the same probe as nc -z (a full TCP connect) to every
host/port in a target spec and reports which ports are open. It uses the
standard library only, so it can be dropped onto any box with a Python 3
interpreter and run directly (./tcpsweep.py ...) or as a module
(python3 -m tcpsweep ...).
Discovered open ports stream to stdout (one IP PORT line each) so the
tool composes in a pipeline; progress and the summary go to stderr.
Results are also written to NAME.json and NAME.gnmap plus a resumable
NAME.state.json — all written atomically and owner-readable only (0600),
since a scan result is sensitive reconnaissance data.
Authorized use only. Only scan hosts and networks you own or have explicit permission to test.
Install
pipx install tcpsweep # isolated, recommended for a CLI tool
pip install tcpsweep # or a plain pip install
Both provide a tcpsweep command on your PATH. The tool has no third-party
dependencies, so you can also just copy tcpsweep.py onto a host and run it.
Requirements
- Python 3.8+ (standard library only — no third-party packages)
Usage
tcpsweep 192.168.1.1 22 80 443
tcpsweep 192.168.1.0/24 -p 22,80,443 -t 16
tcpsweep 10.0.0.{1-10,254} -p 1-1024 -r -o office
tcpsweep 192.168.1.1 -p 1-65535 -w 2 -P 0.2 # rate-limited, 0.2s gap
tcpsweep 10.0.0.0/24 -p 22 -b # grab banners
Run tcpsweep --help for the full option list, including target selection
(CIDR / dash ranges / brace notation / -iL target files / --exclude),
threading, rate limiting, link-health auto-pause, and the various output
formats (-oJ / -oX / -oT / -oC / -oA).
Output files
By default the scanner writes working files named after the target (or the
-o NAME base):
| File | Contents |
|---|---|
NAME.json |
Full structured results |
NAME.gnmap |
Greppable, nmap-style summary |
NAME.state.json |
Resume state for an interrupted scan |
These files hold reconnaissance data and are excluded from version control via
.gitignore.
Development
Run the test suite with:
python3 -m pytest test_scan.py -q # or: python3 -m unittest test_scan
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 tcpsweep-0.1.0.tar.gz.
File metadata
- Download URL: tcpsweep-0.1.0.tar.gz
- Upload date:
- Size: 32.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5a4a21a62ed5deb15e1b59b20229028472a27c2bbb69ec3d815410b120d791b
|
|
| MD5 |
0830dba9bd8199faf16a914549dc23a9
|
|
| BLAKE2b-256 |
d91ce72febd07c4a2745c303b3796fec1cb3748df86b0bec8eae4bd2411a7cb7
|
Provenance
The following attestation bundles were made for tcpsweep-0.1.0.tar.gz:
Publisher:
release.yml on BearlyStable/scanner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tcpsweep-0.1.0.tar.gz -
Subject digest:
e5a4a21a62ed5deb15e1b59b20229028472a27c2bbb69ec3d815410b120d791b - Sigstore transparency entry: 2269316554
- Sigstore integration time:
-
Permalink:
BearlyStable/scanner@f53e5801fab04b9c0edc48e5d923b7086eeed898 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/BearlyStable
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f53e5801fab04b9c0edc48e5d923b7086eeed898 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tcpsweep-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tcpsweep-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fe47b425bc71583e82fc5d066742fcd91f930aa6dc9a4deaf8ea8550c99a4a5
|
|
| MD5 |
79af210c0b9b7ffd16627690f7b5b104
|
|
| BLAKE2b-256 |
04bc05f3ba3b01e1d721c0f3f9308c7cc13be0147d5f0479efa16003245ca8ee
|
Provenance
The following attestation bundles were made for tcpsweep-0.1.0-py3-none-any.whl:
Publisher:
release.yml on BearlyStable/scanner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tcpsweep-0.1.0-py3-none-any.whl -
Subject digest:
6fe47b425bc71583e82fc5d066742fcd91f930aa6dc9a4deaf8ea8550c99a4a5 - Sigstore transparency entry: 2269316728
- Sigstore integration time:
-
Permalink:
BearlyStable/scanner@f53e5801fab04b9c0edc48e5d923b7086eeed898 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/BearlyStable
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f53e5801fab04b9c0edc48e5d923b7086eeed898 -
Trigger Event:
push
-
Statement type: