Skip to main content

PORTFINDER

Python Version License PyPI Version

Portfinder is a powerful asynchronous port scanner for Python that allows you to quickly scan multiple targets with flexible configuration options.

Navigation

Features

  • Scan multiple IPs, CIDR ranges or domains
  • Custom port ranges support (e.g., 1-1000,3389,8080)
  • Protocol-specific scanning (TCP, UDP, HTTP, HTTPS)
  • High-performance async I/O implementation
  • Multiple output formats (JSON, JSON Lines, plain text)
  • Quiet mode for scripting

Installation as Python Library PyPI

pip install portfinder

run basic scan

portfinder -t example.com

advanced scan

portfinder -t 192.168.1.1,10.0.0.0/24,example.com -p 1-1024,3389,8080 -P http -T 1.5 -c 500 -tps 300 -o scan_results -j
Argument Description
-f, --file Target txt file with IP/CIDR/domain (new-line-separated)
-t, --target Target IP/CIDR/domain (comma-separated)
-p, --ports Ports to scan (default: 80,443,53)
-P, --protocol Protocol to check (tcp, udp, http, https)
-T, --timeout Timeout in seconds (default: 2.0)
-c, --concurrency Maximum concurrent connections per host (default: 1000) no more than ~500-1000 on CPU cores
-o, --outfile Output file path (without extension)
-j, --js Output in JSON format
-jl, --jsl Output in JSON Lines format
-q, --quiet Disable all stdout output
-u, --uvloop_disable Disable async uvloop (move to standart asyncio event loop)

usage with docker

docker run --rm stanley0507/portfinder:latest -t 192.168.1.1 -p 1-1000

usage with input file with docker

docker run -v $(pwd)/results:/data --rm stanley0507/portfinder:latest -f /data/input_data.txt -p 1-9000 -o scan_result_ -jl

input_data.txt example

192.168.1.1
example.com

basic python usage

from portfinder.scanner import Scanner
from portfinder.dto import Protocol, Result

async def run_scan():
    ...
    scanner = Scanner(
        target="0.0.0.0",
        ports="80-23000",
        protocol=Protocol.HTTP,
        timeout=4.0,
        concurrency=700,
    )
    results: list[Result] = await scanner.run()
    ...
  • Result is a active port item (dataclass) with attributes:
    • host: str
    • port: int
    • ip_version: IpVersion
    • protocols: list[Protocol]
  • Protocol enum:
    • HTTP,
    • HTTPS,
    • TCP,
    • UDP

output files format:

  • txt file
0.0.0.0:21 [ipv4] (tcp)
  • json file
[
  {
    "host": "0.0.0.0",
    "port": 21,
    "ip_version": "ipv4",
    "protocols": [
      [
        "tcp"
      ]
    ]
  }
]
  • jsonl file
{"host": "0.0.0.0", "port": 53, "ip_version": "ipv4", "protocols": [["tcp"]]}

powered by lynkey.io

License MIT

Metadata

Release files for portfinder 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for portfinder 0.1.8
File Size Uploaded
portfinder-0.1.8.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for portfinder 0.1.8
File Interpreter ABI Platform
portfinder-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 20.2 kB

Release files / portfinder-0.1.8.tar.gz

Download URL portfinder-0.1.8.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
75503aa64afdd81b0e772ad44d101a29fa0420a174275812f7fbdbe2035b44b1
BLAKE2b-256 checksum
How to use checksums
cf0cdda21c52b941146262b42ee120db7d1d811d4c718a47a72c0047b45f1b5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.13 Darwin/24.3.0

Release files / portfinder-0.1.8-py3-none-any.whl

Download URL portfinder-0.1.8-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9419fe390af6e587c1d5ca52aced70334edc553e3042669522ebfde74745904f
BLAKE2b-256 checksum
How to use checksums
1f274dc339243493e93801994f16fed1fa59a678cdfe7679a68fd61b7444ef47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.13 Darwin/24.3.0

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page