对于蓝队/恶意软件分析师,您可以将 ChatGPT 的 API 直接连接到 Cuckoo Sandbox API。这样,对于您从 Cuckoo 沙盒获得的每份报告,ChatGPT 都会为您解释结果。
ChatGPT 确实最适合解释和阅读代码。它可以翻译、转录、修订和合并文本。因此,它非常擅长理解任何用户知识水平的输出。
随后,我认为蓝队和恶意软件分析师可以从分析和自动化他们的恶意软件分析中受益最大。
在这种情况下,我要求 ChatGPT 编写一个 python 脚本,将恶意软件分析工具 Cuckoo Sandbox 与 ChatGPT API 链接起来。(Cuckoo Sandbox是一个用于自动恶意软件分析的开源工具。

此外,在此提示中,我希望 ChatGPT 在三个级别上解释恶意软件正在做什么:
- level_0_prompt =“请提供对恶意软件行为的板级非技术解释。
- level_1_prompt =“请提供恶意软件行为的技术解释,但要用非网络安全专家的术语。
- level_2_prompt =“请向恶意软件分析专业人员提供恶意软件行为的技术解释。
level_0_prompt = "Please provide a board-level, non-technical interpretation of the malware behavior."
level_1_prompt = "Please provide a technical interpretation of the malware behavior, but in non-cybersecurity expert terms."
level_2_prompt = "Please provide a technical interpretation of the malware behavior to a malware analysis professional."

ChatGPT 编写了一个合理的脚本,可能需要一些编辑。但总的来说,我认为它相对较好。
import requests
import json
import openai_secret_manager
# Set up API keys
cuckoo_api_key = openai_secret_manager.get_secret("cuckoo_api_key")["api_key"]
openai_api_key = openai_secret_manager.get_secret("openai_api_key")["api_key"]
# Set up API endpoints
cuckoo_api_endpoint = "http://<your_cuckoo_sandbox_server_ip>/cuckoo/api"
cuckoo_report_endpoint = cuckoo_api_endpoint + "/tasks/report/{task_id}"
openai_api_endpoint = "https://api.openai.com/v1/engines/davinci-codex/completions"
之后,您需要 # 定义解释的三个级别(见上文块)。
脚本中的下一步:
# Define a function to retrieve the Cuckoo Sandbox report
def get_cuckoo_report(task_id):
headers = {"Authorization": "Bearer " + cuckoo_api_key}
url = cuckoo_report_endpoint.format(task_id=task_id)
response = requests.get(url, headers=headers)
return response.json()
# Define a function to generate a report using ChatGPT
def generate_report(prompt):
headers = {"Content-Type": "application/json", "Authorization": "Bearer " + openai_api_key}
data = {
"prompt": prompt,
"temperature": 0.5,
"max_tokens": 256,
"stop": "\n"
}
response = requests.post(openai_api_endpoint, headers=headers, data=json.dumps(data))
return response.json()["choices"][0]["text"].strip()
最后,您需要定义两个 API 的主要功能,以便它们正确协同工作。
# Define the main function to connect the two APIs
def analyze_malware(task_id, level):
cuckoo_report = get_cuckoo_report(task_id)
malware_behavior = cuckoo_report["behavior"]["processes"][0]["calls"]
if level == 0:
prompt = level_0_prompt
elif level == 1:
prompt = level_1_prompt
elif level == 2:
prompt = level_2_prompt
prompt += "\n\nMalware behavior:\n"
for call in malware_behavior:
prompt += "- " + call["api"] + " (" + call["category"] + ")\n"
report = generate_report(prompt)
return report
最后,ChatGPT 指定了需要编辑的参数才能使此脚本正常工作。

考虑一下写一个模板的想法。你需要python(或Rust或Go或Bash或任何其他脚本语言)才能使这个脚本正常工作。但是,如果您这样做,您将能够为非技术人员和技术人员提供恶意软件正在做什么以及它做了什么的清晰概念。
原文链接:Connect ChatGPT API to Cuckoo Sandbox | by David Merian | Mar, 2023 | System Weakness