Skip to content

Agent KB_core

grisun0 edited this page Oct 16, 2026 · 20 revisions

Subsystem: core (page 1 of 2)

Pages: KB_core.md, KB_core_p2.md

core/init.py

core/api_authz.py

  • Doc: Tenant-bound API authorization for the LazyOwn C2 dashboard.
  • Layer: presentation
  • Language: py
  • Symbols:
    • ApiAuthzConfig (class, line 54) class ApiAuthzConfig
    • ApiKey (class, line 75) class ApiKey
    • _hash_secret (function, line 137) def _hash_secret(secret)
    • _verify_secret (function, line 142) def _verify_secret(secret, stored_hash)
    • _generate_token_bytes (function, line 147) def _generate_token_bytes(nbytes)
    • ApiKeyStore (class, line 161) class ApiKeyStore
    • require_api_auth (function, line 365) def require_api_auth(store, permissions, require_tenant)
    • create_api_token (function, line 440) def create_api_token(store, tenant_id, label, permissions, expires_in_days)
    • to_dict (method, line 94) def to_dict(self)
    • from_dict (method, line 107) def from_dict(cls, data)
    • is_expired (method, line 119) def is_expired(self)
    • is_retired (method, line 124) def is_retired(self)
    • has_permission (method, line 127) def has_permission(self, permission)
    • has_all_permissions (method, line 130) def has_all_permissions(self, permissions)
    • __init__ (method, line 170) def __init__(self, config)
    • config (method, line 176) def config(self)
    • _read (method, line 180) def _read(self)
    • _write (method, line 191) def _write(self, data)
    • _grace_deadline (method, line 197) def _grace_deadline(self, retired_at)
    • _prune_retired (method, line 201) def _prune_retired(self, records)
    • list_keys (method, line 217) def list_keys(self, tenant_id)
    • find_by_hash (method, line 229) def find_by_hash(self, key_hash)
    • create_key (method, line 238) def create_key(self, tenant_id, label, permissions, expires_in_days)
    • revoke_key (method, line 273) def revoke_key(self, label, tenant_id)
    • validate_key (method, line 287) def validate_key(self, plaintext)
    • rotate_key (method, line 309) def rotate_key(self, label, tenant_id)
    • _prune_record (method, line 343) def _prune_record(self, key_hash)
    • _touch_last_used (method, line 351) def _touch_last_used(self, key_hash)
    • _extract_key (function, line 393) def _extract_key(request_obj)
    • decorator (function, line 405) def decorator(f)
    • decorated (function, line 407) def decorated()
  • Imported by: lazyc2/app_factory.py, lazyc2/blueprints/api.py, tests/test_api_authz.py, tests/test_api_v1.py

core/autonomous.py

core/command_bridge.py

  • Doc: Lightweight command execution bridge between C2 bots and the LazyOwn CLI shell.
  • Layer: utility
  • Language: py
  • Symbols:
    • CommandBridge (class, line 15) class CommandBridge
    • get_bridge (function, line 126) def get_bridge()
    • __init__ (method, line 18) def __init__(self)
    • ready (method, line 25) def ready(self)
    • error (method, line 30) def error(self)
    • _ensure_shell (method, line 34) def _ensure_shell(self)
    • onecmd (method, line 65) def onecmd(self, command)
    • one_cmd (method, line 89) def one_cmd(self, command)
    • execute (method, line 110) def execute(self, command)
  • Depends on: lazyown.py
  • Imported by: tests/test_core_command_bridge.py

core/config.py

core/console.py

core/credential_vault.py

  • Doc: Credential vault — AES-256-GCM encryption for sensitive config values.
  • Layer: utility
  • Language: py
  • Symbols:
    • check_dangerous_defaults (function, line 63) def check_dangerous_defaults(payload)
    • _get_aes_key (function, line 79) def _get_aes_key(payload)
    • seal_value (function, line 93) def seal_value(plaintext, key)
    • unseal_value (function, line 112) def unseal_value(sealed, key)
    • seal_payload (function, line 141) def seal_payload(payload, key)
    • unseal_payload (function, line 164) def unseal_payload(payload, key)
    • rotate_aes_key (function, line 186) def rotate_aes_key(payload, current_key)
    • generate_secure_defaults (function, line 215) def generate_secure_defaults()
  • Depends on: core/config.py, core/crypto.py, core/logging.py
  • Imported by: cli/commands/security.py, core/hardening.py, lazyown.py, tests/test_credential_vault.py

core/crypto.py

core/defaults.py

core/dependencies.py

  • Doc: Graceful optional-import handling for heavy third-party dependencies.
  • Layer: utility
  • Language: py
  • Symbols:
    • MissingDependencyError (class, line 37) class MissingDependencyError(ImportError)
    • DependencySpec (class, line 66) class DependencySpec
    • _DeferredImport (class, line 101) class _DeferredImport
    • _spec_for (function, line 157) def _spec_for(import_name, pip_package, feature)
    • optional_import (function, line 183) def optional_import(import_name)
    • optional_attr (function, line 209) def optional_attr(import_name, attr)
    • DependencyStatus (class, line 253) class DependencyStatus
    • DependencyReport (class, line 268) class DependencyReport
    • probe_python_dependency (function, line 288) def probe_python_dependency(spec)
    • collect_dependency_report (function, line 312) def collect_dependency_report()
    • format_report (function, line 323) def format_report(report)
    • main (function, line 368) def main()
    • __init__ (method, line 45) def __init__(self, import_name, pip_package, feature)
    • __init__ (method, line 115) def __init__(self, spec)
    • _raise (method, line 123) def _raise(self)
    • __getattr__ (method, line 132) def __getattr__(self, _name)
    • __call__ (method, line 136) def __call__(self)
    • __getitem__ (method, line 140) def __getitem__(self, _key)
    • __iter__ (method, line 144) def __iter__(self)
    • __len__ (method, line 148) def __len__(self)
    • __bool__ (method, line 152) def __bool__(self)
    • missing (method, line 278) def missing(self)
    • ok (method, line 283) def ok(self)
  • Imported by: core/__init__.py, tests/test_dependencies.py, utils.py

core/error_advice.py

  • Doc: Actionable error advice with fix command and documentation link.
  • Layer: utility
  • Language: py
  • Symbols:
    • ErrorAdviceConfig (class, line 16) class ErrorAdviceConfig
    • ErrorAdvice (class, line 27) class ErrorAdvice
    • get_advice (function, line 74) def get_advice(key)
    • render_advice (function, line 86) def render_advice(key, config)
    • docs_url (method, line 35) def docs_url(self, config)
  • Depends on: core/console.py

core/errors.py

  • Doc: Error taxonomy for the LazyOwn framework.
  • Layer: utility
  • Language: py
  • Symbols:
    • ErrorCode (class, line 10) class ErrorCode(IntEnum)
    • LazyOwnError (class, line 58) class LazyOwnError(Exception)
    • ConfigError (class, line 78) class ConfigError(LazyOwnError)
    • TargetError (class, line 85) class TargetError(LazyOwnError)
    • AuthError (class, line 92) class AuthError(LazyOwnError)
    • ToolError (class, line 99) class ToolError(LazyOwnError)
    • PayloadError (class, line 106) class PayloadError(LazyOwnError)
    • DatabaseError (class, line 113) class DatabaseError(LazyOwnError)
    • NetworkError (class, line 120) class NetworkError(LazyOwnError)
    • PermissionError (class, line 127) class PermissionError(LazyOwnError)
    • ValidationError (class, line 134) class ValidationError(LazyOwnError)
    • __init__ (method, line 61) def __init__(self, message, error_code)
    • to_dict (method, line 66) def to_dict(self)
    • __str__ (method, line 74) def __str__(self)
    • __init__ (method, line 81) def __init__(self, message, error_code)
    • __init__ (method, line 88) def __init__(self, message, error_code)
    • __init__ (method, line 95) def __init__(self, message, error_code)
    • __init__ (method, line 102) def __init__(self, message, error_code)
    • __init__ (method, line 109) def __init__(self, message, error_code)
    • __init__ (method, line 116) def __init__(self, message, error_code)
    • __init__ (method, line 123) def __init__(self, message, error_code)
    • __init__ (method, line 130) def __init__(self, message, error_code)
    • __init__ (method, line 137) def __init__(self, message, error_code)
  • Depends on: cli/commands/enum.py
  • Imported by: core/__init__.py

core/executor.py

  • Doc: Centralised subprocess wrapper for the LazyOwn framework.
  • Layer: utility
  • Language: py
  • Symbols:
    • _validate_input (function, line 41) def _validate_input(command)
    • _validate_timeout (function, line 75) def _validate_timeout(timeout)
    • safe_run (function, line 96) def safe_run(command)
    • safe_run (function, line 98) def safe_run(command)
    • safe_run (function, line 101) def safe_run(command)
    • run_shell (function, line 149) def run_shell(cmd)
  • Depends on: core/logging.py
  • Imported by: tests/test_core_executor.py

core/hardening.py

core/host_policy.py

  • Doc: Single source of truth for host and network shape validation.
  • Layer: business_logic
  • Language: py
  • Symbols:
    • rejects_shell_meta (function, line 20) def rejects_shell_meta(value)
    • is_valid_cidr (function, line 32) def is_valid_cidr(value)
    • is_valid_host (function, line 48) def is_valid_host(value)
  • Imported by: core/hardening.py, core/validators.py, tests/test_host_policy.py

core/http.py

  • Doc: HTTP and API utilities for the LazyOwn framework.
  • Layer: presentation
  • Language: py
  • Symbols:
    • generate_http_req (function, line 18) def generate_http_req(host, port, uri, custom_header, cmd)
    • get_banner (function, line 50) def get_banner(host, port)
    • get_command (function, line 69) def get_command(url, lhost)
    • send_command (function, line 87) def send_command(cmd, url, lhost)
    • exploitalert (function, line 106) def exploitalert(content)
    • packetstormsecurity (function, line 125) def packetstormsecurity(content)
    • nvddb (function, line 143) def nvddb(content)
    • scrape_news (function, line 174) def scrape_news()
    • display_news (function, line 198) def display_news(titles, links, scores)
    • inject_payloads (function, line 211) def inject_payloads(urls, payload_url, request_timeout)
  • Depends on: core/console.py
  • Imported by: core/__init__.py

core/llm_budget.py

  • Doc: LLM budget cap and per call token counter.
  • Layer: utility
  • Language: py
  • Symbols:
    • BudgetExceeded (class, line 54) class BudgetExceeded(RuntimeError)
    • LLMBackendLike (class, line 58) class LLMBackendLike(Protocol)
    • ModelPrice (class, line 69) class ModelPrice
    • BudgetConfig (class, line 103) class BudgetConfig
    • LedgerEntry (class, line 132) class LedgerEntry
    • _today_utc (function, line 150) def _today_utc(now)
    • _now_iso (function, line 163) def _now_iso(now)
    • BudgetLedger (class, line 176) class BudgetLedger
    • TokenEstimator (class, line 268) class TokenEstimator
    • BudgetGuard (class, line 310) class BudgetGuard
    • BudgetedBackend (class, line 408) class BudgetedBackend
    • default_model_prices (function, line 442) def default_model_prices()
    • default_sessions_dir (function, line 461) def default_sessions_dir()
    • _coerce_bool (function, line 476) def _coerce_bool(value, default)
    • _coerce_price_table (function, line 496) def _coerce_price_table(value)
    • _coerce_positive_float (function, line 520) def _coerce_positive_float(value, default)
    • _coerce_positive_int (function, line 536) def _coerce_positive_int(value, default)
    • load_budget_config (function, line 552) def load_budget_config(payload, sessions_dir)
    • read_budget_status (function, line 585) def read_budget_status(payload, sessions_dir)
    • format_budget_status (function, line 616) def format_budget_status(config, ledger)
    • _has_required_methods (function, line 642) def _has_required_methods(backend)
    • wrap_backend_with_budget (function, line 657) def wrap_backend_with_budget(backend, config, estimator, model, ledger)
    • generate (method, line 61) def generate(self, prompt)
    • stream_generate (method, line 63) def stream_generate(self, prompt)
    • complete (method, line 65) def complete(self, system, user, max_tokens, temperature)
    • from_mapping (method, line 81) def from_mapping(cls, data)
    • _empty_state (method, line 189) def _empty_state(self)
    • _load (method, line 193) def _load(self)
    • _save (method, line 215) def _save(self, state)
    • _state (method, line 226) def _state(self)
    • record (method, line 232) def record(self, entry)
    • spent_today (method, line 251) def spent_today(self)
    • calls_today (method, line 256) def calls_today(self)
    • reset (method, line 261) def reset(self)
    • __init__ (method, line 278) def __init__(self, encoding_name)
    • _load_encoding (method, line 283) def _load_encoding(encoding_name)
    • count (method, line 292) def count(self, text)
    • __init__ (method, line 319) def __init__(self, config, estimator, ledger)
    • price_for (method, line 329) def price_for(self, model)
    • estimate_cost (method, line 343) def estimate_cost(self, model, input_tokens, output_tokens)
    • estimate_and_check (method, line 356) def estimate_and_check(self, prompt, model, output_tokens)
    • __init__ (method, line 417) def __init__(self, inner, guard, model)
    • generate (method, line 422) def generate(self, prompt)
    • stream_generate (method, line 430) def stream_generate(self, prompt)
    • complete (method, line 435) def complete(self, system, user, max_tokens, temperature)
  • Imported by: cli/commands/ai.py, modules/llm_factory.py, skills/lazyown_mcp.py, tests/test_llm_budget.py

core/logging.py

core/network.py

  • Doc: Network primitives for the LazyOwn framework.
  • Layer: utility
  • Language: py
  • Symbols:
    • parse_ip_mac (function, line 18) def parse_ip_mac(input_string)
    • create_arp_packet (function, line 33) def create_arp_packet(src_mac, src_ip, dst_ip, dst_mac)
    • send_packet (function, line 66) def send_packet(packet, iface)
    • parse_proc_net_file (function, line 78) def parse_proc_net_file(file_path)
    • get_open_ports (function, line 105) def get_open_ports()
    • is_port_in_use (function, line 120) def is_port_in_use(port, host)
    • get_banner (function, line 134) def get_banner(ip, port)
    • get_network_info (function, line 154) def get_network_info()
  • Depends on: core/console.py
  • Imported by: core/__init__.py

core/parsers.py

core/payload_schema.py

  • Doc: Declarative schema and validation for [payload.json](https://github.com/grisuno/LazyOwn/blob/146a52570ef792d1ec01ec4d3709b0c159990e47/payload.json).
  • Layer: utility
  • Language: py
  • Symbols:
    • FieldKind (class, line 73) class FieldKind(StrEnum)
    • Severity (class, line 91) class Severity(StrEnum)
    • FieldSpec (class, line 100) class FieldSpec
    • ValidationIssue (class, line 142) class ValidationIssue
    • _validate_string (function, line 165) def _validate_string(value)
    • _validate_int (function, line 171) def _validate_int(value)
    • _validate_port (function, line 185) def _validate_port(value)
    • _validate_bool (function, line 195) def _validate_bool(value)
    • _validate_ip (function, line 212) def _validate_ip(value)
    • _validate_hostname (function, line 220) def _validate_hostname(value)
    • _validate_url (function, line 232) def _validate_url(value)
    • _validate_path (function, line 240) def _validate_path(value)
    • _validate_interface (function, line 246) def _validate_interface(value)
    • _validate_hex (function, line 254) def _validate_hex(value)
    • _validate_os_id (function, line 262) def _validate_os_id(value)
    • _validate_json_blob (function, line 268) def _validate_json_blob(value)
    • _validate_opaque (function, line 280) def _validate_opaque(_value)
    • _coerce_int (function, line 301) def _coerce_int(raw)
    • _coerce_bool (function, line 316) def _coerce_bool(raw)
    • _spec (function, line 335) def _spec(name, kind, default, description)
    • field_for (function, line 1582) def field_for(key)
    • coerce_value (function, line 1587) def coerce_value(key, raw)
    • validate_value (function, line 1610) def validate_value(key, value)
    • validate_payload (function, line 1684) def validate_payload(payload)
    • format_issue (function, line 1719) def format_issue(issue)
    • default_payload (function, line 1737) def default_payload()
    • categories (function, line 1745) def categories()
  • Depends on: cli/commands/enum.py, modules/llm_factory.py
  • Imported by: cli/assign.py, cli/commands/session_ops.py, cli/wizard.py, core/__init__.py, core/config.py, scripts/devtools/core_smoke.py, skills/lazyown_mcp.py, tests/test_core_config.py, tests/test_core_defaults.py, tests/test_infra_disposable.py, tests/test_payload_schema.py, tests/test_placeholder_coverage.py

core/process.py

core/profiles.py

  • Doc: Runtime profiles: light vs full installations.
  • Layer: utility
  • Language: py
  • Symbols:
    • active_profile (function, line 40) def active_profile()
    • is_light (function, line 59) def is_light()
    • specs_for_profile (function, line 64) def specs_for_profile(specs)
  • Imported by: cli/doctor.py, cli/wizard.py, tests/test_profiles.py

core/prompt.py

  • Doc: Prompt builder for LazyOwn CLI and C2 dashboard banner.
  • Layer: utility
  • Language: py
  • Symbols:
    • _load_prompt_payload (function, line 17) def _load_prompt_payload()
    • get_git_info (function, line 35) def get_git_info()
    • get_venv_info (function, line 60) def get_venv_info()
    • get_kernel (function, line 68) def get_kernel()
    • get_terminal_size (function, line 78) def get_terminal_size()
    • get_local_ips (function, line 87) def get_local_ips()
    • copy2clip (function, line 109) def copy2clip(text)
    • getprompt (function, line 127) def getprompt()
  • Depends on: core/config.py
  • Imported by: contrib/legacy/lazybinenc.py, key.py, static/js/quill-2.0.3.js

Next: KB_core_p2.md

Start

Wiki

Agent Docs

Recipes

Clone this wiki locally