torn-bot / main.py
Erinaldordso's picture
Update main.py
fc5aeb7 verified
Raw History Blame Contribute Delete
7.75 kB
import time
import random
import threading
import json
import urllib.request
from datetime import datetime
from http.server import BaseHTTPRequestHandler, HTTPServer
from seleniumbase import Driver
from selenium.webdriver.common.by import By
from pyvirtualdisplay import Display
# --- 🍪 SEQUESTRO DE SESSÃO (v10.1) ---
# Atualizado com o valor da tua captura de ecrã do Kiwi Browser
RAW_COOKIE = "PHPSESSID=1d24f3002c5873679b29fbc1f58f1418"
# 🎯 PRIORIDADES DE TRABALHO
SKILLS_PRIORIDADE = ["Mining", "Logging", "Fishing", "Gathering"]
# --- 📱 TELEGRAM CONFIG ---
TELEGRAM_TOKEN = "8762853869:AAEERuQL6jIU4n3rR9Seba0XrzS2CiMa6cQ"
TELEGRAM_CHAT_ID = "7677821729"
def enviar_telegram(mensagem):
try:
url = f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage"
payload = json.dumps({'chat_id': TELEGRAM_CHAT_ID, 'text': mensagem, 'parse_mode': 'Markdown'}).encode('utf-8')
req = urllib.request.Request(url, data=payload, headers={'Content-Type': 'application/json'})
urllib.request.urlopen(req)
except: pass
def log(acao, status="INFO", notificar=False):
agora = datetime.now().strftime("%H:%M:%S")
icons = {"STATUS": "📊", "LOGIN": "🔑", "FARM": "⛏️", "VENDA": "💰", "BANCO": "🏦", "COMBATE": "⚔️", "CURA": "❤️", "LEVEL": "🌟", "ALERTA": "⚠️", "SUCESSO": "✅", "MUDANCA": "🔄", "HACK": "🏴‍☠️"}
icone = icons.get(status, 'ℹ️')
print(f"[{agora}] [{icone}] {acao}", flush=True)
if notificar: enviar_telegram(f"{icone} {acao}")
class ServidorFalso(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200); self.end_headers()
self.wfile.write(b"Bot Drakor v10.1 - Session Injection")
def log_message(self, format, *args): pass
# Variáveis Globais
ultima_acao = time.time()
hora_inicio_sistema = time.time()
ultimo_relatorio = time.time()
niveis_ganhos = 0
vendas_realizadas = 0
def reset_watchdog():
global ultima_acao
ultima_acao = time.time()
def realizar_login_via_cookie(driver):
log("Iniciando bypass de segurança via Injeção de Cookie...", "HACK")
# 1. Abre a página inicial para carregar o domínio
driver.get("https://www.drakor.com/")
time.sleep(5)
try:
# 2. Limpa cookies antigos para evitar conflitos
driver.delete_all_cookies()
# 3. Injeta o novo Cookie do Comandante
nome, valor = RAW_COOKIE.split('=', 1)
driver.add_cookie({
'name': nome,
'value': valor,
'domain': '.drakor.com', # Ponto antes do domínio para abranger subdomínios
'path': '/',
})
log("Chave-mestra injetada! Forçando entrada...", "SUCESSO")
# 4. Acede diretamente à área de trabalho
driver.get("https://www.drakor.com/tradeskills")
time.sleep(7)
if "Logout" in driver.page_source or "Profile" in driver.page_source:
log("Sessão validada! Bot online e operante.", "SUCESSO", notificar=True)
return True
log("O servidor rejeitou o Cookie (Provável bloqueio de IP do Datacenter).", "ALERTA")
return False
except Exception as e:
log(f"Erro na injeção: {str(e)[:40]}", "ALERTA")
return False
def enviar_relatorio_performance():
global ultimo_relatorio, niveis_ganhos, vendas_realizadas, hora_inicio_sistema
tempo_online = int((time.time() - hora_inicio_sistema) // 3600)
relatorio = (
f"📈 *RELATÓRIO DE PERFORMANCE*\n\n"
f"⏱️ **Online:** {tempo_online}h\n"
f"🌟 **Níveis:** +{niveis_ganhos}\n"
f"💰 **Banco:** {vendas_realizadas} depósitos\n"
f"🤖 **Status:** Ativo 24/7"
)
enviar_telegram(relatorio)
ultimo_relatorio = time.time()
def gerir_economia_e_banco(driver):
global vendas_realizadas
log("Mochila cheia! Iniciando ciclo financeiro...", "VENDA")
driver.get("https://www.drakor.com/sell")
time.sleep(5)
driver.execute_script("var b = document.querySelector('button:contains(\"Sell All Materials\")'); if(b) b.click();")
time.sleep(3)
driver.get("https://www.drakor.com/bank")
time.sleep(4)
if driver.execute_script("var b = document.querySelector('button:contains(\"Deposit All\")'); if(b){ b.click(); return true; } return false;"):
log("Ouro guardado no cofre!", "BANCO", notificar=True)
vendas_realizadas += 1
driver.get("https://www.drakor.com/tradeskills")
def executar_farm(driver):
global ultima_acao, niveis_ganhos, ultimo_relatorio
html = driver.page_source
if time.time() - ultimo_relatorio > 3600: enviar_relatorio_performance()
# Proteção de Página Presa
if time.time() - ultima_acao > 240:
log("Watchdog: Página inativa. Refreshing...", "ALERTA")
driver.refresh()
reset_watchdog()
return
# Captcha / Anti-Bot
if "Pattern Match" in html or "Verification" in html:
log("CAPTCHA! Pausa de segurança ativada.", "ALERTA", notificar=True)
time.sleep(300)
driver.refresh()
return
# Combate / Vitória
if "Encounter" in html or "Attack" in html or "Collect Loot" in html:
if "Collect Loot" in html:
driver.execute_script("var b = document.querySelector('.lootBtn'); if(b) b.click();")
log("Vitória e Loot!", "💰", notificar=True)
time.sleep(3)
driver.get("https://www.drakor.com/tradeskills")
else:
driver.execute_script("var a = document.querySelector('.attackBtn'); if(a) a.click();")
reset_watchdog()
return
if "Inventory Full" in html or "Bag Full" in html:
gerir_economia_e_banco(driver)
return
try:
# Verifica se está em progresso
if driver.execute_script("var b = document.querySelector('.progressBarActive'); return (b && b.style.display !== 'none');"):
time.sleep(2)
return
# Tenta clicar na ação principal
clicou = driver.execute_script("""
var b = document.querySelector('.actionBtn, .btn-action');
if (b && !b.disabled && b.style.display !== 'none') { b.click(); return true; }
return false;
""")
if clicou:
reset_watchdog()
time.sleep(3)
return
# Se nada aconteceu, troca de nó
driver.get("https://www.drakor.com/tradeskills")
time.sleep(5)
for skill in SKILLS_PRIORIDADE:
if driver.execute_script(f"var l = Array.from(document.querySelectorAll('a[href*=\"/skill/\"]')).filter(i=>i.innerText.includes('{skill}') && !i.innerText.includes('Depleted')); if(l.length>0){{ l[l.length-1].click(); return true; }} return false;"):
log(f"Nova rota: {skill}", "MUDANCA", notificar=True)
reset_watchdog()
time.sleep(5)
return
except: time.sleep(2)
def iniciar():
display = Display(visible=0, size=(1024, 768)); display.start()
driver = Driver(uc=True, headless=False)
reset_watchdog()
try:
while True:
if realizar_login_via_cookie(driver):
while True:
executar_farm(driver)
time.sleep(1)
else:
log("Aguardando novo cookie do Comandante...", "ALERTA")
time.sleep(600)
except Exception as e: log(f"Erro: {e}", "ALERTA")
finally: driver.quit(); display.stop()
if __name__ == "__main__":
threading.Thread(target=lambda: HTTPServer(('0.0.0.0', 7860), ServidorFalso).serve_forever(), daemon=True).start()
iniciar()