GreyDGL / PentestGPT

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

Cannot close PentestGPT with "/bye" when opening normally with "pentestgpt" #215

Closed ll3N1GmAll closed 7 months ago

ll3N1GmAll commented 7 months ago

Describe the bug Cannot close PentestGPT with /bye when opening normally with pentestgpt

Please attach screenshot for output of pentestgpt-connection.

pentestgpt-connection
Your OPENAI_KEY is not set. Please set it in the environment variable.
If you want to use chatGPT with no API, use "text-davinci-002-render-sha" in chatgpt_config.py
Your CHATGPT_COOKIE is not set. Please set it in the environment variable.
You're testing the connection for PentestGPT v"0.12.0"
#### Test connection for OpenAI api (GPT-3.5)
1. The OpenAI API key is not properly configured. The likely reason is that you do not link a payment method
to OpenAI so your key is not active. 
Please follow README to update OpenAI API key through `export OPENAI_KEY=<>`
The error is below: No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details.
#### Test connection for OpenAI api (GPT-4)
2. The OpenAI API key is not properly configured. Please check the error below:
The error is below: No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details.
#### Test connection for chatgpt cookie

To Reproduce Steps to reproduce the behavior:

  1. Open PentestGPT normally with pentestgpt
  2. enter /bye

Expected behavior PentestGPT closes gracefully/normally

Version v"0.12.0" Not using cookies

Additional context The following error happens when closing PentestGPT

> /bye
Traceback (most recent call last):
  File "/home/<profile>/.local/lib/python3.10/site-packages/tenacity/__init__.py", line 382, in __call__
    result = fn(*args, **kwargs)
  File "/home/<profile>/PentestGPT/pentestgpt/utils/llm_api.py", line 253, in send_message
    conversation = self.conversation_dict[conversation_id]
KeyError: None

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/<profile>/.local/bin/pentestgpt", line 8, in <module>
    sys.exit(main())
  File "/home/<profile>/PentestGPT/pentestgpt/main.py", line 62, in main
    pentestGPTHandler.main()
  File "/home/<profile>/PentestGPT/pentestgpt/utils/pentest_gpt.py", line 737, in main
    self.initialize(previous_session_ids=loaded_ids)
  File "/home/<profile>/PentestGPT/pentestgpt/utils/pentest_gpt.py", line 266, in initialize
    self._feed_init_prompts()
  File "/home/<profile>/PentestGPT/pentestgpt/utils/pentest_gpt.py", line 193, in _feed_init_prompts
    _reasoning_response = self.reasoningAgent.send_message(
  File "/home/<profile>/.local/lib/python3.10/site-packages/tenacity/__init__.py", line 289, in wrapped_f
    return self(f, *args, **kw)
  File "/home/<profile>/.local/lib/python3.10/site-packages/tenacity/__init__.py", line 379, in __call__
    do = self.iter(retry_state=retry_state)
  File "/home/<profile>/.local/lib/python3.10/site-packages/tenacity/__init__.py", line 326, in iter
    raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x7ff2a2a510c0 state=finished raised KeyError>]
GreyDGL commented 7 months ago

Please check if you have linked a payment method or not; the pentestgpt-connection output shows that you did not get the API access correctly.

ll3N1GmAll commented 7 months ago

I have not setup a payment method because I only planned to use GPT4All. Since I am not using OpenAI, do I still need to setup a payment method for only local LLM use?

GreyDGL commented 7 months ago

I see. It seems that the conversation is not properly initialized, leading to the RetryError. In this case, I'll debug the other issue you raised and see if there's a solution for this.

ll3N1GmAll commented 7 months ago

I see. It seems that the conversation is not properly initialized, leading to the RetryError. In this case, I'll debug the other issue you raised and see if there's a solution for this.

Thanks so much! Let me know if you need anything else from me to assist you in your troubleshooting.

GreyDGL commented 7 months ago

Close this issue for now and merge to #214