import ctypes
import random
import string

def spoofer_alterar_nome_pc():
    novo_nome = gerar_nome_pc_aleatorio()
    if alterar_nome_pc(novo_nome):
        print(f"Nome do PC alterado para: {novo_nome}")
    else:
        print("Erro ao alterar o nome do PC.")

def gerar_nome_pc_aleatorio():
    caracteres_permitidos = string.ascii_letters + string.digits
    novo_nome = ''.join(random.choices(caracteres_permitidos, k=8))
    return novo_nome

def alterar_nome_pc(novo_nome):
    try:
        if hasattr(ctypes.windll.kernel32, "SetComputerNameW"):
            ctypes.windll.kernel32.SetComputerNameW(novo_nome)
            return True
        else:
            print("Função SetComputerNameW não disponível.")
            return False
    except Exception as e:
        print(f"Erro: {e}")
        return False

if __name__ == "__main__":
    spoofer_alterar_nome_pc()