Zero-dependency local reverse proxy for managing services on dynamic ports
Project description
LocalPortManager ๐
A lightweight, zero-dependency local reverse proxy for managing multiple services on dynamic ports. Perfect for development environments, penetration testing frameworks, and microservice development.
โจ Features
- ๐ Zero External Dependencies - Uses only Python standard library (3.8+)
- ๐ Dynamic Port Allocation - Automatically finds available ports (4000-4999)
- ๐ Service Registry - Persistent JSON-based service mappings
- ๐ HTTP Reverse Proxy - Route requests by hostname
- ๐ Thread-Safe - Concurrent request handling
- โก Lightweight - Single file, minimal overhead
๐ Requirements
- Python 3.8 or higher
*.localhostDNS resolution (default on most systems including Kali Linux)
๐ Quick Start
1. Start the Proxy Server
python localportmanager.py proxy
The proxy starts on http://127.0.0.1:1355 by default.
2. Register a Service
# Register a simple HTTP server
python localportmanager.py register myapp "python -m http.server {port}"
# Register a custom application
python localportmanager.py register api "uvicorn main:app --port {port}"
3. Access Your Service
Once registered, access your service through the proxy:
http://myapp.localhost:1355
๐ Usage
Commands
| Command | Description |
|---|---|
proxy |
Start the reverse proxy server |
register <name> <command> |
Register a new service |
unregister <name> |
Remove a service from registry |
list |
List all registered services |
status |
Show proxy status and services |
Options
# Start proxy on custom port
python localportmanager.py --port 8080 proxy
# Use custom state file
python localportmanager.py --state-file /path/to/registry.json proxy
# Auto-start service without prompting
python localportmanager.py register myapp "cmd" --yes
๐ง Examples
Web Development
# Register multiple frontend applications
python localportmanager.py register frontend-react "npm run dev -- --port {port}"
python localportmanager.py register frontend-vue "npm run serve -- --port {port}"
python localportmanager.py register api "python -m uvicorn api:app --port {port}"
Access via:
http://frontend-react.localhost:1355http://frontend-vue.localhost:1355http://api.localhost:1355
Penetration Testing (Zen-AI-Pentest)
# Register various listeners
python localportmanager.py register listener-01 "nc -lvp {port}"
python localportmanager.py register payload-server "python -m http.server {port}"
python localportmanager.py register api-server "python api.py {port}"
Docker Integration
# Register Docker container ports
python localportmanager.py register grafana "docker run -p {port}:3000 grafana/grafana"
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Client โโโโโโถโ LocalPortManager โโโโโโถโ Backend Service โ
โ โ โ Proxy (127.0.0.1:1355) โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ Registry โ โ Dynamic โ
โ (JSON) โ โ Port (4000+)โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
๐ Service Routing
LocalPortManager routes requests based on the Host header:
| Host Header | Routes To |
|---|---|
myapp.localhost:1355 |
Service "myapp" |
myapp |
Service "myapp" |
127.0.0.1:1355/myapp/... |
Service "myapp" (path-based fallback) |
๐ Project Structure
.
โโโ localportmanager.py # Main application (single file)
โโโ README.md # This file
โโโ LICENSE # MIT License
โโโ examples/ # Usage examples
๐ ๏ธ Development
Running Tests
# Test the module
python -c "import localportmanager; print('OK')"
# Test with verbose output
python localportmanager.py --version
Code Structure
PortRegistry- Manages service/port mappingsReverseProxyHandler- HTTP request handlerLocalPortManager- Main application class
โ ๏ธ Security Notes
- Proxy only binds to
127.0.0.1(localhost) - No authentication by design (local development tool)
- State file stored in
/tmpby default (cleared on reboot) - For production use, consider adding authentication layer
๐ค Integration with Zen-AI-Pentest
LocalPortManager is designed to work seamlessly with Zen-AI-Pentest:
# Inside Zen-AI-Pentest agent
from localportmanager import LocalPortManager
lpm = LocalPortManager(proxy_port=1355)
port = lpm.register_service("exploit-listener", "nc -lvp {port}")
print(f"Listener accessible at: http://exploit-listener.localhost:1355")
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Inspired by the need for simple service management in penetration testing
- Built for the Zen-AI-Pentest framework
- Zero-dependency philosophy for maximum portability
๐ Support
- Issues: GitHub Issues
- Author: @SHAdd0WTAka
Made with โค๏ธ for the cybersecurity community
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 localportmanager-1.0.3.tar.gz.
File metadata
- Download URL: localportmanager-1.0.3.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14424890a64408f50630349b3badb1b4e0462e20dc44b513c3be87391203caa9
|
|
| MD5 |
0596d221cff48283979ce7660982cd09
|
|
| BLAKE2b-256 |
111731de6e56858c69113d09531ac948c39971cc8c81575d883c92f7dc0504fd
|
File details
Details for the file localportmanager-1.0.3-py3-none-any.whl.
File metadata
- Download URL: localportmanager-1.0.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ef42af47a5e357331ae1522aca22946e2f4e8b5112af00c54a6faa2e20293d7
|
|
| MD5 |
126acb8cda0f1ca29133d259525fa743
|
|
| BLAKE2b-256 |
03f4bbd6502f846e4f2768035606e5dc85206c547f538baa6d39af635f71716e
|