Commit Graph

25 Commits

Author SHA1 Message Date
Lee Chagolla-Christensen 30943c819a Add DISABLE_AUTH env var to disable Traefik basic auth
- Add compose.noauth.yaml that redefines the auth middleware as a no-op headers middleware
- Read DISABLE_AUTH from .env in nemesis-ctl.sh and conditionally layer compose.noauth.yaml
- Make dev compose files explicit so the noauth overlay layers correctly
- Fix frontend labels in compose.override.yaml to include full traefik label set
- Document DISABLE_AUTH in env.example
2026-02-10 23:30:49 -08:00
Lee Chagolla-Christensen 9d62493623 Type checker, reg parsing improvements, UI improvements (#101)
* fix: upgrade python-multipart to 0.0.22 to address CVE-2026-24486 (Dependabot #683)

* update deps+skill, pyright

* pyright + tests in CLI

* Add pyright type checking and enhance registry hive analysis

Registry Hive Analyzer Enhancements:
- Extract machine SID from SAM domain V value with binary SID decoding
- Extract per-user metadata via regipy (ACB flags, timestamps, full
  name, comment via USER_ACCOUNT_V)
- Compute password expiration from domain max password age policy
- Detect empty LM/NT hashes via well-known constants
- Parse DCC cached domain credentials into structured entries
- Store DPAPI system machine_key/user_key as separate fields
- Add structured secret_type field to LSA secrets (dcc, dpapi_system,
  hex_blob, generic)
- Add detailed markdown and plain-text formatters for SAM accounts
  and LSA secrets, replacing _get_lsa_secret_output_string
- Fix SYSTEM hive attribute names: computer_name -> machinename,
  current_control_set -> currentcontrol
- Switch SAM user iteration from sam.users to sam.secrets (pypykatz API)
- Add FILETIME-to-UTC and regipy value-to-bytes helpers

New Tests:
- Add test_registry_hive.py with SAM, SECURITY, and SYSTEM hive fixtures
- Add test_container.py for container analyzer
- Add SAM/SECURITY/SYSTEM binary test fixtures

Pyright Setup:
- Add pyrightconfig.json (basic mode, Python 3.13) to all libs and projects
- Add pyright>=1.1 as dev dependency to all pyproject.toml files
- Update all uv.lock files accordingly
- Update lint.sh to deactivate active venvs and verify pyright availability

Type Annotation Fixes:
- Fix globals initialized as None without Optional type across
  file_enrichment, document_conversion, and agents global_vars
- Fix StorageMinio return types: upload/upload_file/upload_uploadfile
  return str, not uuid.UUID
- Fix MockStorageMinio to match updated StorageMinio return types
- Add explicit type annotations to dict literals in chromekey.py,
  pdf/analyzer.py, registry_hive/analyzer.py, and publish_findings.py
- Fix kubeconfig current_context parameter to accept str | None
- Fix container_contents allowed_extensions: set = None -> set | None = None
- Fix file subscription file_queue: asyncio.Queue = None -> asyncio.Queue | None = None
- Fix web_api upload_file to wrap object_id in uuid.UUID() for response

None-safety Assertions:
- Add assert statements for asyncpg_pool, tracking_service,
  workflow_client, workflow_manager, file_linking_engine, file_queue,
  gotenberg_url, and process.stdout across all activity, subscription,
  route, and workflow files in file_enrichment and document_conversion
- Add assertions for asyncpg_pool in all chromium processors
- Add assertions for File.from_metadata timestamp/expiration fields
- Add assertion for alerting GQL client session type

Pyright Ignore Annotations:
- Suppress third-party type issues in Dapr workflow/activity APIs,
  gRPC subscription imports, ccache/lnk/office_doc attribute access,
  and nemesis_dpapi FlagMixin operators
- Add file-level suppression for office2john.py, pdf2john.py,
  pe/analyzer.py, and test harness files

Bug Fixes:
- Fix office2john.py format string: bare % filename -> % (filename, stream)
- Fix container analyzer 7z iteration: iterate sz.files list instead
  of calling .items()
- Fix file_linking rules_engine: store match result to avoid double call
- Fix logger.exception calls: remove exception object as first arg in
  storage.py, cookies.py, enrichments.py, housekeeping/main.py
- Fix document_conversion lifespan: use stack.callback() for sync shutdown
- Fix NoseyParkerOutput fallback: add missing workflow_id field
- Fix regipy hive_type: handle None return from RegistryHive.hive_type

DPAPI Manager:
- Remove unused guid parameter from get_system_credentials across
  DpapiManager, NullDpapiManager, and DpapiManagerProtocol

Added Missing Dependencies (file_enrichment_modules):
- pypykatz>=0.6.11, pyarrow>=19.0.1, msoffcrypto-tool>=5.4.2,
  oletools>=0.60.2, regipy>=5.2.0, pillow>=11.3.0

* quiet console logs

* feat: lazy file loading with backend range request support

Add offset/length query params to the download endpoint so the frontend
can request partial file content.  FileViewer now fetches data on demand
— hex, transform (Strings, etc.), ZIP, SQLite, and image tabs only load
when activated.  Text-based content is capped at 10 MB previews.

* fix: transform tabs stuck on "Loading content..."

- Prevent stale WS subscription from overwriting fetched content
- Show retry button when transform content fails to load
- Reset fetch guard on non-OK HTTP responses

* fix: hex tab deferred loading with full file content

* feat: truncation dropdown, spinner overlay, and tab render refactor

- Add truncation dropdown to MonacoContentViewer for files > 10MB,
  replacing the old banner alert and hex "Load Hex View" button
- Add spinner overlay on Monaco editor while loading full content
- Wire truncation support to transform tabs (monaco/json types),
  enrichment tabs, and text tabs
- Change hex tab to auto-load first 10MB preview with dropdown for
  full file instead of requiring manual load
- Default word wrap to off
- Remove "File is too large" warning message
- Refactor ~150-line ternary chain into explicit per-tab render
  functions (renderPreviewTab, renderZipTab, renderSqliteTab,
  renderTextTab, renderHexTab, renderTabContent) with shared helpers
  (renderFullFileContent, getTextContent)

* feat: improve Yara Rules UI

- Compact table rows with tighter padding
- Add X button and Esc key to close editor dialog
- Disable Save button when rule content is unchanged
- Disable Create button with inline warning when rule name already exists
- Default source to "Created manually by <user>" for new rules
- Update source placeholder to "e.g. /yara_rules/custom.yara"

* update gitignore

---------

Co-authored-by: Lee Chagolla-Christensen <lee@localhost>
2026-02-05 14:34:25 -08:00
Lee Chagolla-Christensen 2a028adb7e linting, lint+test scripts 2026-02-04 09:44:26 -08:00
Lee Chagolla-Christensen 3d8336977d Python 3.13, linting/quality, and agent reliability
- Raise requires-python to >=3.13 across all projects/libs; set ruff target to py313
- Fix bare excepts, unused variables/imports, Optional→union syntax, and import ordering
- Refactor chatbot MCP server to async subprocess with health checks and graceful shutdown
- Simplify file-enrichment prod Dockerfile to use uv sync with UV_PROJECT_ENVIRONMENT
- Fix module_loader to use fully qualified analyzer module name
- Make YARA _analyze_yara async and fix rule_manager access in workflow
- Enable LiteLLM healthcheck and add agents→litellm dependency
- Add PE analyzer tests with PyInstaller fixture;
- Update PDF tests for nested metadata
- Suppress third-party DeprecationWarnings, use async-lru for LLM status cache
- Add PHOENIX_ENABLED validation to nemesis-ctl.sh; remove debug pprint in agents
- Add Claude Code managing-packages skill, update CLAUDE.md guidance
2026-02-03 20:36:12 -08:00
Lee Chagolla-Christensen 67f874fcbe python 3.14.2, fix enrichment status bugs 2026-01-14 22:14:41 -08:00
Lee Chagolla-Christensen b5b00ca72a Migrate to uv from poetry (#99)
* initial uv migration

* update github workflows

* use python module not system commands

* remove poetry references

* fix uv in prod images

---------

Co-authored-by: Lee Chagolla-Christensen <lee@localhost>
2026-01-14 15:20:31 -08:00
Lee Chagolla-Christensen fe743d794d Minor fixes updates (#94)
* workflow purge errors with replicas, doc updates

* fix masterkeys page

* update readme

* path linking bug in UI

---------

Co-authored-by: Lee Chagolla-Christensen <lee@localhost>
2025-11-13 12:06:26 -08:00
harmj0y 75037a4b5d Exposed Nemesis MCP
- Exposed Nemesis Postgres MCP on /mcp route
- Added `tools/mcp_bridge.py`
2025-11-08 14:54:44 -08:00
Lee Chagolla-Christensen 58dd461532 Refactor document conversion service into Dapr workflow
- Restructure document_conversion to match into workflow structure
- PDF analyzer: use PyMuPDF and extract extensive metadata
- Add PDF test suite with encrypted/unencrypted fixtures
- Add Tika Tesseract OCR configuration support example
- Update Dapr configurations for new document_conversion component
- Remove deprecated helpers from common lib
- Update queue constants and workflow setup
2025-11-06 01:30:10 -08:00
Lee Chagolla-Christensen 6ec0a3b61a Workflow performance improvements (#87)
* upgrade to dapr postgresv2 statestore

* actually make it v2

* dapr state table name, cleanup subscriptions/globals

* proper exceptions

* formatting/lint

* Refactor workflow tracking and improve activity input handling

- Extract workflow tracking logic into dedicated WorkflowTrackingService
- Simplify activity signatures to accept specific parameters instead of generic dicts
- Remove unused asyncio event loop references from enrichment modules
- Update YaraRuleManager initialization and method names

* re-added workflow tracking in the DB

* update uvicorn prod options

* enrichment work parallelism, convert queues from broadcast to task queues

* Refactor pubsub and improve workflow parallelism

- Split Dapr pubsub Dapr yaml components into topic-specific queues (alerting, dotnet, dpapi, files, noseyparker, workflow_monitor)
- Update all Dapr volume mounts to reference new topic-specific pubsub components
- Converted queues to task queues
- Use YAML anchors to reduce duplication for file-enrichment replicas
- Pass asyncpg pool to enrichment modules instead of creating connections
- Add asyncpg_pool parameter throughout chromium and enrichment module analyzers
- Update VSCode workspace (removed InspectAssembly, renamed dotnet_api to dotnet_service)
- Added curl commands for Jaeger API to performance docs to help with perf troubleshooting
- Created common.queues module to centralize pubsub/topic names (eases
  future refactoring)

* worker mods

* Workflow performance tuning, fix pubsub config, CLI arg changes

- Fix pubsub deleteWhenUnused typo (deletedWhenUnused)
- Add LOG_LEVEL environment variable support across services
- CLI: Rename --repeat to --times, add --max-files option
- Increase files pubsub prefetchCount from 25 to 50
- Add MAX_PARALLEL_WORKFLOWS configuration
- Fix DotNetAssemblyAnalysis null handling with field validators
- Update dashboard to show cumulative files/findings over time
- Add RUST_LOG environment variable support to noseyparker
- Update CHANGELOG for 2.1.4 release notes

* Dapr 1.16.2 and use db transactions

- Upgrade all Dapr containers from 1.16.1 to 1.16.2
- Reduce enrichment parallelism default from 25 to 5 workflows
- Reduce healthcheck intervals from 10s to 5s for alerting and document conversion
- Fixed DPAPI eventing to use new pubsubs
- Refactor file_linking database operations to use atomic upserts and avoid deadlocks
- Add WriteOnceViolationError handling in DPAPI masterkey analyzer
- Wrap database operations in transactions for enrichment storage and plaintext indexing
- Fix postgres notification handler closure variable capture

* remove unused start_time

* Scheduler persistence, workflow concurrency tuning, and config cleanup

- Add volume for Dapr scheduler and init service
- Add scheduler dependency to file enrichment service
- Add async workflow client libraries
- Format and cleanup compose.yaml (spacing, indentation, empty lines)

* Migrate file_enrichment to async Dapr client and optimize Dockerfile

- Use async DaprClient where possible in file_enrichment
- Improve Dockerfile caching
- Add asyncpg connection pool helper and fix typo in secret store name
- Include VS Code debug configuration for document_conversion
- Remove unused dapr_client from DpapiBlobAnalyzer
- Clean up activity return types and better handle exceptions

* Enrichment tracking for NoseyParker and logging cleanup

- Add workflow_id to NoseyParkerInput and NoseyParkerOutput models
- Remove workflow lookup query in noseyparker subscription handler
- Adjust jaeger_perf_stats.sh output formatting and precision
- Add type hints for async functions

* noseyparker scanner perf, tracing for update_enrichment_results

---------

Co-authored-by: Lee Chagolla-Christensen <lee@localhost>
2025-11-04 14:06:59 -08:00
Lee Chagolla-Christensen a22218fcef fix ruff/tests in project, install venv script, local state link to user masterkey, masterkey type from path 2025-10-10 14:16:52 -07:00
Lee Chagolla-Christensen 77a10a75fb add repositories 2025-09-08 16:38:23 -07:00
Lee Chagolla-Christensen 27fe8d7cea file-enrichment linting/formatting, update clean_dev_docker.sh 2025-09-08 16:05:08 -07:00
Lee Chagolla-Christensen d08dcf8a96 Merge branch 'nemesis-2.1.3' of github.com:SpecterOps/Nemesis into nemesis-2.1.3
Rename DpapiCryptoError, formatting/linting
2025-09-07 09:33:24 -07:00
harmj0y 40902d9d8f Version 2.1.3
- See CHANGELOG.md for summary of changes
2025-08-29 15:24:32 -07:00
Lee Chagolla-Christensen 65dba88e09 Merge branch 'docker_compose' of github.com:SpecterOps/Nemesis into docker_compose 2025-06-26 17:52:56 -07:00
Lee Chagolla-Christensen 60d57379a6 update helper scripts + cli.md 2025-06-26 17:52:47 -07:00
harmj0y 5e67d15b59 Fix for ./tools/nemesis-ctl.sh for macOS
-Fix for `./tools/nemesis-ctl.sh` for macOS
2025-06-26 16:02:17 -07:00
Lee Chagolla-Christensen 204d12bd67 fix submit.sh 2025-06-26 14:16:37 -07:00
Lee Chagolla-Christensen a2796a940b nemesis-ctl, fix cli compose 2025-06-26 12:29:48 -07:00
Lee Chagolla-Christensen 9908a7a992 update start.sh 2025-06-25 22:27:02 -07:00
harmj0y 8e39993883 Fix in start.sh for macOS
-Fix in start.sh for macOS
2025-06-25 10:43:48 -07:00
Lee Chagolla-Christensen c0be9129ee update starth 2025-06-25 10:22:30 -07:00
Lee Chagolla-Christensen 4fc163a31f docker compose updates 2025-06-24 18:04:52 -07:00
Lee Christensen 8035a6a168 add code 2025-06-13 11:33:07 +02:00