Spaces:
Sleeping
Sleeping
File size: 1,897 Bytes
c071ef5 a79b7fa 5b2ae90 9956223 e31ea21 9956223 e31ea21 9956223 |
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 56 57 58 59 60 61 |
# app.py (FastAPI)
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
import subprocess
app = FastAPI()
class TaskRequest(BaseModel):
team: str
task: str
prompt: str
@app.post("/execute")
def execute_task(req: TaskRequest):
# You can route tasks to different modules here
if req.team == "Red" and req.task == "Exploit":
# Stub: Replace with AI logic or subprocess
output = f"Running red team exploit with prompt: {req.prompt}"
elif req.team == "Blue" and req.task == "Analyze Logs":
# Example: Call AI model or subprocess
output = f"Parsing logs with AI assist: {req.prompt}"
else:
raise HTTPException(status_code=400, detail="Invalid task")
return {"output": output}
def execute_tasks(team: str, task: str, prompt: str):
# You can route tasks to different modules here
if team == "Red" and task == "Exploit":
# Stub: Replace with AI logic or subprocess
output = f"Running red team exploit with prompt: {prompt}"
elif team == "Blue" and task == "Analyze Logs":
# Example: Call AI model or subprocess
output = f"Parsing logs with AI assist: {prompt}"
else:
raise HTTPException(status_code=400, detail="Invalid task")
return {"output": output}
import gradio as gr
import requests
API_BASE = "http://localhost:8000" # Adjust to your FastAPI base URL
def execute_task(team: str, task: str, prompt: str):
return execute_tasks(team, task, prompt)
iface = gr.Interface(
fn=execute_task,
inputs=[
gr.Dropdown(["Red", "Blue"], label="Team"),
gr.Dropdown(["Recon", "Exploit", "Analyze Logs", "Generate Rule"], label="Task"),
gr.Textbox(label="Prompt / Parameters")
],
outputs="text",
title="AI-Driven CyberOps Interface"
)
if __name__ == "__main__":
iface.launch(share=True, debug=True) |