Skip to content

Commit 36c259b

Browse files
committed
feat(feat): suggested commands \n\n Version: release/0.2.131 \n\n \n\n LazyOwn on HackTheBox: https://app.hackthebox.com/teams/overview/6429 \n\n LazyOwn/ https://grisuno.github.io/LazyOwn/ \n\n \n\n Fecha: mar 19 may 2026 23:05:50 -04 \n\n Hora: 1779246350
1 parent b4324b4 commit 36c259b

46 files changed

Lines changed: 68912 additions & 32898 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# Changelog
33

44

5+
### Nuevas características
6+
7+
### Otros
8+
9+
* * feat(feat): suggested commands \n\n Version: release/0.2.131 \n\n \n\n LazyOwn on HackTheBox: https://app.hackthebox.com/teams/overview/6429 \n\n LazyOwn/ https://grisuno.github.io/LazyOwn/ \n\n \n\n Fecha: mar 19 may 2026 23:05:50 -04 \n\n Hora: 1779246350
10+
11+
512
### Nuevas características
613

714
### Otros

CLAUDE.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ Critical keys:
8787
| `sleep`, `sleep_start` | Beacon jitter + auto-loop bootstrap delay |
8888
| `api_key` | Groq (used by `report.py`, AI agents) |
8989
| `enable_telegram_c2`/`discord_c2`/`ia`/`deepseek`/`cloudflare`/`run_in_memory`/`c2_implant_debug`/`c2_debug` | Feature flags |
90+
| `llm_backend` | LLM selection: `"auto"` (Groq when API key is set, else Ollama), `"groq"`, or `"ollama"` |
91+
| `llm_model_groq` | Model identifier passed to the Groq API (default `llama-3.3-70b-versatile`) |
92+
| `llm_model_ollama` | Model identifier passed to the Ollama API (default `deepseek-r1:1.5b`) |
93+
| `ollama_host` | Base URL of the Ollama daemon (default `http://localhost:11434`) |
9094
| `c2_daily_limit`, `c2_hour_limit`, `c2_login_limit` | flask-limiter strings |
9195
| `targets` | Multi-target list (status, ports, tags, notes) |
9296
| `rat_key` | XOR key for stub/beacon |
@@ -166,7 +170,7 @@ CLI and C2 both import `utils.py` + read `payload.json`. MCP reuses `LazyOwnShel
166170
### Adding a route — happy path
167171
1. Decide operator-only (`@requires_auth`) vs beacon-facing (apply both canonical path AND `f'{route_maleable}<...>'` alias).
168172
2. `render_template('foo.html', ctx=...)` — typed context, not raw request data.
169-
3. Validate paths/templates with `validate_route_path` + `validate_template_name` + `is_safe_template_path`. Never bypass.
173+
3. Validate paths/templates with `validate_route_path` + `validate_template_name` + `is_safe_template_path`. Never bypass. The canonical implementations live in `lazyc2/security/validators.py` (return `(bool, str)` tuples). Module-level shims in `lazyc2.py` wrap them as booleans for legacy callers — new code must consume the tuple form so the error string can be surfaced to the operator.
170174
4. Persist via existing helpers:
171175
- JSON: `load_routes`/`save_routes`, `load_short_urls`, etc. — atomic (`*.tmp``os.rename`, chmod 600).
172176
- SQLite: `sqlite3.connect(DB_PATH)` inside `with` blocks.
@@ -205,11 +209,15 @@ Only module both CLI and C2 import. Use existing helpers:
205209
| Input validation | `check_rhost`/`check_lhost`/`check_lport` |
206210
| Tmux bootstrap | `ensure_tmux_session(name)` |
207211
| Emails/users/creds | `generate_emails`/`get_users_dic`/`crack_password` |
212+
| Vulnerability scan + persist | `VulnerabilityScanner().search_cves(service)``.persist(service, target, cves)` writes `sessions/vulns_<target>.json` |
213+
| LLM backend | `from modules.llm_factory import get_llm_backend, try_get_llm_backend` — reads `llm_backend`/`llm_model_*`/`ollama_host` from `payload.json` and returns an `AIModel` that also structurally satisfies `core.protocols.LLMBackend` |
208214

209215
New helpers go here only if shared CLI↔C2. Feature-local helpers → `modules/<feature>.py`.
210216

211217
**Known issue**: two `class Config` defs in `utils.py` (3229, 3328). Second is duplicate — don't add a third; deduplicate first in a separate change before editing.
212218

219+
**LLM backends**: do **not** instantiate `GroqModel`/`OllamaModel` directly. Use `from modules.llm_factory import get_llm_backend` (raises) or `try_get_llm_backend` (returns `None` on failure). The factory reads `llm_backend`, `llm_model_groq`, `llm_model_ollama`, and `ollama_host` from `payload.json`, so swapping providers never requires a code change. Callers that pass an explicit `provider` argument should translate the legacy `groq`/`deepseek` identifiers via the `_PROVIDER_ALIAS` mapping declared next to each call site.
220+
213221
---
214222

215223
## 8. MCP — `skills/lazyown_mcp.py`
@@ -242,6 +250,7 @@ New helpers go here only if shared CLI↔C2. Feature-local helpers → `modules/
242250
| `logs/command_<tool>output<domain>.txt` | run_command CSV logger | facts_show |
243251
| `LazyOwn_session_report.csv` | every command | timeline_narrator, threat_model |
244252
| `credentials*.txt`, `hash*.txt` | reactive_engine, do_responder | later phases |
253+
| `vulns_<rhost>.json` | `do_vulns` via `utils.VulnerabilityScanner.persist` | `get_target_context`, reactive_engine, report generator |
245254
| `world_model.json` | autonomous_daemon | session_state, recommend_next |
246255
| `tasks.json` | campaign_tasks | sitrep, dashboard |
247256
| `objectives.jsonl` | inject_objective | autonomous_daemon |
@@ -343,6 +352,7 @@ When invoking Claude/Groq/Ollama (`lazyown_llm_ask`, `swan_run`, `hive_spawn`, `
343352
| New MCP tool | `skills/lazyown_mcp.py` |
344353
| New autonomous selector | subclass `BaseSelector` in `skills/autonomous_daemon.py` |
345354
| New AI agent persona | `skills/lazyown_groq_agents.py` registry |
355+
| New LLM backend | implement `AIModel` in `modules/ai_model.py`, register identifier in `modules/llm_factory.SUPPORTED_BACKENDS`, expose via the `_PROVIDER_ALIAS` mapping when callers need the legacy `groq`/`deepseek` identifiers |
346356
| New knowledge base | new parquet + `lazyown_parquet_query` mode |
347357
| New directory | create + `README.md` immediately |
348358

COMMANDS.md

Lines changed: 145 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,49 @@ Args:
4646
Returns:
4747
data unchanged — the hook must return PostcommandData.
4848

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+
4992
## _engagement_hook
5093
Post-command hook: biological curiosity reveal + VRI reward.
5194

@@ -3114,6 +3157,96 @@ Example:
31143157
Note:
31153158
Ensure that the `rhost` is valid by checking it with the `check_rhost` function before updating the prompt.
31163159

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+
31173250
## banner
31183251
Show the banner
31193252

@@ -8955,16 +9088,23 @@ Parameters:
89559088
Return None
89569089

89579090
## vulns
8958-
Scan for vulnerabilities based on a provided service banner.
9091+
Search the NVD for CVEs matching a service banner and persist findings.
89599092

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.
89629098

89639099
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.
89659103

89669104
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.
89689108

89699109
Example:
89709110
do_vulns "ProFTPD 1.3.5"

0 commit comments

Comments
 (0)