# PentestGPT | A GPT-empowered Penetration Testing Tool

**URL:** <https://onehack.st/t/pentestgpt-a-gpt-empowered-penetration-testing-tool/242254>\
**Category:** Tools & Scripts\
**Tags:** hacking, freebies, ai\
**Created:** [May 31, 2023, 10:47pm UTC](https://onehack.st/t/pentestgpt-a-gpt-empowered-penetration-testing-tool/242254 "2023-05-31T22:47:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoBody](https://onehack.st/user_avatar/onehack.st/nobody/32/163880_2.png) [@NoBody](https://onehack.st/u/NoBody)\
**Post date:** [May 31, 2023, 10:47pm UTC](https://onehack.st/t/pentestgpt-a-gpt-empowered-penetration-testing-tool/242254/1 "2023-05-31T22:47:42Z")

</div>

![image](https://onehack.st/uploads/default/original/3X/0/1/01c745ab72bf8094f9b7adf3abcb5d400cb5a664.png)

[![Contributors](https://camo.githubusercontent.com/f58642652878d445aa63f3ab5c85c826eb61582d49d0068adaf73217d83841e3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f4772657944474c2f50656e746573744750542e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/GreyDGL/PentestGPT/graphs/contributors) [![Forks](https://camo.githubusercontent.com/622ea9dbd2af9b17de9a6b33311f4cb244d57cd6ed83a96891437af6c2be9c8e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f4772657944474c2f50656e746573744750542e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/GreyDGL/PentestGPT/network/members) [![Stargazers](https://camo.githubusercontent.com/4c7fca8ca584006ea3d55bb96d2a24c2144f594e87f54f9f4e7fb009d751601f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f4772657944474c2f50656e746573744750542e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/GreyDGL/PentestGPT/stargazers) [![Issues](https://camo.githubusercontent.com/ef006c79b4ef410714cf6392f1551a14ac93075cfeac3459bca8941bc38090b1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f4772657944474c2f50656e746573744750542e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/GreyDGL/PentestGPT/issues) [![MIT License](https://camo.githubusercontent.com/29f18a0196eab42a82e4bccb4d8460ca4da3a7cd4eb8f8142cfc019170c57503/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4772657944474c2f50656e746573744750542e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/GreyDGL/PentestGPT/blob/master/LICENSE.txt) [![Discord](https://camo.githubusercontent.com/6870d6d227f0cc05258de502c37f191b8264ec332ff16e53ba1e4a5c8c3e6711/68747470733a2f2f646362616467652e76657263656c2e6170702f6170692f7365727665722f65433334434566456b4b)](https://discord.gg/eC34CEfEkK)

### PentestGPT

A GPT-empowered penetration testing tool.  
[**Explore the docs »**](https://github.com/GreyDGL/PentestGPT)

[Design Details](https://github.com/GreyDGL/PentestGPT/blob/main/PentestGPT_design.md) · [View Demo](https://www.youtube.com/watch?v=lAjLIj1JT3c) · [Report Bug or Request Feature](https://github.com/GreyDGL/PentestGPT/issues)

## General Updates

- [Update on 30/05/2023] A major update that allows the installation of PentestGPT with `pip`.
- Available videos:
  - **PentestGPT for OSCP-like machine: [HTB-Jarvis](https://youtu.be/lAjLIj1JT3c)**. This is the first part only, and I’ll complete the rest when I have time.
  - **PentestGPT on [HTB-Lame](https://youtu.be/Vs9DFtAkODM)**. This is an easy machine, but it shows you how PentestGPT skipped the rabbit hole and worked on other potential vulnerabilities.

- **We’re testing PentestGPT on HackTheBox**. You may follow [this link](https://www.hackthebox.com/home/users/profile/1489431). More details will be released soon.
- Feel free to join the [Discord Channel](https://discord.gg/eC34CEfEkK) for more updates and share your ideas!

## Common Questions

- **Q** : What is PentestGPT?
  - **A** : PentestGPT is a penetration testing tool empowered by ChatGPT. It is designed to automate the penetration testing process. It is built on top of ChatGPT and operate in an interactive mode to guide penetration testers in both overall progress and specific operations.

- **Q** : Do I need to be a ChatGPT plus member to use PentestGPT?
  - **A** : You’re recommended to use ChatGPT plus or GPT-4 API. PentestGPT relies on GPT-4 model for high-quality reasoning. Since there is no public GPT-4 API yet, a wrapper is included to use ChatGPT session to support PentestGPT. You may also use GPT-4 API directly if you have access to it.

- **Q** : Why GPT-4?
  - **A** : After empirical evaluation, we found that GPT-4 performs better than GPT-3.5 in terms of penetration testing reasoning. In fact, GPT-3.5 leads to failed test in simple tasks.

- **Q** : Why not just use GPT-4 directly?
  - **A** : We found that GPT-4 suffers from losses of context as test goes deeper. It is essential to maintain a “test status awareness” in this process. You may check the PentestGPT design [here](https://github.com/GreyDGL/PentestGPT/blob/main/PentestGPT_design.md) for more details.

- **Q** : What about AutoGPT?
  - **A** : AutoGPT is not designed for pentest. It may perform malicious operations. Due to this consideration, we design PentestGPT in an interactive mode. Of course, our end goal is an automated pentest solution.

## Getting Started

- **PentestGPT** is a penetration testing tool empowered by **ChatGPT**.
- It is designed to automate the penetration testing process. It is built on top of ChatGPT and operate in an interactive mode to guide penetration testers in both overall progress and specific operations.
- **PentestGPT** is able to solve easy to medium HackTheBox machines, and other CTF challenges. You can check [this](https://github.com/GreyDGL/PentestGPT/blob/main/resources/README.md) example in `resources` where we use it to solve HackTheBox challenge **TEMPLATED** (web challenge).
- A sample testing process of **PentestGPT** on a target VulnHub machine (Hackable II) is available at [here](https://github.com/GreyDGL/PentestGPT/blob/main/resources/PentestGPT_Hackable2.pdf).
- A sample usage video is below: (or available here: [Demo](https://youtu.be/h0k6kWWaCEU))

### Installation

**PentestGPT** current supports backend of **ChatGPT** and **OpenAI API**. You may use either of them. We’re working on supports to custom local LLM models. You’re recommended to use the OpenAI API for stability and performance (details in item 3).

1. Install the latest version with `pip3 install git+https://github.com/GreyDGL/PentestGPT`
2. If you decide to use **ChatGPT** as the backend

- Obtain the cookie to access the ChatGPT session

```auto
$ pentestgpt-cookie
export CHATGPT_COOKIE='<your cookie here>`

```

- Copy the previous command and run it in your terminal (`export CHATGPT_COOKIE='<big-string-you-shall-get-from-the-previous-command>'`)
- Test the connection with `pentestgpt-connection`
- Run the tool with `pentestgpt`

1. To use OpenAI API

- export your API key with `export OPENAI_KEY='<your key here>'`
- Test the connection with `pentestgpt-connection`

1. To verify that the connection is configured properly, you may run `pentestgpt-connection`. After a while, you should see some sample conversation with ChatGPT.

- A sample output is below

```auto
1. You're connected with ChatGPT Plus cookie. 
To start PentestGPT, please use <pentestgpt --reasoning_model=gpt-4>
## Test connection for OpenAI api (GPT-4)
2. You're connected with OpenAI API. You have GPT-4 access. To start PentestGPT, please use <pentestgpt --reasoning_model=gpt-4 --useAPI>
## Test connection for OpenAI api (GPT-3.5)
3. You're connected with OpenAI API. You have GPT-3.5 access. To start PentestGPT, please use <pentestgpt --reasoning_model=gpt-3.5-turbo --useAPI>

```

1. The ChatGPT cookie solution can be very unstable. We’re constantly working on a better solution. If you have any idea or encounter any issues, please feel free to contact us.

## Usage

1. To start, run `pentestgpt --args`.

- `--reasoning_model` is the reasoning model you want to use.
- `--useAPI` is whether you want to use OpenAI API.
- You’re recommended to use the combination as suggested by `test_connection.py`, which are:
  - `pentestgpt --reasoning_model=gpt-4`
  - `pentestgpt --reasoning_model=gpt-4 --useAPI`
  - `pentestgpt --reasoning_model=gpt-3.5-turbo --useAPI`

1. The tool works similar to _msfconsole_. Follow the guidance to perform penetration testing.
2. In general, PentestGPT intakes commands similar to chatGPT. There are several basic commands.
3. The commands are:  
\* `help`: show the help message.  
\* `next`: key in the test execution result and get the next step.  
\* `more`: let **PentestGPT** to explain more details of the current step. Also, a new sub-task solver will be created to guide the tester.  
\* `todo`: show the todo list.  
\* `discuss`: discuss with the **PentestGPT**.  
\* `google`: search on Google. This function is still under development.  
\* `quit`: exit the tool and save the output as log file (see the **reporting** section below).
4. You can use \<SHIFT + right arrow\> to end your input (and is for next line).
5. You may always use `TAB` to autocomplete the commands.
6. When you’re given a drop-down selection list, you can use cursor or arrow key to navigate the list. Press `ENTER` to select the item. Similarly, use \<SHIFT + right arrow\> to confirm selection.
7. In the sub-task handler initiated by `more`, users can execute more commands to investigate into a specific problem:
8. The commands are:  
\* `help`: show the help message.  
\* `brainstorm`: let PentestGPT brainstorm on the local task for all the possible solutions.  
\* `discuss`: discuss with PentestGPT about this local task.  
\* `google`: search on Google. This function is still under development.  
\* `continue`: exit the subtask and continue the main testing session.

### Report and Logging

1. After finishing the penetration testing, a report will be automatically generated in `logs` folder (if you quit with `quit` command).
2. The report can be printed in a human-readable format by running `python3 utils/report_generator.py <log file>`. A sample report `sample_pentestGPT_log.txt` is also uploaded.

## License

Distributed under the MIT License. See `LICENSE.txt` for more information.

## GitHub:

> **[GitHub - GreyDGL/PentestGPT: Automated Penetration Testing Agentic Framework...](https://github.com/GreyDGL/PentestGPT)**
>
> Automated Penetration Testing Agentic Framework Powered by Large Language Models

---

<div class="post-metadata">

**Author:** ![odirachukwu\_onyejefu](https://onehack.st/user_avatar/onehack.st/odirachukwu_onyejefu/32/43629_2.png) [@odirachukwu\_onyejefu](https://onehack.st/u/odirachukwu_onyejefu)\
**Post date:** [July 21, 2026, 12:24am UTC](https://onehack.st/t/pentestgpt-a-gpt-empowered-penetration-testing-tool/242254/2 "2026-07-21T00:24:33Z")

</div>

> [@NoBody](#):
>
> - 
> - It is designed to automate the penetration testing process. It is built on top of ChatGPT and operate in an interactive mode to guide penetration testers in both overall progress and specific operations.
> 
> - **PentestGPT** is able to solve easy to medium HackTheBox machines, and other CTF challenges. You can check [this](https://github.com/GreyDGL/PentestGPT/blob/main/resources/README.md) example in `resources` where we use it to solve HackTheBox challenge **TEMPLATED** (web challenge).
> 
> - A sample testing process of **PentestGPT** on a target VulnHub machine (Hackable II) isHow

How do I make it autonomous with my local ollama? I installed PentestGPT but it isn’t autonomous and agentic as shown above using my local Ollama
