GreyDGL / PentestGPT

A GPT-empowered penetration testing tool
MIT License
7.28k stars 883 forks source link

Fix restore previous session #164

Closed RiccardoRobb closed 2 months ago

RiccardoRobb commented 1 year ago

Whenever I try to use a previously saved session, the tool creates a new conversation.

Your CHATGPT_COOKIE is not set. Please set it in the environment variable.
Welcome to pentestGPT, an automated penetration testing parser empowered by GPT.
The settings are: 
 - parsing model: gpt-3.5-turbo-16k
 - reasoning model: gpt-4-browsing
 - use API: True
 - log directory: logs
Do you want to continue from previous session? (y/n) y
Please select the previous session by its index (integer):
0. testZero
1. README.md
Please key in your option (integer): 0
You selected: testZero
New conversation.163502c1-6c40-11ee-9cd0-c5a3a6d4eef1 is created.

New conversation.17b793c4-6c40-11ee-9cd0-c5a3a6d4eef1 is created.

New conversation.19abca7e-6c40-11ee-9cd0-c5a3a6d4eef1 is created.

....

In this case the tool does not restore the session

Possible Fix idea

Removing the self.useAPI is False control from line 197\ The tool successfully retrieves information about the selected conversation

Your CHATGPT_COOKIE is not set. Please set it in the environment variable.
Welcome to pentestGPT, an automated penetration testing parser empowered by GPT.
The settings are: 
 - parsing model: gpt-3.5-turbo-16k
 - reasoning model: gpt-4-browsing
 - use API: True
 - log directory: logs
Do you want to continue from previous session? (y/n) y
Please select the previous session by its index (integer):
0. testZero
1. README.md
Please key in your option (integer): 0
You selected: testZero 

But after that the tool cannot retrieve the right conversation\
Key error in [**line 253**](https://github.com/GreyDGL/PentestGPT/blob/main/pentestgpt/utils/llm_api.py)
GreyDGL commented 1 year ago

First, thanks for the continous contribution to the project @RiccardoRobb ! I have noticed this problem. Will provide a fix PR and refer to this item.

RiccardoRobb commented 1 year ago

I am glad to be able to contribute to this project. I will try to find a solution for this problem. I am trying to see if pentestgpt/utils/chatgpt.py can be used to solve the problem; from here I want to see if I can retrieve the entire conversation history. Let me know if this is a good idea :smile: