Spaces:
Running

File size: 2,282 Bytes
24ddcb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import gradio as gr
import subprocess
import os
import threading
import spaces

@spaces.GPU
def run_command(cmd):
    try:
        cmd_str = cmd.strip()

        # أمر خاص لعرض السجلات الحية خلف الكواليس
        if cmd_str == "logs":
            if os.path.exists("hunter_output.log"):
                with open("hunter_output.log", "r") as f:
                    lines = f.readlines()
                return "".join(lines[-30:]) # آخر 30 سطر
            else:
                return "[-] No logs found yet. Make sure the hunter script is running."

        # أمر لعرض العمليات النشطة
        if cmd_str == "status":
            result = subprocess.run("ps aux | grep python", shell=True, capture_output=True, text=True)
            return f"Active Python Processes:\n{result.stdout}"

        if "run_hunter_cloud.py" in cmd_str or "python" in cmd_str:
            process = subprocess.Popen(cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
            return f"[+] Background hunting engine launched successfully! (PID: {process.pid})\nType 'logs' in command box to see real-time progress."

        result = subprocess.run(cmd_str, shell=True, capture_output=True, text=True, timeout=15)
        return f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"
    except Exception as e:
        return f"Error: {str(e)}"

def start_background_task():
    os.system("echo '[*] Linko Sovereign Agent Online' > agent_log.txt")

threading.Thread(target=start_background_task, daemon=True).start()

def agent_interface(command):
    if not command.strip():
        return "Linko Sovereign Agent is ACTIVE. Type 'logs' or 'status' to monitor background workers."
    return run_command(command)

demo = gr.Interface(
    fn=agent_interface,
    inputs=gr.Textbox(label="Remote Command (Bash / Python / logs / status)", placeholder="e.g. logs"),
    outputs=gr.Textbox(label="Execution Output"),
    title="🤖 Linko Sovereign Cloud Agent",
    description="Remote execution node controlled by Linko Sovereign core. Type 'logs' to see live hunting speed."
)

if __name__ == "__main__":
    demo.launch(server_name="0.0.0.0", server_port=7860)