Socket
Book a DemoInstallSign in
Socket

rsh-ws

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rsh-ws

远程外壳,使用WebSocket连接

latest
Source
npmnpm
Version
2.1.2
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Remote Shell - WebSocket

rsh-ws

协议:MIT

怎么使用?

  • 首先,全局安装此项目,运行npm i rsh-ws -g
  • 使用rsh-ws来启动服务
  • 服务会在终端打印连接代码,例如0O0P5D99,前4位是端口号码,后4位是连接密码,端口号码请使用36进制解析,在这个例子中,端口号码是31129
  • 使用WebSocket连接ws://ip:31129,如果是本机,ip可以为127.9.9.9
  • 执行命令,例如,在本例子中,连接密码是5D99,你可以发送JSON命令
{
    "do": "login",
    "passwd": "5D99"
}

来登录

  • 创建终端
{
    "do": "createTerminal",
    "cwd": "./", //终端目录
}

返回值中有 data.pid 参数,用来标识终端 7. 发送命令

{
    "pid": "<pid>",
    "do": "write-to-terminal",
    "data": "ls"
}

这会向终端的stdin写入data 8. 返回命令结果
格式为

{
    "status": "ok",
    "data": {
        "type": "Received data",
        "data": "<data here>"
    }
}
  • 获得rsh-ws版本
    发送命令
{
    "do": "get-version"
}

返回结果

{
    "status": "ok",
    "data": {
        "type":"version",
        "version": "<version here>"
    }
}
  • 文件处理
    发送命令
{
    "do": "file-operation",
    "path": "<path here>"
}

将会返回

{
    "status": "ok",
    "data": {
        "port": "<port here>",
        "file_id": "<file_id here>",
        "path": "<path here>"
    }
}

文件传输使用HTTP协议
支持以下方法

  • GET http://ip:port/<file_id> 下载文件,响应数据为文件内容
  • PUT http://ip:port/<file_id> 上传文件,Body负载为文件内容
  • DELETE http://ip:port/<file_id> 删除文件

port请使用返回数据中的port

Keywords

rsh

FAQs

Package last updated on 01 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts