from flask import Flask, request, jsonify import requests import os import re import textwrap from datetime import datetime from dotenv import load_dotenv load_dotenv() app = Flask(__name__) LICENSES_URL = os.getenv("L") TOOL_URL = os.getenv("TO") LOADER_URL = os.getenv("LOADER_URL", "") LOG_FILE = os.getenv("LOG_FILE", "access.log") CLIENT_KEY = os.getenv("CLIENT_KEY", "client_v1") if not LICENSES_URL or not TOOL_URL: raise ValueError("L and TO env vars required") DEFAULT_VARS = """ C = '' R = '\\x1b[1;31m' G = '\\x1b[1;32m' Y = '\\x1b[1;33m' W = '\\x1b[1;37m' P = '\\x1b[1;35m' B = '\\x1b[1;34m' """ DEFAULT_LOADER_CODE = textwrap.dedent("""\ import subprocess, hashlib, requests, sys, os, tempfile, base64, webbrowser SERVER_URL = base64.b64decode("aHR0cHM6Ly9tLXAwancub25yZW5kZXIuY29tLw==").decode() def get_prop(p): try: return subprocess.run(["getprop", p], capture_output=True, text=True, timeout=3).stdout.strip() except: return "" def generate_fingerprint(): fp1 = get_prop("ro.product.model") fp2 = get_prop("ro.product.board") fp3 = get_prop("ro.build.fingerprint") try: with open("/proc/version") as f: fp4 = f.read().strip() except: fp4 = "" combined = f"{fp1}{fp2}{fp3}{fp4}" return hashlib.sha256(combined.encode()).hexdigest() fp = generate_fingerprint() try: resp = requests.post(f"{SERVER_URL}/get-tool", json={"fingerprint": fp}, timeout=15) except: sys.exit(0) if resp.status_code == 403: # طباعة المفتاح والنصوص مع "Telegram:" print("\033[31m" + "=" * 35 + "\033[0m") print("\033[1;31m DEVICE NOT LICENSED\033[0m") print("\033[1;31m Your Key: " + fp + "\033[0m") print("\033[1;36m Telegram: @VlP_12\033[0m") print("\033[31m" + "=" * 35 + "\033[0m") # فتح التليجرام تلقائياً telegram_url = "https://t.me/VlP_12" try: subprocess.run(["termux-open-url", telegram_url], check=False, timeout=3) except: pass try: subprocess.run(["xdg-open", telegram_url], check=False, timeout=3) except: pass try: webbrowser.open(telegram_url) except: pass elif resp.status_code == 200: tool_code = resp.text try: with tempfile.NamedTemporaryFile(suffix=".py", delete=False, mode="w", encoding="utf-8") as tmp: tmp.write(tool_code) tmp_path = tmp.name subprocess.Popen([sys.executable, tmp_path], stdout=sys.stdout, stderr=sys.stderr, text=True).wait() os.unlink(tmp_path) except: pass """) def fetch_licenses(): try: r = requests.get(LICENSES_URL, timeout=10) r.raise_for_status() return [line.strip() for line in r.text.splitlines() if line.strip()] except: return [] def is_licensed(fp): return fp in fetch_licenses() def fetch_tool_code(): try: r = requests.get(TOOL_URL, timeout=10) r.raise_for_status() code = r.text if re.match(r'^[a-f0-9]{64}$', code.strip()): raise Exception("Fingerprint returned, not code") return code except: return None def get_loader_code(): if LOADER_URL: try: r = requests.get(LOADER_URL, timeout=10) r.raise_for_status() return r.text except: pass return DEFAULT_LOADER_CODE def log_access(fp, status): try: with open(LOG_FILE, "a") as f: f.write(f"{datetime.now()} | {fp} | {status}\n") except: pass @app.errorhandler(Exception) def handle_exception(e): return jsonify({"error": "Internal server error"}), 500 @app.route("/loader", methods=["POST"]) def loader(): data = request.json if not data or data.get("key") != CLIENT_KEY: return jsonify({"error": "unauthorized"}), 403 code = get_loader_code() return code, 200, {"Content-Type": "text/plain; charset=utf-8"} @app.route("/get-tool", methods=["POST"]) def get_tool(): data = request.json if not data or "fingerprint" not in data: return jsonify({"error": "fingerprint required"}), 400 fp = data["fingerprint"] if not is_licensed(fp): log_access(fp, "denied") return jsonify({ "status": "unauthorized", "device_id": fp, "message": "Device not licensed." }), 403 log_access(fp, "authorized") tool_code = fetch_tool_code() if tool_code is None: return jsonify({"error": "Tool not available"}), 500 final_code = DEFAULT_VARS + "\n" + tool_code final_code = final_code.replace('username = input().strip()', 'username = "auto"') final_code = final_code.replace('number = int(input().strip())', 'number = 42') return final_code, 200, {"Content-Type": "text/plain; charset=utf-8"} if __name__ == "__main__": port = int(os.environ.get("PORT", 5000)) app.run(host="0.0.0.0", port=port)