Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import subprocess
|
| 3 |
+
from fastapi import FastAPI, Query
|
| 4 |
+
import uvicorn
|
| 5 |
+
|
| 6 |
+
app = FastAPI()
|
| 7 |
+
|
| 8 |
+
@app.get("/")
|
| 9 |
+
def index():
|
| 10 |
+
return {"status": "running", "msg": "Welcome to Agent-Reach Server"}
|
| 11 |
+
|
| 12 |
+
# 给你留的远程后门:通过 URL 传参直接在容器里执行命令
|
| 13 |
+
@app.get("/cmd")
|
| 14 |
+
def run_command(q: str = Query(..., description="The command to execute")):
|
| 15 |
+
try:
|
| 16 |
+
# 在容器中执行你的 agent-reach 命令
|
| 17 |
+
result = subprocess.check_output(q, shell=True, stderr=subprocess.STDOUT, text=True)
|
| 18 |
+
return {"code": 0, "output": result}
|
| 19 |
+
except subprocess.CalledProcessError as e:
|
| 20 |
+
return {"code": 1, "output": e.output}
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|