python中的battle.net身份验证器例程。
bna的Python项目详细描述
使用命令行工具
bna是python bna库的命令行接口。它可以存储和管理多个身份验证程序,也可以创建新的身份验证程序。
- 要记住两件事:
- 在您正在玩的同一台计算机上使用身份验证器是不安全的。 不可能(不知道秘密)导入现有的验证者
配置存储在~/.config/bna/bna.conf中。例如,可以使用–config=~/.bna.conf传递另一个配置目录。
创建新的验证器
$ bna --new
如果您还没有身份验证器,它将被设置为默认值。您可以通过–否则设置默认值。
获取认证令牌
$ bna 01234567 $ bna EU-1234-1234-1234 76543210
获取序列的还原代码
$ bna --restore-code Z45Q9CVXRR $ bna --restore EU-1234-1234-1234 ABCDE98765 Restored serial EU-1234-1234-1234
来自mobile的otp
$ bna --otpauth-url otpauth://totp/Battle.net:EU123412341234:?secret=ASFAS75ASDF75889G9AD7S69AS7697AS&issuer=Battle.net&digits=8
现在将其粘贴到您的otp应用程序,或转换为qrcode并扫描,或手动输入密码。
注意:这不适用于“google authenticator”,因为它不支持8位数字,请尝试“FreeOTP”
使用python bna库
请求新的验证器
import bna try: # region is EU or US # note that EU authenticators are valid in the US, and vice versa serial, secret = bna.request_new_serial("US") except bna.HTTPError as e: print("Could not connect:", e)
获得代币
# Get and print a token token, time_remaining = bna.get_token(secret=secret) print(token) # print a new token every time the previous one expires from time import sleep while True: token, time_remaining = bna.get_token(secret=secret) print(token) sleep(time_remaining)