Code Monkey home page Code Monkey logo

wpechatgpt's Introduction

English | 中文

WPeChatGPT

  • IDA plugin based on the same model as ChatGPT, using the gpt-3.5-turbo model released by OpenAI, can help analysts quickly analyze binary files.

  • Features currently supported by WPeChatGPT include:

    • Analyze the usage environment, intended purpose, and function of the function.
    • Rename variables of functions.
    • Attempt to restore the function with python3, this function is mainly for functions of smaller blocks (such as an XOR decryption function).
    • Look for vulnerabilities in the current function.
    • Try to use python to generate the corresponding EXP for the vulnerable function.
    • Utilize GPT Automatically analyze binary files, see section Auto-WPeGPT for details.
  • The WPeChatGPT plugin uses OpenAI's text-davinci-003 model trained on GPT. After v2.0 use OpenAI's latest gpt-3.5-turbo model (The same as ChatGPT).

ChatGPT's analysis results for reference only, otherwise we analysts would be out of work on the spot. XD

Update History

Version Date Comment
1.0 2023-02-28 Based on Gepetto.
1.1 2023-03-02 1. Delete the function of analyzing encryption and decryption.
2. Increase the function of python restore function.
3. Modified some details.
1.2 2023-03-03 1. Added the function of finding binary vulnerabilities in functions.
2. Increase the function of trying to automatically generate the corresponding EXP.
3. Modified some details.
(The upload was not tested due to the OpenAI server lag)
2.0 2023-03-06 1. Complete the testing of v1.2 version vulnerability related functions.
2. Switch to the latest gpt-3.5-turbo model released by OpenAI.
2.1 2023-03-07 Fix the timed out issue of OpenAI-API. (See section About OpenAI-API Error Reporting)
2.3 2023-04-23 Add the Auto-WPeGPT v0.1 to support automatic analysis of binary files.
(Package anytree needs to be added from this version, use requirements.txt or pip install anytree)
2.4 2023-11-10 1. Changed some display details.
2. Update Auto-WPeGPT v0.2.

Install

  1. Run the following command to install the required packages.
pip install -r ./requirements.txt
  1. Modify the script WPeChatGPT.py, add your API key to the variable openai.api_key, change the variable ZH_CN to False. (Default Chinese)
  2. Copy the script file WPeChatGPT.py and the folder Auto-WPeGPT_WPeace to the plugins folder of IDA, and finally restart IDA to use it.

! NOTE: You need to set the IDA environment to python3, and you need to use the latest OpenAI Python package after WPeChatGPT 2.0 version.

Usage

Supports using any of the right click, menu bar or shortcut keys in IDA.

  • hot key:
    Function analysis = "Ctrl-Alt-G"
    Rename function variables = "Ctrl-Alt-R"
    Vulnerability finding = "Ctrl-Alt-E"

  • Right click on the pseudocode window:

  

  • Menu bar: Edit $\Rightarrow$ WPeChatGPT

  

Example

How to use:

  

Function analysis effect display:

  

Vulnerability finding effect display:

  

Auto-WPeGPT

Update History:

Version Date Comment
0.1 2023-04-23 Initial release.
0.2 2023-11-10 1. Improve the recognition of valid strings.
2. Improve the analysis of function call trees.
3. Add recognition for import functions.

How to use: Find Auto-WPeGPT in the menu bar and click it. After the output is complete, you can find the analysis results in the corresponding folder ("WPe_+IDB name").

  • Menu bar: Edit $\Rightarrow$ WPeChatGPT $\Rightarrow$ Auto-WPeGPT

  

The meaning of each file in the output folder:

GPT-Result.txt -> Auto-WPeGPT analysis results
funcTree.txt -> function call tree structure
mainFuncTree.txt -> main function tree structure
effectiveStrings.txt -> Suspicious strings in the binary

Show results:

  

After testing, the v0.1 version has a better analysis effect on files with fewer functions. In case of binary files with a large number of functions, tokens will exceed the range. We will try to improve it in the next version.

About OpenAI-API error reporting

  From March 2, 2023, I often encounter API errors, and I thought it was a problem of server instability (because I have ups and downs here), but because there are too many feedbacks that I have encountered related errors, so I I first went to OpenAI to check the API Status and found that it was running well, so I found that it might not be the server problem I thought, so I searched and debugged related problems. The following is how I dealt with the OpenAI API connection problem:

  First of all, the plug-in has been running under the conditions of Scientific Online.

  • Under the condition of scientific Internet access, if you find that the plug-in fails to connect to the API after many attempts, you need to check the urllib3 version of python (version 1.26 has a proxy problem).
    • You can use the following commands to perform a fallback fix for urllib3:
    pip uninstall urllib3
    pip install urllib3==1.25.11
    
  • If the urllib3 version is correct or there are still API access problems after reinstalling the 1.25 version, please download the latest version and specify a proxy for the plugin:
    • Uncomment the following three lines of code, then fill in the proxy address and port information into the proxies variable:
    #print("WPeChatGPT has appointed the proxy.")
    #proxies = {'http': "http://127.0.0.1:7890", 'https': "http://127.0.0.1:7890"}
    #openai.proxy = proxies
    

Contact me

If you encounter problems or have any questions when using the plugin, please leave a message or send me an email.

Acknowledgment

The project is based on Gepetto and inspired by it, you can visit https://github.com/JusticeRage/Gepetto to learn about the original method.

wpechatgpt's People

Contributors

wpeace-hch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wpechatgpt's Issues

对于GPT3.5处理过长数据的问题

这边给出一个建议,自动分块去提交,然后组合让它分析,类似的提问语句示例如下,我将将一个C函数分段提供你给,当我说什么什么的时候,说明我已全部提供给你,然后帮我分析啥啥啥的,然后分段提供,最后让它输出,最后获取最后获取的结果数据,然后输出

网络错误,Error communicating with OpenAI

正在发送 ChatGPT-davinci-003 API 请求,完成后将输出提示。@WPeace
Request to davinci-003 sent...
davinci-003 could not complete the request: Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/completions (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)')))

浏览器挂代理能正常访问 chat

存在报错

正在发送 ChatGPT-gpt-3.5-turbo API 请求,完成后将输出提示。@wpeace
Request to gpt-3.5-turbo sent...
gpt-3.5-turbo could not complete the request: Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000199BC393850>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。')))
使用的全局代理,然后浏览器也能正常访问gpt,求解决

调用三方接口 有问题

使用的是 https://api.zhiyungpt.com/ 的接口

结果如下

正在发送 ChatGPT-gpt-3.5-turbo API 请求,完成后将输出提示。@WPeace Request to gpt-3.5-turbo sent... OpenAI server could not complete the request: HTTP code 200 from API (<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="logo.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#ffffff"/><meta name="description" content="OpenAI 接口聚合管理,支持多种渠道包括 Azure,可用于二次分发管理 key,仅单可执行文件,已打包好 Docker 镜像,一键部署,开箱即用"/><title>New API</title><script defer="defer" src="/static/js/main.b7d9fd94.js"></script><link href="/static/css/main.4af3573c.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>)

找不到插件

作者你好,我放入plugins后重启IDA还是找不到插件
QQ图片20230308150739
QQ图片20230308150758

代理问题

这个是直接电脑挂上全局代理就可以使用嘛,还是得在脚本里指定本地代理的端口才行

Some pitfalls I encountered

When using the ChatGPT API with a Chinese skin version

enable the proxy.

#proxies = {'https': "https://your api address/v1"}
#openai.proxy = proxies

this is error

It needs to be changed like this:

openai.api_base = 'https://your api address/v1'
openai.api_key = 'sk-KxUG6zEFARt8CvsGsVryZz4nJ2xL3j1J9zcHQ1oVgZO28NYE'

IDA无法加载

我使用的是吾爱的IDA_Pro_7.7,已经pip install -r ./requirements.txt,也把.py文件复制到plugins目录,重启IDA后还是无法加载

遇到了一些问题

正在发送 ChatGPT-gpt-3.5-turbo API 请求,完成后将输出提示。@wpeace
Request to gpt-3.5-turbo sent...
OpenAI server could not complete the request:

You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.