Forge is a TCP tunneling tool written in Rust that allows you to create tunnels between hosts with a TLS-encrypted command channel for secure tunnel management. The actual tunnel traffic is transported over direct TCP connections.
Note: This is an actively developed project. The current implementation includes detailed debug messages which, while verbose, are intentionally left in place to assist with development and troubleshooting during this phase.
- Dynamic Reconfiguration: Ability to modify tunnel endpoints (ports and IP addresses) without restarting
- Live Port Modification: Change local listening ports on the fly
- Target Flexibility: Dynamically update target hosts and ports for existing tunnels
- Secure Command Channel: Control messages are sent over a TLS-encrypted connection
- Interactive Management: Command-line interface for managing tunnels
- Network Routing: Connect to any machine reachable from the client, including internal LAN networks and subnets
- Rust 1.70 or later
- OpenSSL command-line tools (for certificate generation)
-
Clone the repository and navigate to the project directory.
git clone https://github.com/GobiasSomeCoffeeCo/forge.git
-
Run the setup script to generate certificates and build the project:
./build-forge.sh
You will be prompted to enter the server's IP address.
-
Start the server:
./server --addr 0.0.0.0:8443 --key keys/server-key.pem --cert keys/server-cert.pem
-
In a separate terminal or on another machine, start the client:
./client
You can deploy the client to multiple machines in your network. Each client automatically generates a unique ID based on timestamp, making it easy to manage multiple connections:
# Copy the client binary to multiple machines
scp client machine1:/opt/forge/
scp client machine2:/opt/forge/
scp client machine3:/opt/forge/
# Each client will connect with its own unique ID
# On the server you'll see them as different clients:
forge> clients
Connected clients:
client-1706511234
client-1706511245
client-1706511256
If your client is on a LAN (e.g., 192.168.1.0/24), you can create tunnels to any reachable machine:
# On the server
forge> create client-1234 8080 192.168.1.50 80 # Access internal web server
forge> create client-1234 3389 192.168.1.100 3389 # Access internal RDP server
This allows the server to access machines that are only reachable from the client's network.
forge> create client-1234 2222 10.10.10.100 22 # Access ssh server on internal LAN
[Server] [Client] [LAN Machine]
192.168.1.10 192.168.1.50/10.10.10.50 10.10.10.100
^ ^ ^
| | |
TLS :8443<-------------->:8443 |
:2222 listening |
| |
+------------------------>:22
The server accepts the following command-line arguments:
--addr
: Address to listen on (default: "127.0.0.1:8443")--key
: Path to server private key (PKCS8 PEM)--cert
: Path to server certificate (PEM)--allow-udp
: Allow UDP tunnels (default: TCP only) # Currently not implemented--port-range
: Port range allowed for tunnels (default: "1024-65535")
Client configuration is stored in config.toml
:
server_address = "192.168.1.4:8443"
server_sni = "192.168.1.4"
ca_cert = "ca-cert.pem"
Once the server is running, you can use the following commands in the server's interactive console:
help
: Display available commandsclients
: List connected clientstunnels <client_id>
: List tunnels for a specific clientcreate <client_id> <local_port> <target_host> <target_port>
: Create a new tunnelmodify <client_id> <local_port> <new_host> <new_port>
: Modify an existing tunnelclose <client_id> <local_port>
: Close a tunnelexit
: Shut down the server
The project implements several security measures:
- TLS encryption for the command channel (server certificate verification)
- Configurable port ranges to restrict tunnel endpoints (default: 1024-65535)
- Client registration system for tunnel management
- TunnelManager: Handles creation and management of tunnels
- MultiplexedTunnel: Manages multiple logical connections over a single TLS connection
- Protocol: Defines the command and control protocol between client and server
- Currently supports TCP tunnels only (UDP support planned)
- No built-in authentication beyond TLS certificates
- TCP tunnels created are currently unencrypted
-
Certificate Errors
- Ensure the CA certificate is properly configured
- Verify the server's certificate matches its hostname/IP
- Check certificate expiration dates
-
Connection Issues
- Verify the server address and port are correct
- Check firewall settings
- Ensure the target service is running
-
Permission Issues
- Ports below 1024 require root/administrator privileges
- Check file permissions on certificates and keys
Both client and server provide detailed logging. Check the console output for error messages and connection details.