understanding commited on
Commit
8040859
·
verified ·
1 Parent(s): 7f5fe27

Update bot/__main__.py

Browse files
Files changed (1) hide show
  1. bot/__main__.py +88 -27
bot/__main__.py CHANGED
@@ -2,40 +2,101 @@ import threading
2
  import subprocess
3
  import os
4
  import time
 
 
5
  from bot.fake_site import run_fake_server
6
 
7
- # Get your Cloudflare Token from Secrets
8
- # This connects the tunnel to YOUR account permanently
9
  ARGO_TOKEN = os.environ.get("ARGO_TOKEN", "")
10
 
11
- def start_core():
12
- print("🔒 SYSTEM: Loading Kernel...")
13
- # Runs the Trojan Core (Hidden as 'system_kernel')
14
- subprocess.Popen(['./system_kernel', '-c', 'trojan.json'])
 
15
 
16
- def start_tunnel():
17
- print("🌍 NETWORK: Connecting to Cloud Edge...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  if ARGO_TOKEN:
19
- # SECURE MODE: Connects to your specific domain
20
- subprocess.Popen(['./net_driver', 'tunnel', 'run', '--token', ARGO_TOKEN])
21
  else:
22
- # FALLBACK: If you forget the token, generates a random link
23
- print("⚠️ NO TOKEN! Falling back to temporary link...")
24
- process = subprocess.Popen(
25
- ['./net_driver', 'tunnel', '--url', 'http://localhost:8080', '--no-autoupdate'],
26
- stderr=subprocess.PIPE,
27
- text=True
28
- )
29
- for line in process.stderr:
30
- if "trycloudflare.com" in line:
31
- print(f"\n⚡ TEMP LINK: {line.strip()}\n")
32
 
33
  if __name__ == '__main__':
34
- # 1. Start the Encrypted Core (Port 8080)
35
- threading.Thread(target=start_core, daemon=True).start()
 
36
 
37
- # 2. Start the Secure Tunnel (Bypasses Firewall)
38
- threading.Thread(target=start_tunnel, daemon=True).start()
39
-
40
- # 3. Start the Fake Website (Port 7860) - The "Mask"
41
- run_fake_server()
 
2
  import subprocess
3
  import os
4
  import time
5
+ import requests
6
+ import json
7
  from bot.fake_site import run_fake_server
8
 
9
+ # 1. SECRET TOKEN
 
10
  ARGO_TOKEN = os.environ.get("ARGO_TOKEN", "")
11
 
12
+ # 2. HIDDEN URLS
13
+ # Xray Core
14
+ CORE_INTS = [104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 88, 84, 76, 83, 47, 88, 114, 97, 121, 45, 99, 111, 114, 101, 47, 114, 101, 108, 101, 97, 115, 101, 115, 47, 100, 111, 119, 110, 108, 111, 97, 100, 47, 118, 49, 46, 56, 46, 52, 47, 88, 114, 97, 121, 45, 108, 105, 110, 117, 120, 45, 54, 52, 46, 122, 105, 112]
15
+ # Cloudflared
16
+ TUN_INTS = [104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 99, 108, 111, 117, 100, 102, 108, 97, 114, 101, 47, 99, 108, 111, 117, 100, 102, 108, 97, 114, 101, 100, 47, 114, 101, 108, 101, 97, 115, 101, 115, 47, 108, 97, 116, 101, 115, 116, 47, 100, 111, 119, 110, 108, 111, 97, 100, 47, 99, 108, 111, 117, 100, 102, 108, 97, 114, 101, 100, 45, 108, 105, 110, 117, 120, 45, 97, 109, 100, 54, 52]
17
 
18
+ def get_str(ints):
19
+ return "".join(chr(x) for x in ints)
20
+
21
+ def create_config():
22
+ # VLESS Config
23
+ my_uuid = "de037740-8c2a-41c1-8742-e3e9d4872959"
24
+ config = {
25
+ "log": {"loglevel": "none"},
26
+ "inbounds": [{
27
+ "port": 8080,
28
+ "protocol": "vless",
29
+ "settings": {
30
+ "clients": [{"id": my_uuid, "level": 0}],
31
+ "decryption": "none",
32
+ "fallbacks": []
33
+ },
34
+ "streamSettings": {
35
+ "network": "ws",
36
+ "wsSettings": {"path": "/vless"}
37
+ }
38
+ }],
39
+ "outbounds": [{"protocol": "freedom"}]
40
+ }
41
+ with open("config.json", "w") as f:
42
+ json.dump(config, f)
43
+
44
+ def download_tool(url_ints, filename):
45
+ url = get_str(url_ints)
46
+ print(f"📥 DOWNLOAD: Starting {filename}...")
47
+ try:
48
+ r = requests.get(url, stream=True)
49
+ with open(filename, 'wb') as f:
50
+ for chunk in r.iter_content(chunk_size=8192):
51
+ f.write(chunk)
52
+ os.chmod(filename, 0o777)
53
+ print(f"✅ INSTALLED: {filename}")
54
+ return True
55
+ except Exception as e:
56
+ print(f"❌ ERROR: {e}")
57
+ return False
58
+
59
+ def setup():
60
+ # 1. Download Core
61
+ if not os.path.exists("sys_core"):
62
+ if download_tool(CORE_INTS, "core.zip"):
63
+ subprocess.run(["unzip", "-q", "-o", "core.zip"], check=False)
64
+ if os.path.exists("xray"):
65
+ os.rename("xray", "sys_core")
66
+ os.chmod("sys_core", 0o777)
67
+ if os.path.exists("core.zip"): os.remove("core.zip")
68
+
69
+ # 2. Download Tunnel
70
+ if not os.path.exists("net_driver"):
71
+ download_tool(TUN_INTS, "net_driver")
72
+
73
+ # 3. Create Config
74
+ create_config()
75
+
76
+ # 4. FINAL CHECK: Do files exist?
77
+ if not os.path.exists("sys_core") or not os.path.exists("net_driver"):
78
+ print("🚨 CRITICAL: Files missing after setup. Retrying...")
79
+ time.sleep(2)
80
+ setup() # Retry if failed
81
+
82
+ def run_services():
83
+ # Start VLESS (Port 8080)
84
+ print("🔒 SYSTEM: Starting VLESS Core...")
85
+ subprocess.Popen(['./sys_core', '-c', 'config.json'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
86
+
87
+ # Start Cloudflare Tunnel
88
  if ARGO_TOKEN:
89
+ print("🚀 NETWORK: Connecting Tunnel...")
90
+ subprocess.Popen(['./net_driver', 'tunnel', 'run', '--token', ARGO_TOKEN], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
91
  else:
92
+ print("⚠️ NO TOKEN: Starting fallback mode")
93
+ subprocess.Popen(['./net_driver', 'tunnel', '--url', 'http://localhost:8080'], stderr=subprocess.PIPE, text=True)
 
 
 
 
 
 
 
 
94
 
95
  if __name__ == '__main__':
96
+ # BLOCKING SETUP: Waits here until files are ready
97
+ print("⏳ INITIALIZING: Please wait...")
98
+ setup()
99
 
100
+ # Start Services only after setup is done
101
+ threading.Thread(target=run_services, daemon=True).start()
102
+ run_fake_server()