trs
利用OpenAI和Chromadb來分析和聊天網絡威脅情報報告和博客。
向預先構建的命令提供威脅報告URL,以進行摘要,MITER TTP提取,思維圖創建和識別檢測機會,或者針對URL文本內容運行您自己的自定義提示。
每個URL文本都存儲在Chroma Vector數據庫中,因此您可以使用存儲的數據將QNA /檢索儀(RAG)聊天會話。
使用OpenAI模型gpt-4-1106-preview
用於更輕鬆地支持較大的上下文,但可以隨意將其換成另一個模型。
完整文檔: https://trs.deadbits.ai
克隆存儲庫
git clone https://github.com/deadbits/trs.git
cd trs
設置Python虛擬環境
python3 -m venv venv
source venv/bin/activate
安裝Python要求
pip install -r requirements.txt
設置您的OpenAI API密鑰:
export OPENAI_API_KEY= " sk-... "
運行命令行應用程序
python trs-cli.py --chat
設置您的OpenAI API密鑰:
.streamlit/secrets.toml
運行簡化的Web界面
streamlit run trs-streamlit.py
重要的
根據簡化的文檔,“簡化在每個用戶互動或代碼更改時,將您的腳本從上到下運行。”由於Chromadb一遍又一遍地將記憶加載到內存中,這可能會導致高內存使用。目前,CLI是推薦的交互方式。
這裡提供更多屏幕截圖。
命令 | 描述 |
---|---|
!summ | 生成一個URL內容的摘要,包括關鍵要點,摘要段落,MITER TTPS和MERMAID MINDMAP,以獲取報告概述。 |
!detect | 確定URL內容中的任何威脅檢測機會。 |
!custom | 獲取URL內容並使用自定義提示進行處理。 |
所有其他輸入 | 運行帶有輸入的RAG管道作為查詢 |
在使用聊天功能之前,必須先用上面的命令之一處理一個URL,以便矢量數據庫具有一些上下文。
任何不是!command
輸入都將發送到RAG管道。
如果答案在上下文中不可用,您將無法得到答案。
? >> Summarize the LemurLoot malware functionality
2023-10-14 14:51:51.140 | INFO | trs.vectordb:query:84 - Querying database for: Summarize the LemurLoot malware functionality
2023-10-14 14:51:51.840 | INFO | trs.vectordb:query:90 - Found 3 results
2023-10-14 14:51:51.841 | INFO | trs.llm:qna:98 - sending qna prompt
2023-10-14 14:51:51.841 | INFO | trs.llm:_call_openai:41 - Calling OpenAI
2023-10-14 14:51:51.854 | INFO | trs.llm:_call_openai:59 - token count: 2443
? >>
The LemurLoot malware has several functionalities. It uses the header field “X-siLock-Step1’ to receive commands from the operator, with two well-defined commands: -1 and -2.
Command “-1” retrieves Azure system settings from MOVEit Transfer and performs SQL queries to retrieve files. Command “-2” deletes a user account with the LoginName and
RealName set to "Health Check Service". If any other values are received, the web shell opens a specified file and retrieves it. If no values are specified, it creates the
“Health Check Service” admin user and creates an active session.
可以將自定義提示模板保存到帶有.txt
擴展名的文本文件中的prompts/
目錄中。 !custom
命令將在該目錄中查找文件Basename的提示,將URL的文本內容添加到模板中,然後將其發送到LLM進行處理。
自定義提示必須包括格式字符串{document}
以便可以添加URL文本內容。
簡化應用程序提供了一些CLI工具沒有的功能,包括:
查看提示和響應歷史記錄
查看數據庫記錄
該項目已在Apache 2.0許可證下獲得許可 - 有關詳細信息,請參見許可證文件。