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])

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

scan_network(cidr, timeout?, max_workers?, resolve_hostnames?) -> list[Device]

Discover devices on a network using TCP connect probes.

scan_ports(host, ports?, timeout?, max_workers?) -> list[PortResult]

Scan TCP ports on a host. ports can be "common", a range, or a list[int].

async_scan_ports(host, ports?, timeout?, concurrency?) -> list[PortResult]

Async version using asyncio for high-performance scanning.

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.1.9.tar.gz (6.3 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.1.9-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_net_scanner-0.1.9.tar.gz
Algorithm Hash digest
SHA256 23e7aef056a5a898ccecb0fa5e0373665d6878c1acc2857f7f5601f3a1864702
MD5 0da04a113be7abc938ad5d2d0c31df22
BLAKE2b-256 befd3db0ff6b0775a5f7a0e4c8340479d2691bb677ea6301b8127c4ac5db3ea5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_net_scanner-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 7fc0f66b42aa7af97f1fe00c4ae2d10c579633290a176a15fb1ffc6bae14555e
MD5 3749b02e336a6dfab13d23ca0e04a93f
BLAKE2b-256 780a1059bfb8da6f343e0b79aed642dbe410ad6630197cb3da1ff70f19b006a1

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