import subprocess import sys import os import time import random import string import threading NPM_PATH = r"C:\Program Files\nodejs\npm.cmd" # ===== Check Dependencies ===== def check_and_install(): try: import javascript except ImportError: print("[*] Installing javascript package...") subprocess.check_call([sys.executable, "-m", "pip", "install", "javascript"]) # Check for npm if subprocess.call([NPM_PATH, "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) != 0: print("[!] npm not found - Please install Node.js from https://nodejs.org first") sys.exit(1) # Install mineflayer if missing node_modules = os.path.join(os.path.dirname(__file__), "node_modules", "mineflayer") if not os.path.exists(node_modules): print("[*] Installing mineflayer...") subprocess.check_call([NPM_PATH, "install", "mineflayer"], cwd=os.path.dirname(__file__) or ".") check_and_install() # ===== JS Template for each bot ===== JS_TEMPLATE = """ const mineflayer = require('mineflayer'); const botName = process.argv[2]; const host = process.argv[3]; const port = parseInt(process.argv[4]); const loginDelay = parseInt(process.argv[5]) * 1000; const password = '123456'; const bot = mineflayer.createBot({ host: host, port: port, username: botName, version: false, auth: 'offline' }); bot.once('spawn', () => { console.log(`[${botName}] Joined the server`); setTimeout(() => { bot.chat('/register ' + password + ' ' + password); console.log(`[${botName}] Sent /register`); }, 1000); setTimeout(() => { bot.chat('/login ' + password); console.log(`[${botName}] Sent /login`); }, loginDelay + 1000); setTimeout(() => { bot.chat('TEAM CB7 ON TOP!'); console.log(`[${botName}] Chat: skibidi`); }, loginDelay + 2500); setTimeout(() => { bot.quit('done'); console.log(`[${botName}] Left the server`); process.exit(0); }, loginDelay + 4000); }); bot.on('error', (err) => { console.log(`[${botName}] Error: ${err.message}`); process.exit(1); }); bot.on('kicked', (reason) => { console.log(`[${botName}] Kicked: ${reason}`); process.exit(0); }); """ def random_name(length=8): prefix = "CB7_TEAM_ON_TOP_" chars = string.ascii_letters + string.digits return prefix + ''.join(random.choices(chars, k=length)) def run_bot(name, host, port, login_delay): js_file = f"_bot_{name}.js" with open(js_file, "w", encoding="utf-8") as f: f.write(JS_TEMPLATE) proc = subprocess.Popen( ["node", js_file, name, host, str(port), str(login_delay)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, encoding="utf-8", errors="replace" ) def stream_output(): for line in proc.stdout: print(line, end="") proc.wait() try: os.remove(js_file) except: pass t = threading.Thread(target=stream_output, daemon=True) t.start() return proc, t def main(): print("=" * 50) print(" Minecraft Auth Bot Tester") print(" (For self-server testing only)") print("=" * 50) print() host = input("Server IP (e.g., localhost): ").strip() or "localhost" port = input("Port (Press Enter for 25565): ").strip() port = int(port) if port else 25565 bot_count = int(input("Number of bots: ").strip()) login_delay = float(input("Delay before /login (seconds, e.g., 3 or 0.5): ").strip()) cycles = int(input("Number of cycles to run: ").strip()) print() print(f"[*] Running {bot_count} bots x {cycles} cycles on {host}:{port}") print(f"[*] Login delay: {login_delay} seconds") input("Press Enter to start...") print() for cycle in range(1, cycles + 1): print(f"\n{'='*40}") print(f" Cycle {cycle}/{cycles}") print(f"{'='*40}") names = [random_name() for _ in range(bot_count)] procs = [] for name in names: print(f"[*] Starting bot: {name}") proc, thread = run_bot(name, host, port, login_delay) procs.append((proc, thread)) time.sleep(0.3) for proc, thread in procs: thread.join(timeout=login_delay + 10) if cycle < cycles: print(f"\n[*] Cycle {cycle} complete. Waiting 1 second before next cycle...") time.sleep(1) print("\n[✓] All cycles finished!") if __name__ == "__main__": main()