# wpeace-hch/wpechatgpt architecture

> Architecture diagram of the GitHub repository wpeace-hch/wpechatgpt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wpeace-hch/wpechatgpt
- Repository: https://github.com/wpeace-hch/wpechatgpt

## Overview

##### Project Type and Purpose
- This is an IDA Pro plugin that automates certain binary analysis tasks using OpenAI’s GPT models.
- Its purpose is two-fold: (a) to offer interactive analysis within IDA (via WPeChatGPT.py) and (b) to perform automated analysis through the Auto‑WPeGPT module (located in the Auto-WPeGPT_WPeace directory), which generates multiple output files (for function trees, analysis results, etc.).

##### Main Components
a. IDA Interface & Environment:
- Mechanisms by which the plugin is activated (right-click context menus, hotkeys, menu bar selections).

b. Core Plugin Logic:
- Main script (WPeChatGPT.py) that handles user interactions, triggers analysis, renames variables, finds vulnerabilities, and invokes restoration functions.
- That this script captures user commands and prepares the relevant binary information for analysis.

c. Auto Analysis Module:
- That this module processes binary files automatically, generating outputs like the GPT-Result.txt, funcTree.txt, etc.

d. External Services:
- Dependency on Internet connectivity and possible configuration via proxy settings.

e. File System & Output Artifacts:
- Where output files (e.g., analysis results, function call trees, suspicious strings) are generated (using directories named from the output format “WPe_+IDB name”).

##### Relationships and Interactions
- Also, show interactions between the plugin and the Auto‑WPeGPT module when users opt for auto analysis mode.

##### Architectural Patterns / Design Principles
- Modular design: one component handles interactive commands (WPeChatGPT.py), and a dedicated sub-module handles automation (Auto-WPeGPT).
- Separation of concerns: UI integration, analysis logic, external API communication, and file I/O are distinct layers.
- Mention error handling and configuration (e.g., API key setup, proxy configurations) as part of the integration with external services.

##### Relevant Technologies, Frameworks, and Libraries
- Python as the primary language.
- The OpenAI Python package (with a note on version requirements and dependency on the latest package since v2.0).
- The anytree package (required by Auto‑WPeGPT for generating function trees).
- IDA Pro’s Python API plugin system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["IDA Pro Environment"]:::ida
    B["WPeChatGPT.py"]:::plugin
    F["Configuration (API keys&proxy)"]:::external
    C["OpenAI API (gpt-3.5-turbo/text-davinci-003)"]:::external
    D["Auto‑WPeGPT Module"]:::auto
    E["Output Files"]:::output

    A -->|"triggers"| B
    B -->|"configures"| F
    F -->|"calls"| C
    B -->|"triggers-auto-analysis"| D
    D -->|"writes-results-to"| E

    click B "https://github.com/wpeace-hch/wpechatgpt/blob/main/WPeChatGPT.py"
    click D "https://github.com/wpeace-hch/wpechatgpt/blob/main/Auto-WPeGPT_WPeace/Auto_WPeGPT.py"
    click C "https://github.com/wpeace-hch/wpechatgpt/blob/main/requirements.txt"

    classDef ida fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef plugin fill:#aed6f1,stroke:#2980b9,stroke-width:2px;
    classDef auto fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;
    classDef external fill:#fad7a0,stroke:#f39c12,stroke-width:2px;
    classDef output fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
```
