Last active
March 11, 2025 05:10
-
-
Save supersonictw/6f98d8c5f2d1850b91fbddb8ebf1ef23 to your computer and use it in GitHub Desktop.
Bypass SSH protocol via WebSocket traffics curl -sSL https://ncurl.xyz/s/vG9S64ySR | sh -
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# sshws.sh - Bypass SSH protocol via WebSocket traffics | |
# SPDX-License-Identifier: MIT (https://ncurl.xyz/s/o_o6DVqIR) | |
# https://gist.github.com/supersonictw/6f98d8c5f2d1850b91fbddb8ebf1ef23 | |
# Client: | |
# ssh -o ProxyCommand="wstunnel client -L stdio://%h:%p ws://example.com:2530" 127.0.0.1 | |
WSTUNNEL_DOWNLOAD="https://github.com/erebe/wstunnel/releases/download/v9.6.1/wstunnel_9.6.1_linux_amd64.tar.gz" | |
WSTUNNEL_TMP_PATH_PREFIX="/tmp/wstunnel" | |
WSTUNNEL_INSTALL_PREFIX="/usr/local/bin" | |
mkdir -p "$WSTUNNEL_TMP_PATH_PREFIX" "$WSTUNNEL_INSTALL_PREFIX" | |
wget -O "$WSTUNNEL_TMP_PATH_PREFIX/wstunnel.tar.gz" $WSTUNNEL_DOWNLOAD | |
tar -zxf "$WSTUNNEL_TMP_PATH_PREFIX/wstunnel.tar.gz" -C "$WSTUNNEL_TMP_PATH_PREFIX" | |
SUDO='' | |
if [ "$EUID" != 0 ]; then | |
SUDO='sudo' | |
fi | |
$SUDO apt-get install -y openssh-server | |
$SUDO install "$WSTUNNEL_TMP_PATH_PREFIX/wstunnel" "$WSTUNNEL_INSTALL_PREFIX/wstunnel" | |
$SUDO tee "/lib/systemd/system/sshws.service" <<EOF | |
[Install] | |
WantedBy=multi-user.target | |
[Unit] | |
Description=Transfer SSH protocol with WebSocket | |
Wants=network-online.target | |
After=network-online.target | |
[Service] | |
Type=simple | |
Restart=always | |
User=nobody | |
ExecStart=$WSTUNNEL_INSTALL_PREFIX/wstunnel server --restrict-to 127.0.0.1:22 http://127.0.0.1:2530 | |
EOF | |
$SUDO systemctl daemon-reload | |
$SUDO systemctl enable --now "sshws.service" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment