Legacy Prompts and Reporting
Overview
This area contains the legacy PentestGPT prompt text, terminal prompt widgets, and a small transcript reporting utility. The prompt templates live in pentestgpt_legacy/…/prompt_class.py as dataclass string fields on PentestGPTPrompt, but the legacy orchestrator imports and uses the class itself in pentestgpt_legacy/…/pentest_gpt.py, so the fields behave like static constants rather than per-instance configuration.
pentestgpt_legacy/…/prompt_class.py defines the three backbone session initializers used by the LLM layer:
generation_session_initprimes the generation session to expand a selected Pentesting Task Tree (PTT) item into tester-facing guidance.reasoning_session_initprimes the reasoning session to maintain the PTT and produce only the tree-form task state.input_parsing_initprimes the parsing session to summarize tool output, web pages, or tester notes before they are sent to reasoning.
The same file also defines the prompt fragments that move data between the sessions. task_description prefixes the tester's initial one-line target description before it is sent to the reasoning client in pentestgpt_legacy/…/pentest_gpt.py; process_results asks reasoning to revise the PTT from new findings; process_results_task_selection asks reasoning to select a favorable next to-do task; and todo_to_command asks generation to convert the selected task into concise step-by-step instructions. Local sub-task prompts (local_task_init, local_task_prefix, and local_task_brainstorm) are used after the user requests “more” detail, while ask_todo and discussion let the main loop ask reasoning to re-evaluate the task tree from user questions or comments. pentestgpt_legacy/…/__init__.py is empty and does not re-export these prompts.
The terminal selection/input helpers live in pentestgpt_legacy/…/prompt_select.py. prompt_select() builds a prompt_toolkit Application around a RadioList, displays a title label, supports mouse selection, exits on Ctrl-D with no result, and returns the selected RadioList.current_value when Shift+Right is pressed. prompt_ask() wraps prompt_toolkit.shortcuts.prompt for free-form user input: in multiline mode Enter inserts a newline, and Shift+Right validates/accepts the buffer; in single-line mode Enter keeps the default accept behavior and Shift+Right also accepts. Both helpers are called from pentestgpt_legacy/…/pentest_gpt.py: prompt_ask() gathers the initial task description, pasted findings, discussion text, and save name, while prompt_select() chooses the pasted input source (tool, user-comments, web, or default) before parsing.
pentestgpt_legacy/…/report_generator.py is a standalone script for printing saved legacy logs as a chronological conversation. main(file_name) opens a JSON file with top-level user and pentestGPT arrays, expects each entry to be [timestamp, text], tags each entry with its source, sorts the combined list by timestamp, formats timestamps with datetime.fromtimestamp(...).strftime("%Y-%m-%d %H:%M:%S"), and prints user/PentestGPT lines to stdout. It adds a dashed separator after each pentestGPT response. When run directly, it defaults to logs/sample_pentestGPT_log.txt unless a path is passed on the command line.
The reporting utility is aligned with the transcript shape written by pentestgpt_legacy/…/pentest_gpt.py: pentestGPT.main() writes self.history as JSON to logs/pentestGPT_log_<timestamp>.txt, and self.history includes user and pentestGPT keys in addition to internal reasoning, input_parsing, generation, and exception channels. report_generator.py intentionally ignores those internal channels and only reconstructs the user-visible conversation.
Coupling
- If pentestgpt_legacy/…/prompt_class.py changes the expected PTT format or status labels, also verify pentestgpt_legacy/…/pentest_gpt.py calls that concatenate
task_description,process_results,process_results_task_selection, andtodo_to_command; the reasoning and generation sessions exchange plain text, so format drift will not fail loudly. - If
prompt_select()in pentestgpt_legacy/…/prompt_select.py changes the type of values returned by theRadioList, update theint(source)indexing in pentestgpt_legacy/…/pentest_gpt.py; the source selector currently passes integer-like option ids and then indexespostfix_optionsby converting the returned value to an integer. - If pentestgpt_legacy/…/pentest_gpt.py changes the saved history schema, update pentestgpt_legacy/…/report_generator.py; the report script assumes top-level
userandpentestGPTarrays and two-element timestamp/text entries.
Risks
- pentestgpt_legacy/…/report_generator.py will raise
KeyError,ValueError, orTypeErrorif a saved log omitsuser/pentestGPT, stores timestamps as non-integer strings, or uses the fullsave_session()shape ({"task_log": ..., "history": ...}) instead of the rawself.historyshape written at shutdown by pentestgpt_legacy/…/pentest_gpt.py. The consequence is that a valid session-save file cannot be rendered by this script without manually selecting the raw history payload. - pentestgpt_legacy/…/prompt_select.py only accepts the selected radio value on Shift+Right (
s-right), while Ctrl-D exits without a result. In pentestgpt_legacy/…/pentest_gpt.py, thenextflow immediately runsint(source), so exiting the selector without a selected result causes the main interaction to error instead of returning to the menu.