File size: 737 Bytes
bb05849
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import subprocess
from fastapi import FastAPI, Query
import uvicorn

app = FastAPI()

@app.get("/")
def index():
    return {"status": "running", "msg": "Welcome to Agent-Reach Server"}

# 给你留的远程后门:通过 URL 传参直接在容器里执行命令
@app.get("/cmd")
def run_command(q: str = Query(..., description="The command to execute")):
    try:
        # 在容器中执行你的 agent-reach 命令
        result = subprocess.check_output(q, shell=True, stderr=subprocess.STDOUT, text=True)
        return {"code": 0, "output": result}
    except subprocess.CalledProcessError as e:
        return {"code": 1, "output": e.output}

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=7860)