Skip to content

Latest commit

Β 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

wspros

SSH WebSocket Proxy - A simple Python proxy server that enables SSH connections over WebSocket protocol, perfect for HTTP Injector Custom Payload mode.

πŸš€ Quick Installation (Recommended)

Install and configure everything with a single command:

bash <(curl -sL https://raw.githubusercontent.com/Codexxxa/wspros/main/install.sh)

This automated installer will:

  • βœ… Install all required dependencies (Python3, OpenSSH, UFW)
  • βœ… Let you choose your preferred port (80, 8080, 443, or custom)
  • βœ… Handle port conflicts automatically (stops Apache/Nginx if needed)
  • βœ… Create and configure the WebSocket proxy service
  • βœ… Set up auto-start on boot with systemd
  • βœ… Configure firewall rules
  • βœ… Provide you with ready-to-use HTTP Injector payloads

What the Installer Does

The install.sh script automates the entire setup process:

  1. Checks for root privileges - Ensures you have the necessary permissions
  2. Interactive port selection - Choose from:
    • Port 80 (default HTTP)
    • Port 8080 (recommended)
    • Port 443 (HTTPS)
    • Custom port (1024-65535)
  3. Installs dependencies - Python3, OpenSSH server, curl, and UFW firewall
  4. Enables SSH service - Configures SSH to start on boot
  5. Handles conflicts - Automatically stops Apache/Nginx if they're using your selected port
  6. Creates the proxy - Installs the WebSocket proxy script at /usr/local/bin/ws-proxy.py
  7. Systemd service - Creates auto-restart service that starts on boot
  8. Configures firewall - Opens SSH (22) and your selected WebSocket port
  9. Shows configuration - Displays your server IP, port, and ready-to-use HTTP Injector payloads

Post-Installation

After installation, you'll see:

  • Your server's IP address and WebSocket port
  • HTTP Injector configuration settings
  • Multiple payload examples for different scenarios
  • Useful management commands

Example payloads provided:

  • WebSocket upgrade payload
  • Payload with bug host support
  • CONNECT method payload
  • Direct connection (200 OK) payload

Management commands:

# Check service status
sudo systemctl status ws-proxy

# View live logs
sudo journalctl -u ws-proxy -f

# Restart service
sudo systemctl restart ws-proxy

# Stop service
sudo systemctl stop ws-proxy

πŸ“± HTTP Injector Setup

Prerequisites

  1. A VPS or server with root access
  2. HTTP Injector app installed on your Android device
  3. Basic SSH credentials (username and password)

Configuration Steps

  1. Run the installer on your VPS (see Quick Installation above)

  2. Open HTTP Injector on your Android device

  3. Configure SSH Settings:

    • Tap on SSH Settings
    • SSH Host: Your server IP (shown after installation)
    • SSH Port: 22
    • Username: Your SSH username
    • Password: Your SSH password
  4. Set up Custom Payload:

    • Select Custom Payload mode
    • Use one of the payloads provided after installation
    • Example (WebSocket):
      GET / HTTP/1.1[crlf]Host: YOUR_IP:YOUR_PORT[crlf]Upgrade: websocket[crlf][crlf]
      
  5. Connect:

    • Tap Start to establish the connection
    • Your SSH tunnel over WebSocket is now active!

Payload Options

The installer provides 4 different payload types:

1. WebSocket Payload (Recommended for most scenarios)

GET / HTTP/1.1[crlf]Host: YOUR_IP:PORT[crlf]Upgrade: websocket[crlf][crlf]

2. WebSocket with Bug Host (For ISP bug hosts)

GET / HTTP/1.1[crlf]Host: [host][crlf]Upgrade: websocket[crlf]Connection: Upgrade[crlf][crlf]

3. CONNECT Method (HTTP proxy style)

CONNECT [host_port] HTTP/1.1[crlf]Host: YOUR_IP:PORT[crlf][crlf]

4. Direct Connection (Simple 200 OK)

GET / HTTP/1.1[crlf]Host: YOUR_IP:PORT[crlf]Connection: keep-alive[crlf][crlf]

Note: Replace YOUR_IP and PORT with the actual values shown after installation. In HTTP Injector, use [crlf] for line breaks and [host] for dynamic host injection.

πŸ› οΈ Manual Installation

If you prefer to install manually or the automated installer doesn't work for your system:

Requirements

  • Python 3.6 or higher
  • No additional dependencies required (uses only standard library)

Usage

Running the Proxy Manually

  1. Download the script:

    wget https://raw.githubusercontent.com/Codexxxa/wspros/main/main.py
  2. Run the proxy:

    On Windows (Run as Administrator):

    python main.py

    On Linux/macOS (requires root for port 80):

    sudo python3 main.py

Expected Output

When the proxy starts, you will see:

2024-01-25 10:00:00 - INFO - SSH WebSocket Proxy started on 0.0.0.0:80
2024-01-25 10:00:00 - INFO - Forwarding traffic to 127.0.0.1:22
2024-01-25 10:00:00 - INFO - Press Ctrl+C to stop the proxy

When a client connects:

2024-01-25 10:01:00 - INFO - Client connected: 192.168.1.100:54321
2024-01-25 10:01:00 - INFO - WebSocket upgrade request detected from ('192.168.1.100', 54321)
2024-01-25 10:01:00 - INFO - Sent 101 Switching Protocols to ('192.168.1.100', 54321)
2024-01-25 10:01:00 - INFO - Connected to SSH server at 127.0.0.1:22

Configuration

The following parameters can be modified in the script:

Parameter Default Description
LISTEN_HOST 0.0.0.0 Address to listen on
LISTEN_PORT 80 Port to listen on
SSH_HOST 127.0.0.1 SSH server address to forward to
SSH_PORT 22 SSH server port to forward to
BUFFER_SIZE 4096 Buffer size for data transfer

How It Works

  1. The proxy listens on your selected port for incoming connections
  2. When a client connects, it reads the initial HTTP request
  3. It supports multiple connection types:
    • WebSocket Upgrade: Responds with 'HTTP/1.1 101 Switching Protocols'
    • CONNECT Method: Responds with 'HTTP/1.1 200 Connection Established'
    • Direct Connection: Responds with 'HTTP/1.1 200 OK'
  4. A bidirectional tunnel is established between the client and the local SSH server
  5. All traffic is forwarded transparently between the client and SSH server

Features

  • βœ… Multiple connection methods (WebSocket, CONNECT, direct)
  • βœ… Automatic service management with systemd
  • βœ… Auto-restart on failure
  • βœ… Firewall configuration
  • βœ… Port conflict resolution
  • βœ… Comprehensive logging
  • βœ… Uses only Python standard libraries (socket, threading)
  • βœ… No C++ build tools required
  • βœ… Works on Linux distributions (Ubuntu, Debian, CentOS, RHEL, Fedora)
  • βœ… Optimized for HTTP Injector Custom Payload mode

Troubleshooting

Service won't start

# Check the service status
sudo systemctl status ws-proxy

# Check the logs
sudo journalctl -u ws-proxy -n 50

Port is already in use

The installer automatically handles Apache/Nginx conflicts. If you still have issues:

# Find what's using the port
sudo lsof -i :PORT_NUMBER

# Stop the conflicting service
sudo systemctl stop SERVICE_NAME

Cannot connect from HTTP Injector

  1. Verify the proxy is running: sudo systemctl status ws-proxy
  2. Check firewall rules: sudo ufw status or sudo firewall-cmd --list-all
  3. Verify SSH credentials are correct
  4. Ensure your VPS's security group/firewall allows the WebSocket port
  5. Test SSH connection directly: ssh username@your_server_ip

View detailed logs

# Real-time logs
sudo journalctl -u ws-proxy -f

# Last 100 lines
sudo journalctl -u ws-proxy -n 100

# Logs from today
sudo journalctl -u ws-proxy --since today

Uninstallation

To completely remove the WebSocket SSH Proxy:

# Stop and disable the service
sudo systemctl stop ws-proxy
sudo systemctl disable ws-proxy

# Remove the service file
sudo rm /etc/systemd/system/ws-proxy.service

# Remove the proxy script
sudo rm /usr/local/bin/ws-proxy.py

# Reload systemd
sudo systemctl daemon-reload

# Optional: Remove firewall rules
sudo ufw delete allow YOUR_PORT/tcp

Security Considerations

  • Network Binding: By default, the proxy binds to 0.0.0.0 (all network interfaces), allowing connections from external machines. This is intentional for a VPS setup.
  • Firewall: The installer configures UFW/firewalld to only allow SSH and the WebSocket port.
  • SSH Authentication: The proxy relies on SSH server's authentication. Always use strong passwords or SSH keys.
  • VPS Security: Ensure your VPS has proper security measures (fail2ban, regular updates, etc.)
  • Monitor Logs: Regularly check logs for suspicious activity

FAQ

Q: Which port should I choose? A: Port 8080 is recommended as it's commonly open and doesn't require special privileges. Port 80 might conflict with web servers. Port 443 works well if you're not running HTTPS services.

Q: Can I run this on shared hosting? A: No, you need a VPS or dedicated server with root access.

Q: Does this work with all ISPs? A: The WebSocket method works with most ISPs. Try different payload options if one doesn't work.

Q: Can I change the port after installation? A: Yes. Edit /etc/systemd/system/ws-proxy.service, change the WS_PROXY_PORT value, then run:

sudo systemctl daemon-reload
sudo systemctl restart ws-proxy
sudo ufw allow NEW_PORT/tcp

Q: Is this legal? A: This tool is for legitimate SSH tunneling. Ensure you comply with your ISP's terms of service and local laws.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages