Giter Club home page Giter Club logo

xshell-otp's Introduction

Xshell-OTP

Xshell 自动登录 One-time Password 跳板机

USAGE

使用

下载 jumper.js 后拖到最后,修改 Main 函数中的配置:

function Main()
{
    // Calculate OTP token
    var totpObj = new TOTP();
    var epoch = Math.floor(new Date().getTime() / 1000 % 30);
    var elapsed = 30 - epoch

    // Adjust the sliding window
    if (elapsed <= 3 ) {
        xsh.Dialog.MsgBox("Hold on, and wait " + elapsed + " seconds!");
        xsh.Session.Sleep(elapsed * 1000 + 100);
    }

    // Calculate OTP token
    // REVISED 修改为你自己的 Google Authenticator Secret
    var otp = totpObj.getOTP("REVISED");

    // Copy the token to clipboard
    xsh.Screen.Synchronous = true;
    xsh.Screen.Send("cmd /c echo " + otp + "| clip");
    xsh.Screen.Send(String.fromCharCode(13));
    xsh.Screen.Clear();

    // Open Session
    // xsh.Session.Open("ssh://username:password@host:port")
    // 修改为你自己的 xsh 文件路径
    xsh.Session.Open("C:\Users\REVISED\Documents\NetSarang\Xshell\Sessions\jump.xsh");

    // Close the local shell
    // xsh.Session.Sleep(1000);
    xsh.Screen.Send("exit");
    xsh.Screen.Send(String.fromCharCode(13));
}

原理

使用 Google Authenticator MFA 验证机制登录跳板机,可以通过其导出的 secret 在本地计算出当前的 token。Xshell 支持运行 javascript 脚本,所以这个 token 可以直接在 Xshell 端计算完成。但是 Xshell 在处理 MFA 验证机制时,是直接弹出对话框,并不支持传统的 terminal 输入,Xshell 也并没有提供自动完成的 API,所以只能手动拷贝输入。

xshell-otp's People

Contributors

ms2008 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.