We're testing PentestGPT on HackTheBox. You may follow this link. More details will be released soon.
- 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: Yes. 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.
- 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 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.
- Q: Future plan?
- A: We're working on a paper to explore the tech details behind automated pentest. Meanwhile, please feel free to raise issues/discussions. I'll do my best to address all of them.
- 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 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.
- A sample usage video is below: (or available here: Demo)
PentestGPT.-.720WebShareName.mov
- The project is still in its early stage. Feel free to raise any issues when using the tool.
- Please help to contribute by submitting the vulnerabilities you identified or challenges you solved with PentestGPT.
- This project is for research purpose. Please contact me if you're interested in collaboration.
- Install
requirements.txt
withpip install -r requirements.txt
- (Deprecated: Will update support for non-plus member later.)
Installchatgpt-wrapper
if you're non-plus members:pip install git+https://github.com/mmabrouk/chatgpt-wrapper
. More details at: https://github.com/mmabrouk/chatgpt-wrapper. Note that the support for non-plus members are not optimized. - Configure the cookies in
config
. You may follow a sample bycp config/chatgpt_config_sample.py. config/chatgpt_config.py
.- Login to ChatGPT session page.
- Find the request cookies to
https://chat.openai.com/api/auth/session
and paste it into thecookie
field ofconfig/chatgpt_config.py
. (You may use Inspect->Network, find session and copy thecookie
field inrequest_headers
tohttps://chat.openai.com/api/auth/session
) - Note that the other fields are temporarily deprecated due to the update of ChatGPT page.
- To verify that the connection is configured properly, you may run
python3 test_connection.py
. You should see some sample conversation with ChatGPT.
- To start, run
python3 main.py
. - The tool works similar to msfconsole. Follow the guidance to perform penetration testing.
- In general, PentestGPT intakes commands similar to chatGPT. There are several basic commands.
- 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.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).
- You can use <SHIFT + right arrow> to end your input (and is for next line).
- You may always use
TAB
to autocomplete the commands. - 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.
- The commands are:
- After finishing the penetration testing, a report will be automatically generated in
logs
folder (if you quit withquit
command). - The report can be printed in a human-readable format by running
python3 utils/report_generator.py <log file>
. A sample reportsample_pentestGPT_log.txt
is also uploaded.
The current design is mainly for web penetration testing
PentestGPT provides a unified terminal input handler, and backed by three main components:
- A test generation module which generates the exact penetration testing commands or operations for the users to execute.
- A test reasoning module which conducts the reasoning of the test, guiding the penetration testers on what to do next.
- A parsing module which parses the output of the penetration tools and the contents on the webUI.
The handler is the main entry point of the penetration testing tool. It allows pentesters to perform the following operations:
- (initialize itself with some pre-designed prompts.)
- Start a new penetration testing session by providing the target information.
- Ask for todo-list, and acquire the next step to perform.
- After completing the operation, pass the information to PentestGPT.
- Pass a tool output.
- Pass a webpage content.
- Pass a human description.