You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updated SKILLS.md with expanded architecture, configuration, and development guidance for CAPE Sandbox v2. Added references to documentation, clarified directory structure, core workflows, and best practices. Included new sections on configuration management, adding modules (signatures, processing, reporting, machinery, packages), performance, security, and advanced debugging. Improved troubleshooting steps and command references for developers.
This document outlines the architectural structure, core concepts, and development patterns for the CAPE Sandbox (v2). It serves as a guide for extending functionality, debugging, and maintaining the codebase.
4
4
5
+
> **Agent Hint:** Use the referenced documentation files (`docs/book/src/...`) to dive deeper into specific topics.
6
+
5
7
## 1. Project Overview
6
8
CAPE (Config And Payload Extraction) is a malware analysis sandbox derived from Cuckoo Sandbox. It focuses on automated malware analysis with a specific emphasis on extracting payloads and configuration from malware.
7
9
10
+
***Ref:**`docs/book/src/introduction/what.rst`
11
+
8
12
**Core Tech Stack:**
9
13
-**Language:** Python 3
10
14
-**Web Framework:** Django
11
15
-**Database:** PostgreSQL (SQLAlchemy) for task management, MongoDB/Elasticsearch for results storage.
* Sample is injected/executed using specific **Analysis Packages** (`analyzer/windows/modules/packages/`).
47
+
***Ref:**`docs/book/src/usage/packages.rst`
36
48
* Behavior is monitored via API hooking (CAPE Monitor).
37
-
4.**Result Collection:** Logs, PCAP, and dropped files are transferred back to Host.
38
-
5.**Processing:**`modules/processing/` parses raw logs into a structured dictionary.
39
-
6.**Signatures:**`modules/signatures/` runs logic against the processed data.
40
-
7.**Reporting:**`modules/reporting/` exports data (JSON, HTML, MongoDB, MAEC).
41
-
42
-
### B. Web Interface Architecture
43
-
The Web UI is split into two distinct rendering logic paths:
44
-
1.**Django Views (`web/analysis/views.py`):** Handles URL routing, authentication, and context generation. It fetches data from MongoDB/Elasticsearch.
45
-
2.**Jinja2 Templates:**
46
-
***Web Templates (`web/templates/`):** Standard Django templates for the UI.
47
-
***Report Templates (`data/html/`):** Standalone Jinja2 templates used by the `reporthtml` module to generate static HTML reports. *Note: Changes here affect the downloadable HTML report, not necessarily the Web UI.*
48
-
49
-
## 4. Development Guides
49
+
***Auxiliary Modules** (`modules/auxiliary/`) run in parallel on the Host (e.g., Sniffer).
50
+
5.**Result Collection:** Logs, PCAP, and dropped files are transferred back to Host.
51
+
6.**Processing:**`modules/processing/` parses raw logs into a structured dictionary (Global Container).
52
+
7.**Signatures:**`modules/signatures/` runs logic against the processed data.
53
+
8.**Reporting:**`modules/reporting/` exports data (JSON, HTML, MongoDB, MAEC).
54
+
55
+
## 4. Configuration Management
56
+
***Overrides:** Never edit files in `conf/` directly. Create a copy in `custom/conf/` with the same name.
57
+
***Environment Variables:** You can use env vars in configs: `%(ENV:VARIABLE_NAME)s`.
58
+
***Conf.d:** You can create directories like `custom/conf/reporting.conf.d/` and add `.conf` files there for granular overrides.
***Coding Style:** See `docs/book/src/development/code_style.rst`
63
+
64
+
### Coding Standards (PEP 8+)
65
+
***Imports:** Explicit imports only (`from lib import a, b`). No `from lib import *`. Group standard library, 3rd party, and local imports.
66
+
***Strings:** Use double quotes (`"`) for strings. (This line was corrected from the original prompt to reflect the actual change needed for the example.)
67
+
***Logging:** Use `import logging; log = logging.getLogger(__name__)`. Do not use `print()`.
68
+
***Exceptions:** Use custom exceptions from `lib/cuckoo/common/exceptions.py` (e.g., `CuckooOperationalError`).
1.**Conditionally Render:** Always check if a dictionary key exists in templates (`{% if analysis.key %}`) before rendering to avoid UI breaks on different analysis types (Static vs Dynamic).
163
+
2.**Keep Views Light:** Perform heavy data crunching in `modules/processing`, not in Django views.
164
+
3.**Modular CSS/JS:** Keep custom styles in `web/static/` rather than inline in templates when possible.
165
+
166
+
### Performance
167
+
1.**Evented Signatures:** Use `evented = True` and `on_call()` in signatures to process API calls in a single loop instead of iterating the whole log multiple times.
168
+
2.**Ram-boost:** Enable `ram_boost` in `processing.conf` behavior section to keep API logs in memory if the Host has >20GB RAM.
169
+
3.**Disable Unused Reports:** Disable heavy reporting modules (e.g., HTML, MAEC) in `reporting.conf` if not strictly needed for automation.
170
+
171
+
### Security
172
+
1.**Guest Isolation:** Always use static IPs and consider isolated/host-only networks. Disable noisy services (LLMNR, Teredo) in Guest to reduce PCAP noise.
173
+
2.**Stealth:** Use the `no-stealth` option sparingly. CAPE's anti-anti-VM features are enabled by default and are critical for modern malware.
89
174
90
-
## 5. Troubleshooting & Debugging
175
+
## 7. Troubleshooting & Debugging
176
+
***Ref:**`docs/book/src/Issues/Debugging_VM_issues.rst` (VM hangs, High CPU)
1. **Conditionally Render:** Always check if a dictionary key exists in templates before rendering to avoid UI breaks on different analysis types (Static vs Dynamic).
111
-
2. **Keep Views Light:** Perform heavy data crunching in`modules/processing`, not in Django views.
112
-
3. **Modular CSS/JS:** Keep custom styles in`web/static/` rather than inline in templates when possible.
0 commit comments