Untitled
Anonymous
Plain Text
09/03/2025 7:36 PM
1.2 KB
14
Indexable
Never
import pyotp
import time
import os
import sys
import subprocess
def clear_terminal():
os.system('cls' if os.name == 'nt' else 'clear')
def copiar_para_clipboard(texto):
processo = subprocess.Popen(['clip'], stdin=subprocess.PIPE, text=True)
processo.communicate(input=texto)
# โ
Se houver argumento via CLI, imprime o OTP atual e sai
if len(sys.argv) > 1:
totp = pyotp.TOTP(sys.argv[1])
current_otp = totp.now()
copiar_para_clipboard(current_otp)
print(f"๐ OTP atual: {current_otp}")
sys.exit(0)
# ๐ Solicita o secret
secret = input("Digite o secret fornecido pelo site: ").strip().replace(" ", "").upper()
# Cria o gerador TOTP
totp = pyotp.TOTP(secret)
interval = totp.interval # Normalmente 30 segundos
current_otp = totp.now()
print(f"๐ OTP atual: {current_otp}")
# ๐ Loop infinito com atualizaรงรฃo por segundo
while True:
current_otp = totp.now()
copiar_para_clipboard(current_otp)
for remaining in range(interval, 0, -1):
clear_terminal()
print(f"๐ OTP atual: {current_otp}")
print(f"โณ Expira em: {remaining} segundos")
time.sleep(1)
Editor is loading...
Leave a Comment