Bboysoul's Blog

首页 公告 RSS

搭建webssh

January 9, 2023 本文有 448 个字 需要花费 1 分钟阅读

简介

为了防止世界被破坏,为了维护世界的和平,为了防止我有一天连接不上我的云服务器,所以我决定搭建一个webssh作为一个后门

webssh原理

+---------+     http     +--------+    ssh    +-----------+
| browser | <==========> | webssh | <=======> | ssh server|
+---------+   websocket  +--------+    ssh    +-----------+

如上图所示,浏览器和webssh使用websocket通信,webssh和服务器使用ssh通信,所以,只要我搭建一个webssh客户端在我的oracle服务器上,我就可以使用下面的路径连接我的服务器

client <---> cloudflare <---> nginx/Caddy <---> wssh

这样,只要cloudflare不倒,我就不倒

操作

首先clone下仓库

git clone https://github.com/huashengdun/webssh.git

之后修改下面的代码

vim webssh/settings.py

define('xheaders', type=bool, default=True, help='Support xheaders')

改为

define('xheaders', type=bool, default=False, help='Support xheaders')

就是default=True改为default=False

具体原因看下面这个issue

https://github.com/huashengdun/webssh/issues/141

之后直接

docker-compose up -d

启动完成

接着配置服务器中的nginx

server {
    listen       443 ssl;
    server_name  your_domain;
    ssl_certificate cert/cloudflare/cloudflare.pem;
    ssl_certificate_key cert/cloudflare/cloudflare.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    #表示使用的加密套件的类型。
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #表示使用的TLS协议的类型。
    ssl_prefer_server_ciphers on;
    location /{
        proxy_pass http://127.0.0.1:8888;
        access_log logs/webssh.log main;
        client_max_body_size 1000m;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Real-PORT $remote_port;
        proxy_http_version 1.1;
    }
}

之后cloudflare中加上解析就可以了

欢迎关注我的博客www.bboy.app

Have Fun


Tags:

本站总访问量 本站总访客数