Skip to main content

LAN device discovery and TCP port scanning.

Project description

philiprehberger-net-scanner

Tests PyPI version Last updated

LAN device discovery and TCP port scanning.

Installation

pip install philiprehberger-net-scanner

Usage

Network Discovery

from philiprehberger_net_scanner import scan_network

devices = scan_network("192.168.1.0/24", timeout=2.0)
for device in devices:
    print(f"{device.ip} - {device.hostname or 'unknown'} ({device.response_time_ms:.1f}ms)")

Port Scanning

from philiprehberger_net_scanner import scan_ports

# Scan common ports
ports = scan_ports("192.168.1.1", ports="common")
for port in ports:
    print(f"Port {port.number}: {port.state} ({port.service})")

# Scan specific range
ports = scan_ports("192.168.1.1", ports=range(1, 1024), timeout=0.5)

# Scan specific ports
ports = scan_ports("192.168.1.1", ports=[22, 80, 443, 3306, 5432])

Single port check

from philiprehberger_net_scanner import is_port_open

if is_port_open("example.com", 443, timeout=1.0):
    print("HTTPS is reachable")

Async Port Scanning

import asyncio
from philiprehberger_net_scanner import async_scan_ports

ports = asyncio.run(async_scan_ports("192.168.1.1", ports=range(1, 65536), timeout=0.5))

API

Function / Class Description
scan_network(cidr, timeout=1.0, max_workers=64, resolve_hostnames=True) Discover devices on a network using TCP connect probes
scan_ports(host, ports="common", timeout=1.0, max_workers=128) Scan TCP ports on a host ("common", range, or list[int])
async_scan_ports(host, ports="common", timeout=1.0, concurrency=128) Asyncio-based version of scan_ports
is_port_open(host, port, timeout=1.0) One-off boolean check for a single TCP port
Device Discovered host: ip, hostname, mac, response_time_ms
PortResult Scan result: number, state ("open"/"closed"/"filtered"), service

Development

pip install -e .
python -m pytest tests/ -v

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_net_scanner-0.2.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_net_scanner-0.2.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_net_scanner-0.2.0.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_net_scanner-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c732012733e7b9fa902efad5ead7cd8bcefb9de41a75d248df871cf67e6cc8f1
MD5 ac0c2270cab0f068e92e2f1b8365ec16
BLAKE2b-256 a17eab4462efb310073376ae3ac5381f2e1fd862c25c06031a374eab52899ef5

See more details on using hashes here.

File details

Details for the file philiprehberger_net_scanner-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_net_scanner-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 881a6a2e88d0dcb7caa4856c57e704f03d9ed140b90fca8f5e13cbd20f564d64
MD5 8e9881218753cb5cc3c609a2e9bb1557
BLAKE2b-256 0ad6a817d0a38c48675fa161e2839aed9d2c4eb8e8017ffa314e09ef801d013f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page