Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,130 +1,71 @@
|
|
| 1 |
import time
|
| 2 |
import threading
|
| 3 |
-
|
| 4 |
-
from http.server import BaseHTTPRequestHandler, HTTPServer
|
| 5 |
from seleniumbase import Driver
|
| 6 |
-
from selenium.webdriver.common.by import By
|
| 7 |
-
from selenium.webdriver.support.ui import WebDriverWait
|
| 8 |
-
from selenium.webdriver.support import expected_conditions as EC
|
| 9 |
from pyvirtualdisplay import Display
|
| 10 |
|
| 11 |
-
# --- 🔐
|
| 12 |
USER_TW = "erinaldordso3"
|
| 13 |
PASS_TW = "Miau.1996"
|
| 14 |
MUNDO_ID = "br141"
|
| 15 |
|
| 16 |
def log(acao, status="INFO"):
|
| 17 |
agora = datetime.now().strftime("%H:%M:%S")
|
| 18 |
-
icons = {"AUDIT": "📊", "
|
| 19 |
print(f"[{agora}] [{icons.get(status, 'ℹ️')}] {acao}", flush=True)
|
| 20 |
|
|
|
|
|
|
|
| 21 |
class ServidorFalso(BaseHTTPRequestHandler):
|
| 22 |
def do_GET(self):
|
| 23 |
self.send_response(200); self.end_headers()
|
| 24 |
-
self.wfile.write(b"Bot Tribal Wars v5.
|
| 25 |
-
def log_message(self, format, *args): pass
|
| 26 |
|
| 27 |
-
|
| 28 |
-
try: HTTPServer(('0.0.0.0', 7860), ServidorFalso).serve_forever()
|
| 29 |
-
except: pass
|
| 30 |
|
| 31 |
-
def
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
| 34 |
try:
|
| 35 |
-
|
| 36 |
-
driver.
|
| 37 |
-
driver.type('input#password', PASS_TW)
|
| 38 |
-
driver.execute_script("document.querySelector('.btn-login').click();")
|
| 39 |
time.sleep(5)
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
return True
|
| 48 |
-
return False
|
| 49 |
-
except: return False
|
| 50 |
-
|
| 51 |
-
def auditoria_e_obras(driver):
|
| 52 |
-
# TELEPORTE DIRETO PARA O EDIFÍCIO PRINCIPAL
|
| 53 |
-
driver.get(f"https://{MUNDO_ID}.tribalwars.com.br/game.php?screen=main")
|
| 54 |
-
time.sleep(3)
|
| 55 |
-
|
| 56 |
-
# 🛠️ DESTRUIDOR DE BLOQUEIOS (Remove qualquer overlay que impeça cliques)
|
| 57 |
-
driver.execute_script("""
|
| 58 |
-
jQuery(".popup_box_close, .quest-reward-collect, #mask, .modal-overlay, .confirmation-box").click().remove();
|
| 59 |
-
jQuery("body").removeClass("modal-open");
|
| 60 |
-
""")
|
| 61 |
-
|
| 62 |
-
try:
|
| 63 |
-
# 🧪 MÉTODO RAIO-X: Extrai recursos direto da memória do jogo
|
| 64 |
-
dados = driver.execute_script("""
|
| 65 |
-
return {
|
| 66 |
-
wood: game_data.village.wood,
|
| 67 |
-
stone: game_data.village.stone,
|
| 68 |
-
iron: game_data.village.iron,
|
| 69 |
-
pop: game_data.village.pop,
|
| 70 |
-
pop_max: game_data.village.pop_max
|
| 71 |
-
};
|
| 72 |
-
""")
|
| 73 |
-
|
| 74 |
-
log(f"AUDITORIA -> 🪵 {dados['wood']} | 🧱 {dados['stone']} | ⚙️ {dados['iron']} | 👥 {dados['pop']}/{dados['pop_max']}", "AUDIT")
|
| 75 |
|
| 76 |
-
#
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
log("Fila 2/2. Aguardando construção finalizar.", "INFO")
|
| 80 |
-
return
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
log_name = ed.upper()
|
| 97 |
-
break
|
| 98 |
-
|
| 99 |
-
if alvo:
|
| 100 |
-
driver.execute_script("arguments[0].click();", alvo)
|
| 101 |
-
log(f"UPGRADE DISPARADO: {log_name}!", "CONSTR")
|
| 102 |
-
else:
|
| 103 |
-
log("Sem recursos ou nada pronto para subir agora.", "INFO")
|
| 104 |
|
| 105 |
-
|
| 106 |
-
log(f"Sincronizando interface... (Aguardando dados do jogo)", "ALERTA")
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
driver = Driver(uc=True, headless=False)
|
| 111 |
-
|
| 112 |
-
try:
|
| 113 |
-
if realizar_login(driver):
|
| 114 |
-
while True:
|
| 115 |
-
auditoria_e_obras(driver)
|
| 116 |
-
# Reduzimos o tempo de espera para 3 segundos para acelerar a correção
|
| 117 |
-
time.sleep(3)
|
| 118 |
-
|
| 119 |
-
if "screen=index" in driver.current_url:
|
| 120 |
-
realizar_login(driver)
|
| 121 |
-
else:
|
| 122 |
-
time.sleep(10)
|
| 123 |
-
|
| 124 |
-
except Exception as e: log(f"Erro Crítico: {e}", "ALERTA")
|
| 125 |
-
finally:
|
| 126 |
-
driver.quit(); display.stop()
|
| 127 |
|
| 128 |
if __name__ == "__main__":
|
| 129 |
-
threading.Thread(target=
|
| 130 |
iniciar()
|
|
|
|
| 1 |
import time
|
| 2 |
import threading
|
| 3 |
+
import random
|
|
|
|
| 4 |
from seleniumbase import Driver
|
|
|
|
|
|
|
|
|
|
| 5 |
from pyvirtualdisplay import Display
|
| 6 |
|
| 7 |
+
# --- 🔐 CREDENCIAIS ---
|
| 8 |
USER_TW = "erinaldordso3"
|
| 9 |
PASS_TW = "Miau.1996"
|
| 10 |
MUNDO_ID = "br141"
|
| 11 |
|
| 12 |
def log(acao, status="INFO"):
|
| 13 |
agora = datetime.now().strftime("%H:%M:%S")
|
| 14 |
+
icons = {"AUDIT": "📊", "LOGIN": "🔑", "ALERTA": "❌", "SUCESSO": "✅"}
|
| 15 |
print(f"[{agora}] [{icons.get(status, 'ℹ️')}] {acao}", flush=True)
|
| 16 |
|
| 17 |
+
from datetime import datetime
|
| 18 |
+
|
| 19 |
class ServidorFalso(BaseHTTPRequestHandler):
|
| 20 |
def do_GET(self):
|
| 21 |
self.send_response(200); self.end_headers()
|
| 22 |
+
self.wfile.write(b"Bot Tribal Wars v5.7 - Chameleon Mode")
|
| 23 |
+
def log_message(self, format, *args): pass
|
| 24 |
|
| 25 |
+
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
def iniciar():
|
| 28 |
+
display = Display(visible=0, size=(1920, 1080)); display.start()
|
| 29 |
+
|
| 30 |
+
# AGRESSIVO: Esconde totalmente que é um bot e usa User-Agent de Chrome Real
|
| 31 |
+
driver = Driver(uc=True, headless=False, agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36")
|
| 32 |
+
|
| 33 |
try:
|
| 34 |
+
log("Tentando bypass final de detecção...", "LOGIN")
|
| 35 |
+
driver.get("https://www.tribalwars.com.br/")
|
|
|
|
|
|
|
| 36 |
time.sleep(5)
|
| 37 |
|
| 38 |
+
# Login Manualizado por JS para evitar rastreio de digitação
|
| 39 |
+
driver.execute_script(f"document.getElementById('user').value = '{USER_TW}';")
|
| 40 |
+
driver.execute_script(f"document.getElementById('password').value = '{PASS_TW}';")
|
| 41 |
+
time.sleep(1)
|
| 42 |
+
driver.execute_script("document.querySelector('.btn-login').click();")
|
| 43 |
+
time.sleep(10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
# Tenta entrar no mundo
|
| 46 |
+
driver.get(f"https://{MUNDO_ID}.tribalwars.com.br/game.php?screen=main")
|
| 47 |
+
time.sleep(10)
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
while True:
|
| 50 |
+
# Tenta ler o texto bruto da página para ver se pelo menos o nome da aldeia aparece
|
| 51 |
+
corpo = driver.find_element("tag name", "body").text
|
| 52 |
+
|
| 53 |
+
if "Madeira" in corpo or "Wood" in corpo:
|
| 54 |
+
log("CONSEGUIMOS! Dados visíveis.", "SUCESSO")
|
| 55 |
+
# Aqui o bot continuaria com a lógica de construção...
|
| 56 |
+
# (Simplificado para teste de visão)
|
| 57 |
+
mad = driver.execute_script("return document.getElementById('wood').innerText")
|
| 58 |
+
log(f"Recursos detetados: {mad}", "AUDIT")
|
| 59 |
+
else:
|
| 60 |
+
log("Servidor bloqueou a visão dos dados. Anti-bot ativo.", "ALERTA")
|
| 61 |
+
# Se falhar, ele tenta um refresh forçado
|
| 62 |
+
driver.refresh()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
time.sleep(30)
|
|
|
|
| 65 |
|
| 66 |
+
except Exception as e: log(f"Erro: {e}", "ALERTA")
|
| 67 |
+
finally: driver.quit(); display.stop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
if __name__ == "__main__":
|
| 70 |
+
threading.Thread(target=lambda: HTTPServer(('0.0.0.0', 7860), ServidorFalso).serve_forever(), daemon=True).start()
|
| 71 |
iniciar()
|