
IATelligence is a Python script that will extract the IAT of a PE file and request GPT to get more information about the API and the ATT&CK matrix related
IATelligence は、PEファイルからインポート アドレス テーブル(IAT)を抽出し、OpenAI の GPT-3 モデルを使用して、ファイルがインポートする各 Windows API に関する詳細を提供する Python スクリプトです。このスクリプトは、関連する MITRE ATT&CK テクニックを検索し、攻撃者がその API をどのように使用する可能性があるかを説明します。
また、ファイルのハッシュを表示し、GPT-3 リクエストのコストを見積もります。IATelligence は、マルウェア解析に GPT-3 を使用し、IAT に基づいてマルウェアの動作を迅速に評価するための概念実証です。
以下は、得られる結果の簡単な例です。IAT のサイズによっては、リクエストに時間がかかる場合があることに注意してください。

このツールを実行するには、OpenAi API へのアクセスが必要です。その後、スクリプトを変更して独自の API キーを追加する必要があります。
# Authenticate with the OpenAI API
openai.api_key = ""
また、依存関係をインストールする必要があります。
pip install -r requirements.txt
ツールを実行するには、スクリプトの引数として PE ファイルを指定するだけです。
python iatelligence.py sample.exe
スクリプトは、ハッシュとリクエストの推定コストも計算します。
[+] IAT Request from the file: .\sample.exe
[+] 33 functions will be requested to GPT!
[+] MD5: 2f82623f9523c0d167862cad0eff6806
[+] SHA1: 5d77804b87735e66d7d1e263c31c4ef010f16153
[+] SHA256: 9c2c8a8588fe6db09c09337e78437cb056cd557db1bcf5240112cbfb7b600efb
[+] Imphash: 8eeaa9499666119d13b3f44ecd77a729
[!] Estimated cost of requests: $0.0693
結果は表で確認できます。以下は切り詰めた抜粋です。
+------------------------------------------+-----------------------------+------------------------------------------+
| Libraries | API | GPT Verdict |
+------------------------------------------+-----------------------------+------------------------------------------+
| SHELL32.dll | ShellExecuteW | The purpose of this API, ShellExecuteW, |
| | | is to launch an application or open a |
| | | file in the Windows operating system. It |
| | | is associated with MITRE ATT&CK |
| | | technique T1218 - Execution Through |
| | | Module Load. This technique involves |
| | | using shell32.dll to execute malicious |
| | | code without directly invoking the |
| | | executable file itself, which can help |
| | | attackers evade detection and gain |
| | | access to systems. |
| | | |
| KERNEL32.dll | GetCurrentThreadId | The purpose of this API is to retrieve |
| | | the identifier of the calling thread. It |
| | | is associated with MITRE ATT&CK |
| | | technique T1155 - Thread Execution, |
| | | which involves creating and running |
| | | threads within a process or code |
| | | injection into an existing thread. The |
| | | GetCurrentThreadId() function allows |
| | | attackers to identify and target |
| | | specific threads for malicious |
| | | activities. |
| | | |
| KERNEL32.dll | GetSystemTimeAsFileTime | The purpose of this API is to retrieve |
| | | the current system time as a file time |
| | | format. It is associated with the MITRE |
| | | ATT&CK technique T1124 - System Time |
| | | Discovery, which is used by adversaries |
| | | to gain insight into when certain |
| | | activities occurred or are scheduled to |
| | | occur. This allows them to perform |
| | | timing-based attacks and evade |
| | | detection. |
| | | |
| KERNEL32.dll | GetTickCount | The purpose of this API is to retrieve |
| | | the number of milliseconds since Windows |
| | | was started. It is associated with MITRE |
| | | ATT&CK technique T1082 - System Time |
| | | Discovery, which involves an adversary |
| | | querying system information to gain |
| | | insight into file and system times or to |
| | | determine valid accounts. This can be |
| | | used for various malicious activities |
| | | such as enumeration, credential dumping, |
| | | and lateral movement. |
| | | |
| KERNEL32.dll | RtlCaptureContext | The purpose of this API is to capture |
| | | the Context Record of a thread in order |
| | | to provide information about its state. |
| | | This can be used for debugging, logging |
| | | or other purposes. The associated MITRE |
| | | ATT&CK technique is T1113 - Process |
| | | Injection, as this API can be used to |
| | | inject code into a running process. |
| | | |
| KERNEL32.dll | GetCurrentProcessId | The purpose of this API is to retrieve |
| | | the current process identifier (PID) for |
| | | a process running on Windows. This can |
| | | be used to identify which processes are |
| | | currently active and running on a |
| | | system. It is associated with MITRE |
| | | ATT&CK technique T1057 - Process |
| | | Discovery, as it allows an adversary to |
| | | gain knowledge about the processes that |
| | | are running on a system. |
| | | |
| KERNEL32.dll | RtlVirtualUnwind | The purpose of this API is to provide an |
| | | unwinding mechanism that can be used to |
| | | traverse the stack frames of a program. |
| | | It is associated with the MITRE ATT&CK |
| | | technique called "Stack Walking" |
| | | (T1063). This technique involves using |
| | | APIs like RtlVirtualUnwind() to walk |
| | | through the stack frames, which can help |
| | | attackers gain access to sensitive |
| | | information or bypass security controls. |
| | | |
| KERNEL32.dll | UnhandledExceptionFilter | The purpose of this API is to provide an |
| | | exception handler for unhandled |
| | | exceptions in the Windows operating |
| | | system. It is associated with the MITRE |
| | | ATT&CK technique T1136 - Create or |
| | | Modify System Process, as it allows a |
| | | program to be able to handle unexpected |
| | | events that may occur during its |
| | | execution. |
OpenAI の GPT-3 を使用して PE ファイル内のインポートされた Windows API を分析するコストは、IAT のサイズによって異なります。個々のリクエストのコストは高くありませんが、ファイルが大きいと合計コストはすぐに膨らむ可能性があります。スクリプトが提供する推定コストは概算であり、変動する可能性があります。
スクリプトの設計上、分析は一度に 1 つの API ずつ実行されるため、処理が遅くなる可能性があります。分析の進行状況を示すプログレスバーが表示されます。
GPT-3 は言語モデルであるため、結果が常に正確であるとは限らないことに注意することが重要です。さらに、このスクリプトは関連する MITRE ATT&CK テクニックの詳細をコンテキストなしで提供するため、その情報はマルウェアアナリストが慎重に検討する必要があります。
Twitter: @fr0gger_