Spaces:
Configuration error
Configuration error
Update blackgat/app/ai_modules.py
Browse files- blackgat/app/ai_modules.py +7 -14
blackgat/app/ai_modules.py
CHANGED
|
@@ -1,15 +1,13 @@
|
|
| 1 |
-
# ai_models.py
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
|
| 6 |
-
HF_API_TOKEN = os.getenv("HF_API_TOKEN")
|
| 7 |
if not HF_API_TOKEN:
|
| 8 |
-
raise RuntimeError("
|
| 9 |
|
| 10 |
HEADERS = {"Authorization": f"Bearer {HF_API_TOKEN}"}
|
| 11 |
|
| 12 |
-
# Unified LLM interface for all agents
|
| 13 |
def query_huggingface(prompt, model_id, max_tokens=150):
|
| 14 |
url = f"https://api-inference.huggingface.co/models/{model_id}"
|
| 15 |
payload = {
|
|
@@ -27,21 +25,18 @@ def query_huggingface(prompt, model_id, max_tokens=150):
|
|
| 27 |
except requests.exceptions.RequestException as e:
|
| 28 |
return f"[ERROR] API call failed: {str(e)}"
|
| 29 |
|
| 30 |
-
# AI Agent: Scribe
|
| 31 |
def scribe_generate(data):
|
| 32 |
prompt = f"""Write a professional bug bounty report.
|
| 33 |
Vulnerability: {data['type']}
|
| 34 |
URL: {data['url']}
|
| 35 |
Payload: {data['payload']}
|
| 36 |
Impact: {data['impact']}"""
|
| 37 |
-
return {"report": query_huggingface(prompt,
|
| 38 |
|
| 39 |
-
# AI Agent: KillChain
|
| 40 |
def killchain_ai(data):
|
| 41 |
prompt = f"Suggest a chained attack path using these findings: {data}"
|
| 42 |
-
return {"chain": query_huggingface(prompt,
|
| 43 |
|
| 44 |
-
# Agent: HeatSeeker (local logic)
|
| 45 |
def heatseeker_score(data):
|
| 46 |
score = 0
|
| 47 |
if "admin" in data['url']: score += 3
|
|
@@ -49,11 +44,9 @@ def heatseeker_score(data):
|
|
| 49 |
if data['status_code'] == 500: score += 5
|
| 50 |
return {"score": score}
|
| 51 |
|
| 52 |
-
# AI Agent: ReconGPT
|
| 53 |
def recon_gpt(prompt):
|
| 54 |
-
return {"task": query_huggingface(prompt,
|
| 55 |
|
| 56 |
-
# AI Agent: Exploit Simulation
|
| 57 |
def exploit_suggestion(data):
|
| 58 |
prompt = f"Given this bug bounty scenario, how might an attacker exploit it? {data}"
|
| 59 |
-
return {"exploit": query_huggingface(prompt,
|
|
|
|
| 1 |
+
# app/ai_models.py
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
HF_API_TOKEN = os.getenv("BlackGat_AI")
|
|
|
|
| 6 |
if not HF_API_TOKEN:
|
| 7 |
+
raise RuntimeError("BlackGat_AI token not set. Please add it as a Hugging Face Space secret.")
|
| 8 |
|
| 9 |
HEADERS = {"Authorization": f"Bearer {HF_API_TOKEN}"}
|
| 10 |
|
|
|
|
| 11 |
def query_huggingface(prompt, model_id, max_tokens=150):
|
| 12 |
url = f"https://api-inference.huggingface.co/models/{model_id}"
|
| 13 |
payload = {
|
|
|
|
| 25 |
except requests.exceptions.RequestException as e:
|
| 26 |
return f"[ERROR] API call failed: {str(e)}"
|
| 27 |
|
|
|
|
| 28 |
def scribe_generate(data):
|
| 29 |
prompt = f"""Write a professional bug bounty report.
|
| 30 |
Vulnerability: {data['type']}
|
| 31 |
URL: {data['url']}
|
| 32 |
Payload: {data['payload']}
|
| 33 |
Impact: {data['impact']}"""
|
| 34 |
+
return {"report": query_huggingface(prompt, "schoolkithub/cyberbase", 200)}
|
| 35 |
|
|
|
|
| 36 |
def killchain_ai(data):
|
| 37 |
prompt = f"Suggest a chained attack path using these findings: {data}"
|
| 38 |
+
return {"chain": query_huggingface(prompt, "schoolkithub/primus")}
|
| 39 |
|
|
|
|
| 40 |
def heatseeker_score(data):
|
| 41 |
score = 0
|
| 42 |
if "admin" in data['url']: score += 3
|
|
|
|
| 44 |
if data['status_code'] == 500: score += 5
|
| 45 |
return {"score": score}
|
| 46 |
|
|
|
|
| 47 |
def recon_gpt(prompt):
|
| 48 |
+
return {"task": query_huggingface(prompt, "schoolkithub/neox")}
|
| 49 |
|
|
|
|
| 50 |
def exploit_suggestion(data):
|
| 51 |
prompt = f"Given this bug bounty scenario, how might an attacker exploit it? {data}"
|
| 52 |
+
return {"exploit": query_huggingface(prompt, "schoolkithub/hackphyr")}
|