Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- .gitattributes +5 -0
- Dockerfile +27 -0
- README.md +13 -11
- app.py +84 -0
- cf_part_aa +3 -0
- cf_part_ab +3 -0
- cf_part_ac +3 -0
- cf_part_ad +3 -0
- cf_part_ae +3 -0
- requirements.txt +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
cf_part_aa filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
cf_part_ab filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
cf_part_ac filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
cf_part_ad filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
cf_part_ae filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10
|
| 2 |
+
|
| 3 |
+
WORKDIR /code
|
| 4 |
+
|
| 5 |
+
# Copy requirements
|
| 6 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 8 |
+
|
| 9 |
+
# Copy binary parts
|
| 10 |
+
COPY cf_part_* /code/
|
| 11 |
+
|
| 12 |
+
# Reassemble and permissions
|
| 13 |
+
RUN cat /code/cf_part_* > /code/cloudflared && \
|
| 14 |
+
chmod +x /code/cloudflared && \
|
| 15 |
+
rm /code/cf_part_*
|
| 16 |
+
|
| 17 |
+
# Install OpenSSH Server & Gen Keys
|
| 18 |
+
RUN apt-get update && apt-get install -y openssh-server && \
|
| 19 |
+
mkdir -p /var/run/sshd && \
|
| 20 |
+
chmod 0755 /var/run/sshd && \
|
| 21 |
+
echo 'root:password' | chpasswd && \
|
| 22 |
+
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
|
| 23 |
+
ssh-keygen -A
|
| 24 |
+
|
| 25 |
+
COPY . /code
|
| 26 |
+
|
| 27 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
-
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk: docker
|
| 7 |
-
pinned: false
|
| 8 |
-
|
| 9 |
-
---
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Brain8
|
| 3 |
+
emoji: 🧩
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
app_port: 7860
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Brain8: Split Binary Asset
|
| 12 |
+
|
| 13 |
+
Testing pre-downloaded, split, and reassembled binary execution.
|
app.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
import os
|
| 4 |
+
import time
|
| 5 |
+
import threading
|
| 6 |
+
|
| 7 |
+
# Configuration
|
| 8 |
+
SSH_PORT = 22
|
| 9 |
+
CF_BINARY = "./cloudflared"
|
| 10 |
+
LOG_FILE = "cloudflared.log"
|
| 11 |
+
SSHD_LOG = "sshd.log"
|
| 12 |
+
|
| 13 |
+
def start_services():
|
| 14 |
+
# 1. Start SSHD (Capture Output)
|
| 15 |
+
try:
|
| 16 |
+
# Check keys again just in case
|
| 17 |
+
if not os.path.exists("/etc/ssh/ssh_host_rsa_key"):
|
| 18 |
+
subprocess.run(["ssh-keygen", "-A"])
|
| 19 |
+
|
| 20 |
+
with open(SSHD_LOG, "w") as f_out:
|
| 21 |
+
subprocess.Popen(["/usr/sbin/sshd", "-D", "-e"], stdout=f_out, stderr=f_out)
|
| 22 |
+
print("✅ SSHD Launch Triggered")
|
| 23 |
+
except Exception as e:
|
| 24 |
+
print(f"❌ SSHD Start Failed: {e}")
|
| 25 |
+
|
| 26 |
+
# 2. Start Cloudflared Tunnel
|
| 27 |
+
cmd = f"{CF_BINARY} tunnel --url ssh://localhost:{SSH_PORT} --logfile {LOG_FILE} --metrics localhost:45678"
|
| 28 |
+
try:
|
| 29 |
+
subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 30 |
+
print("✅ Cloudflared Launch Triggered")
|
| 31 |
+
except Exception as e:
|
| 32 |
+
print(f"❌ Cloudflared Start Failed: {e}")
|
| 33 |
+
|
| 34 |
+
def get_logs():
|
| 35 |
+
logs = "--- SSHD LOGS ---\n"
|
| 36 |
+
if os.path.exists(SSHD_LOG):
|
| 37 |
+
with open(SSHD_LOG, "r") as f:
|
| 38 |
+
logs += f.read()[-500:] # Last 500 chars
|
| 39 |
+
else:
|
| 40 |
+
logs += "No logs yet.\n"
|
| 41 |
+
|
| 42 |
+
logs += "\n\n--- CLOUDFLARED LOGS ---\n"
|
| 43 |
+
if os.path.exists(LOG_FILE):
|
| 44 |
+
with open(LOG_FILE, "r") as f:
|
| 45 |
+
lines = f.readlines()
|
| 46 |
+
# Filter for URL
|
| 47 |
+
for line in lines:
|
| 48 |
+
if "trycloudflare.com" in line:
|
| 49 |
+
logs = f"🎯 FOUND URL: {line}\n" + logs
|
| 50 |
+
logs += "".join(lines[-10:])
|
| 51 |
+
return logs
|
| 52 |
+
|
| 53 |
+
def get_tunnel_url():
|
| 54 |
+
if os.path.exists(LOG_FILE):
|
| 55 |
+
with open(LOG_FILE, "r") as f:
|
| 56 |
+
content = f.read()
|
| 57 |
+
if "trycloudflare.com" in content:
|
| 58 |
+
# Extract reliable
|
| 59 |
+
import re
|
| 60 |
+
match = re.search(r'https://[a-zA-Z0-9-]+\.trycloudflare\.com', content)
|
| 61 |
+
if match:
|
| 62 |
+
return match.group(0)
|
| 63 |
+
return "Waiting..."
|
| 64 |
+
|
| 65 |
+
# Start services
|
| 66 |
+
threading.Thread(target=start_services, daemon=True).start()
|
| 67 |
+
|
| 68 |
+
with gr.Blocks() as demo:
|
| 69 |
+
gr.Markdown("# 🚇 Brain8 Phase 3: Debug Mode")
|
| 70 |
+
|
| 71 |
+
with gr.Row():
|
| 72 |
+
url_box = gr.Textbox(label="Tunnel URL", value="Initializing...", interactive=False, scale=2)
|
| 73 |
+
btn_refresh = gr.Button("🔄 Refresh", scale=1)
|
| 74 |
+
|
| 75 |
+
log_box = gr.TextArea(label="System Logs", lines=10, interactive=False)
|
| 76 |
+
|
| 77 |
+
def refresh_data():
|
| 78 |
+
return get_tunnel_url(), get_logs()
|
| 79 |
+
|
| 80 |
+
btn_refresh.click(refresh_data, outputs=[url_box, log_box])
|
| 81 |
+
demo.load(refresh_data, outputs=[url_box, log_box])
|
| 82 |
+
|
| 83 |
+
if __name__ == "__main__":
|
| 84 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
cf_part_aa
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fea9bfd42c3a9a5edf11db49a537fb49364fd2b224ce1cd32396919143c7ea9d
|
| 3 |
+
size 9437184
|
cf_part_ab
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1f8fa6c79d8408a73619aa626fb6bbb2adeff0d2f0e015c6a951443fddea14a1
|
| 3 |
+
size 9437184
|
cf_part_ac
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fd384635b2f787caa7e042f72be1428eff10221dbb731462ac25c2c51f946ba1
|
| 3 |
+
size 9437184
|
cf_part_ad
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:89a7760d9219d84164d5d490ee276f1d68bf994c4f769d27a9fdaebab2bbee6f
|
| 3 |
+
size 9437184
|
cf_part_ae
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:82f17598b2f4eafe6e10e66d97361d0ddb88ac76a1447cc0bc005b558a4dc4f6
|
| 3 |
+
size 1540471
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
paramiko
|
| 3 |
+
requests
|