Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| import random | |
| import re | |
| def luhn_check(card_number): | |
| digits = [int(d) for d in str(card_number) if d.isdigit()] | |
| checksum = 0 | |
| parity = len(digits) % 2 | |
| for i, digit in enumerate(digits): | |
| if i % 2 == parity: | |
| digit *= 2 | |
| if digit > 9: | |
| digit -= 9 | |
| checksum += digit | |
| return checksum % 10 == 0 | |
| def verificar_luhn_lista(lista): | |
| tarjetas_raw = [t.strip() for t in lista.replace('\n', ',').split(',') if t.strip()] | |
| if len(tarjetas_raw) > 50: | |
| return "❌ Máximo permitido: 50 tarjetas." | |
| resultados = [] | |
| for entrada in tarjetas_raw: | |
| match = re.search(r"\d{12,19}", entrada) | |
| if match: | |
| numero = match.group() | |
| resultado = "✅ VÁLIDA" if luhn_check(numero) else "❌ INVÁLIDA" | |
| resultados.append(f"{entrada} → {resultado}") | |
| else: | |
| resultados.append(f"{entrada} → ⚠️ No se encontró un número válido") | |
| return "\n".join(resultados) | |
| def buscar_bin(bin_input): | |
| bin_input = re.sub(r"\D", "", bin_input)[:6] | |
| if len(bin_input) < 6: | |
| return "❌ Ingrese al menos los primeros 6 dígitos." | |
| try: | |
| response = requests.get(f"https://lookup.binlist.net/{bin_input}") | |
| if response.status_code == 200: | |
| data = response.json() | |
| tipo = data.get("type", "Desconocido") | |
| marca = data.get("scheme", "Desconocida") | |
| nivel = data.get("brand", "Desconocido") | |
| banco = data.get("bank", {}).get("name", "Desconocido") | |
| pais = data.get("country", {}).get("name", "Desconocido") | |
| return ( | |
| f"🔍 Información del BIN {bin_input}:\n" | |
| f"- Banco: {banco}\n" | |
| f"- Marca: {marca.capitalize()}\n" | |
| f"- Tipo: {tipo.capitalize()} 💳\n" | |
| f"- Nivel: {nivel}\n" | |
| f"- País: {pais}" | |
| ) | |
| else: | |
| return "❌ No se encontró información para este BIN." | |
| except: | |
| return "❌ Error al conectar con el servicio BIN." | |
| def generar_tarjetas(bin_input, cantidad, mes, anio): | |
| bin_input = re.sub(r"\D", "", bin_input) | |
| if len(bin_input) < 6 or len(bin_input) > 15: | |
| return "❌ El BIN debe tener entre 6 y 15 dígitos." | |
| fecha_final = f"{str(mes).zfill(2)}/{str(anio)[-2:]}" | |
| generadas = [] | |
| while len(generadas) < cantidad: | |
| base = bin_input | |
| while len(base) < 15: | |
| base += str(random.randint(0, 9)) | |
| for last_digit in range(10): | |
| card_candidate = base + str(last_digit) | |
| if luhn_check(card_candidate): | |
| ccv = str(random.randint(100, 999)) | |
| generadas.append(f"{card_candidate}|{fecha_final}|{ccv}") | |
| break | |
| return "\n".join(generadas) | |
| custom_css = ''' | |
| body { | |
| background-color: #eafaf1; | |
| font-family: Arial, sans-serif; | |
| } | |
| h1, h2, .gr-textbox label, .gr-dropdown label, .gr-slider label { | |
| text-align: center !important; | |
| font-weight: bold !important; | |
| color: #14532d; | |
| } | |
| .gr-block, .gr-group { | |
| margin: auto; | |
| max-width: 600px; | |
| padding: 10px; | |
| } | |
| .gr-button { | |
| display: block; | |
| margin: 10px auto 0 auto; | |
| font-weight: bold; | |
| background-color: #34d399; | |
| color: #064e3b; | |
| } | |
| ''' | |
| with gr.Blocks(css=custom_css, title="Herramientas Educativas de Tarjetas") as demo: | |
| gr.Markdown("# 🧠 Herramientas Educativas para Tarjetas") | |
| with gr.Tab("💳 Generador de CC"): | |
| gr.Markdown("Genera tarjetas válidas con BIN, fecha seleccionada y CCV aleatorio.") | |
| bin_para_generar = gr.Textbox(label="BIN o primeros dígitos") | |
| cantidad = gr.Slider(minimum=1, maximum=50, step=1, value=10, label="Cantidad de tarjetas") | |
| mes_dropdown = gr.Dropdown(choices=[str(m).zfill(2) for m in range(1, 13)], label="Mes (MM)", value="12") | |
| anio_dropdown = gr.Dropdown(choices=[str(y) for y in range(2025, 2033)], label="Año (YYYY)", value="2026") | |
| boton_generar = gr.Button("Generar tarjetas") | |
| salida_generadas = gr.Textbox(label="Tarjetas generadas", lines=10) | |
| boton_generar.click( | |
| generar_tarjetas, | |
| inputs=[bin_para_generar, cantidad, mes_dropdown, anio_dropdown], | |
| outputs=salida_generadas | |
| ) | |
| with gr.Tab("📘 Bin List"): | |
| gr.Markdown("Consulta información educativa de un BIN específico.") | |
| bin_input = gr.Textbox(label="Número de tarjeta o BIN") | |
| boton_bin = gr.Button("Buscar BIN") | |
| bin_info = gr.Textbox(label="Resultado del análisis", lines=7, interactive=False) | |
| boton_bin.click(buscar_bin, inputs=bin_input, outputs=bin_info) | |
| with gr.Tab("✅ Verificador Luhn"): | |
| gr.Markdown("Verifica si un número de tarjeta cumple con el algoritmo Luhn.") | |
| entrada_luhn = gr.Textbox(label="Pega tarjetas (con o sin fecha/ccv)", lines=8) | |
| boton_verificar = gr.Button("Verificar") | |
| salida_luhn = gr.Textbox(label="Resultado", lines=10, interactive=False) | |
| boton_verificar.click(verificar_luhn_lista, inputs=entrada_luhn, outputs=salida_luhn) | |
| demo.launch() | |