SecureCRT兩步驗證自動登錄腳本


 

簡介

用於解決 Google Authenticator 的兩步驗證登錄。涉及到密碼,不建議腳本保存到公共環境。

 

安裝oathtool

Mac

$ brew install oath-toolkit

Linux

$ yum install oathtool

其它安裝方法見:https://github.com/daveio/shell-otp

Windows

http://rubli.info/t-blog/2011/09/03/generating-oath-otps-on-windows-with-oathtool/ 

 

腳本示例

 

這里引用的是totp算法

#$language = "Python"
#$interface = "1.0"

import subprocess

OATHTOOL = "你的oathtool路徑"
TOTP_CACHE_PATH = "/tmp/totp.txt"
TOTP_KEY = "你的GoogleOauthKey"
PASSWORD = "你的密碼"

def totp(key):
    totp = subprocess.check_output([OATHTOOL, "--totp", "-b", "-d", "6", TOTP_KEY]).rstrip()
    return totp


def Main():
    tab = crt.GetScriptTab()
    if tab.Session.Connected != True:
        crt.Dialog.MessageBox("Session Not Connected")
        return
    tab.Screen.Synchronous = True
    tab.Screen.WaitForStrings(['Verification code:'])
    vc = totp(TOTP_KEY)
    tab.Screen.Send("{vc}\r\n".format(vc=vc))
    tab.Screen.WaitForStrings(['Password:'])
    tab.Screen.Send("{pwd}\r\n".format(pwd=PASSWORD))
    return

Main()

 

 

 

參考:

http://www.dannysite.com/blog/165/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM