|
46 | 46 | Returns: |
47 | 47 | data unchanged — the hook must return PostcommandData. |
48 | 48 |
|
| 49 | +## _read_recent_commands_for_autosuggest |
| 50 | +Return the last ``limit`` first-tokens from the session transcript. |
| 51 | + |
| 52 | +The transcript lives at ``sessions/LazyOwn_session_report.csv``. |
| 53 | +Newest entries appear last in the returned list. |
| 54 | + |
| 55 | +Args: |
| 56 | + limit: Maximum number of distinct command names to return. |
| 57 | + |
| 58 | +Returns: |
| 59 | + A list of command first-tokens. Empty when the file is |
| 60 | + absent or unreadable. |
| 61 | + |
| 62 | +## _refresh_autosuggest |
| 63 | +Recompute the active suggestion from the engine's provider chain. |
| 64 | + |
| 65 | +Reads ``enable_autosuggest`` from ``self.params`` so the |
| 66 | +operator can toggle the feature with ``set enable_autosuggest |
| 67 | +false`` without restarting the shell. Commands listed in the |
| 68 | +engine's skip set are passed through unchanged so help/exit |
| 69 | +do not poison the context. |
| 70 | + |
| 71 | +Args: |
| 72 | + executed_command: First-line of the command that just |
| 73 | + executed. The engine drops it into |
| 74 | + :class:`cli.autosuggest.SuggestionContext.last_command`. |
| 75 | + |
| 76 | +## _autosuggest_hook |
| 77 | +Refresh the next-command suggestion and print one dim hint line. |
| 78 | + |
| 79 | +The hint is printed below the command output, never injected |
| 80 | +into ``self.prompt``, so readline column accounting stays |
| 81 | +intact and the prompt itself remains clean. Failure inside the |
| 82 | +hook is swallowed — at worst the operator sees no hint. |
| 83 | + |
| 84 | +Args: |
| 85 | + data: cmd2 PostcommandData containing the executed |
| 86 | + statement. |
| 87 | + |
| 88 | +Returns: |
| 89 | + ``data`` unchanged. cmd2 expects the hook to return the |
| 90 | + same PostcommandData reference. |
| 91 | + |
49 | 92 | ## _engagement_hook |
50 | 93 | Post-command hook: biological curiosity reveal + VRI reward. |
51 | 94 |
|
@@ -3114,6 +3157,96 @@ Example: |
3114 | 3157 | Note: |
3115 | 3158 | Ensure that the `rhost` is valid by checking it with the `check_rhost` function before updating the prompt. |
3116 | 3159 |
|
| 3160 | +## next |
| 3161 | +Execute the active next-command suggestion (alias ``.``). |
| 3162 | + |
| 3163 | +The autosuggest engine prints a dim ``press '.' to run: <cmd>`` |
| 3164 | +line after every command. ``next`` (or ``.``) pops that |
| 3165 | +suggestion, runs it via ``onecmd_plus_hooks`` so every regular |
| 3166 | +pre/post hook fires, and then forces the engine to recompute |
| 3167 | +using the executed command as ``last_command`` — guaranteeing |
| 3168 | +the next suggestion advances even if cmd2 does not re-fire its |
| 3169 | +postcmd hook for the nested call. |
| 3170 | + |
| 3171 | +Args: |
| 3172 | + line: Ignored. Present to satisfy the cmd2 ``do_*`` |
| 3173 | + contract. |
| 3174 | + |
| 3175 | +Returns: |
| 3176 | + None. |
| 3177 | + |
| 3178 | +## daemon_mode |
| 3179 | +Switch the autonomous daemon between auto, approval and paused modes. |
| 3180 | + |
| 3181 | +Usage: |
| 3182 | + daemon_mode auto Run without operator gating (default). |
| 3183 | + daemon_mode approval Require operator approval per command. |
| 3184 | + daemon_mode paused Block the loop before the next step. |
| 3185 | + |
| 3186 | +The selected mode is persisted to |
| 3187 | +``sessions/daemon_control.json`` and read by the daemon before |
| 3188 | +every step. No daemon restart is required. |
| 3189 | + |
| 3190 | +Args: |
| 3191 | + line: Whitespace-stripped mode name. |
| 3192 | + |
| 3193 | +Returns: |
| 3194 | + None. |
| 3195 | + |
| 3196 | +## daemon_pause |
| 3197 | +Pause the autonomous daemon before its next step. |
| 3198 | + |
| 3199 | +Equivalent to ``daemon_mode paused``. The daemon polls the |
| 3200 | +control file between steps and resumes once the mode flips back |
| 3201 | +to auto or approval. |
| 3202 | + |
| 3203 | +Args: |
| 3204 | + line: Ignored. |
| 3205 | + |
| 3206 | +## daemon_resume |
| 3207 | +Resume the autonomous daemon (switch mode to auto). |
| 3208 | + |
| 3209 | +Args: |
| 3210 | + line: Ignored. |
| 3211 | + |
| 3212 | +## daemon_veto |
| 3213 | +Add or clear vetoed command first-tokens for the autonomous daemon. |
| 3214 | + |
| 3215 | +Usage: |
| 3216 | + daemon_veto add <command> Block <command> on future steps. |
| 3217 | + daemon_veto remove <command> Remove a previously-blocked command. |
| 3218 | + daemon_veto clear Drop every veto entry. |
| 3219 | + daemon_veto List the current vetoes. |
| 3220 | + |
| 3221 | +Args: |
| 3222 | + line: Sub-command plus optional command token. |
| 3223 | + |
| 3224 | +## daemon_focus |
| 3225 | +Restrict the autonomous daemon to a set of focus targets. |
| 3226 | + |
| 3227 | +Usage: |
| 3228 | + daemon_focus <ip_or_host> [<ip_or_host> ...] |
| 3229 | + daemon_focus clear Drop the focus list (run anywhere). |
| 3230 | + daemon_focus Print the current focus targets. |
| 3231 | + |
| 3232 | +Args: |
| 3233 | + line: Whitespace-separated list of targets or sub-command. |
| 3234 | + |
| 3235 | +## daemon_approve |
| 3236 | +Approve or veto the daemon's currently-pending action. |
| 3237 | + |
| 3238 | +Usage: |
| 3239 | + daemon_approve Approve the active pending action. |
| 3240 | + daemon_approve veto Veto the active pending action. |
| 3241 | + daemon_approve show Print the pending action (no decision). |
| 3242 | + |
| 3243 | +The active action lives in ``sessions/daemon_control.json`` |
| 3244 | +under ``pending`` and is created by the daemon when running in |
| 3245 | +approval mode. |
| 3246 | + |
| 3247 | +Args: |
| 3248 | + line: Optional sub-command. |
| 3249 | + |
3117 | 3250 | ## banner |
3118 | 3251 | Show the banner |
3119 | 3252 |
|
@@ -8955,16 +9088,23 @@ Parameters: |
8955 | 9088 | Return None |
8956 | 9089 |
|
8957 | 9090 | ## vulns |
8958 | | -Scan for vulnerabilities based on a provided service banner. |
| 9091 | +Search the NVD for CVEs matching a service banner and persist findings. |
8959 | 9092 |
|
8960 | | -This function initializes a vulnerability scanner and searches for CVEs (Common Vulnerabilities and Exposures) |
8961 | | -related to the specified service banner. If no service banner is provided, it prompts the user to enter one. |
| 9093 | +The configured ``rhost`` value from ``payload.json`` is used as |
| 9094 | +the target identifier for the persisted JSON report. The scanner |
| 9095 | +respects the operator's ``user_agent_lin`` setting when present |
| 9096 | +so reconnaissance traffic shares the same fingerprint across the |
| 9097 | +framework. |
8962 | 9098 |
|
8963 | 9099 | Args: |
8964 | | - line (str): The service banner to search for vulnerabilities. If not provided, the user will be prompted to enter one. |
| 9100 | + line: Optional service banner. When empty the operator is |
| 9101 | + prompted interactively; the input is stripped of |
| 9102 | + surrounding whitespace before being sent to the NVD. |
8965 | 9103 |
|
8966 | 9104 | Returns: |
8967 | | - None |
| 9105 | + None. Results are printed to the shell and persisted to |
| 9106 | + ``sessions/vulns_<rhost>.json`` so the reactive engine and |
| 9107 | + report generator can consume them without re-scanning. |
8968 | 9108 |
|
8969 | 9109 | Example: |
8970 | 9110 | do_vulns "ProFTPD 1.3.5" |
|
0 commit comments