Untitled

Anonymous
Plain Text
09/03/2025 7:36 PM
1.2 KB
13
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