Metadata-Version: 2.4
Name: PortMiner
Version: 0.2.2
Summary: A simple and Lite URL port scanner built with pure Python
Home-page: https://pypi.org/project/PortMiner/
Author: Mobin Salehi
Author-email: salehimobin343@gmail.com
License: GPL-3.0-or-later
Project-URL: GitHub, https://github.com/MobinSalehiP/Port-Miner
Project-URL: PyPI, https://pypi.org/project/PortMiner/
Keywords: port scanner,network,security,latency,portminer,port,url,ports
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Networking
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-python
Dynamic: summary

# Port Miner ⛏️

[![PyPI version](https://img.shields.io/pypi/v/portminer.svg)](https://pypi.org/project/PortMiner/)
[![Python Version](https://img.shields.io/pypi/pyversions/portminer.svg)](https://pypi.org/project/PortMiner/)
[![License: GPL-3.0-or-later](https://img.shields.io/badge/License-GPL--3.0--or--later-blue.svg)](LICENSE)
[![Downloads](https://img.shields.io/pypi/dm/portminer.svg)](https://pypi.org/project/PortMiner/)
[![Total Downloads](https://static.pepy.tech/personalized-badge/portminer?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/portminer)
[![Status](https://img.shields.io/badge/status-active-brightgreen.svg)](https://github.com/MobinSalehiP/Port-Miner)

**Port Miner** is a lightweight TCP port scanner built with pure Python. It allows users to scan common network ports or specify a custom port range for authorized network testing.

With a simple interactive interface, concurrent port checks, and connection-time measurements, Port Miner provides a straightforward way to explore network services.

## ✨ Features

- ⚡ **Lightweight:** Simple design with minimal overhead.
- 🐍 **Pure Python:** Uses Python's standard library without third-party runtime dependencies.
- 🌐 **URL and IP Support:** Accepts a hostname, URL, or IPv4 address.
- 🔎 **Default Port Scan:** Scans 38 predefined common ports.
- 🎯 **Custom Port Range:** Specify a starting port and an ending port to scan any valid TCP port range from `1` to `65535`.
- 🧵 **Concurrent Scanning:** Uses `ThreadPoolExecutor` to check multiple ports concurrently.
- ⏱️ **Connection Timing:** Displays the connection time in milliseconds for reachable ports.
- 📋 **Service Labels:** Shows known service names for predefined ports and labels other ports as `Unknown/Custom`.
- 📦 **No Runtime Dependencies:** Uses Python's built-in networking and concurrency modules.
- 💻 **Cross-Platform:** Designed for Windows, Linux, and macOS.
- 🚀 **PyPI Distribution:** Installable using `pip`.

## 🛠 Requirements

- Python 3.7 or newer, subject to compatibility with the Python version used.
- A network connection to reach the target.
- Authorization to scan the target system.

No additional runtime packages are required.

## 📦 Installation

Install Port Miner from PyPI:

```bash
pip install PortMiner
```

Verify the installation:

```bash
pip show PortMiner
```

## 🚀 Usage

Import `scan_ports` and call the function:

```python
from PortMiner import scan_ports

scan_ports()
```

The program will prompt you to enter a target URL or IP address and select a scanning mode.

### 🔎 1. Default Port Scan

Choose the default mode to scan the 38 predefined ports included in Port Miner.

Example:

```text
🎅 Enter target URL or IP: example.com

Select scan mode:
1. Default Scan (38 common ports)
2. Custom Range Scan

Enter your choice (1/2): 1
```

The scanner checks the ports listed in `COMMON_PORTS` and reports detected open ports.

### 🎯 2. Custom Port Range Scan

Use Custom Range Scan when you want to inspect a specific range of TCP ports rather than only the predefined ports.

For example, to scan ports `80` through `100`:

```text
🎅 Enter target URL or IP: example.com

Select scan mode:
1. Default Scan (38 common ports)
2. Custom Range Scan

Enter your choice (1/2): 2
Enter start port (1-65535): 80
Enter end port (1-65535): 100
```

Port Miner will scan every port in the selected range, including both endpoints.

**Custom range examples:**

| Start port | End port | Number of ports |
|---:|---:|---:|
| 80 | 100 | 21 |
| 1 | 1024 | 1024 |
| 8000 | 8100 | 101 |
| 3000 | 3010 | 11 |

Valid port numbers range from `1` to `65535`. The starting port must not exceed the ending port.

Large ranges may take longer to scan, depending on network conditions, timeouts, and the number of concurrent workers.

### 🧩 Using a Custom Function Argument

You can also provide the target directly:

```python
from PortMiner import scan_ports

scan_ports("example.com")
```

The scanner will still prompt you to select the scan mode.

To access the predefined port dictionary:

```python
from PortMiner import COMMON_PORTS

print(COMMON_PORTS)
```

## ⚙️ How It Works

Port Miner uses Python's built-in networking features to test TCP connections to a target host.

- **`socket`:** Creates TCP sockets and checks whether connections can be established.
- **`socket.gethostbyname()`:** Resolves a hostname to an IPv4 address.
- **`urllib.parse`:** Extracts the hostname from URL input.
- **`time.perf_counter()`:** Measures connection-attempt duration.
- **`ThreadPoolExecutor`:** Executes multiple port checks concurrently.

A port is reported as open when the TCP connection succeeds. Firewalls, network filtering, timeouts, and server configuration can affect the results.

The reported connection time is not necessarily the same as the target's general network latency or application response time.

## 📋 Output

For detected open ports, the scanner displays information similar to this example:

```text
PortMiner Scanner
Target   : example.com (93.184.216.34)
Scanning : 21 ports

[✔] Port 80    (HTTP) OPEN | Latency: 35.21 ms

Scan complete. Found 1 open port(s).
```

This is an illustrative example, not a report of the target's actual port status.

## 🌍 Supported Platforms

Port Miner is designed for:

- Windows
- Linux
- macOS

Actual results may vary depending on the local environment and network configuration.

## 🔐 Responsible Use

Port Miner is intended for educational purposes, network diagnostics, and authorized security testing.

**Only scan systems and networks that you own or have explicit permission to test.**

An open port does not automatically indicate a security vulnerability. Port Miner performs basic TCP connectivity checks and is not a comprehensive vulnerability scanner.

## 📄 License

Port Miner is distributed under the **GNU General Public License v3.0 or later (GPL-3.0-or-later)**.

You may use, study, modify, and redistribute the software under the applicable license terms.

See the [LICENSE](LICENSE) file for the complete license text.

Official license information: [GNU GPL v3.0](https://www.gnu.org/licenses/gpl-3.0.html).

## 🔗 Links

- **PyPI:** https://pypi.org/project/PortMiner/
- **GitHub:** https://github.com/MobinSalehiP/Port-Miner
- **License:** [LICENSE](LICENSE)

## 👨‍💻 Author

**Mobin Salehi**

For bug reports, feature requests, or suggestions, open an issue on GitHub.

Email: salehimobin343@gmail.com

---

*Port Miner: Simple tools for exploring TCP ports with Python.*
