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/