Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
548 commits
Select commit Hold shift + click to select a range
5876999
django 5 fixes + free_space_monitor
doomedraven Feb 6, 2025
ec00df4
ci: Update requirements.txt
actions-user Feb 6, 2025
ad650c5
Update pyproject.toml
doomedraven Feb 7, 2025
bdf5f43
Update scheduler.py
doomedraven Feb 7, 2025
3f4a4d1
pyinstaller (#2487)
doomedraven Feb 7, 2025
9f9902b
style: Automatic code formatting
actions-user Feb 7, 2025
6a20ee0
Update load_extra_modules.py
doomedraven Feb 7, 2025
7f5da6f
style: Automatic code formatting
actions-user Feb 7, 2025
ab10529
Update pyinstxtractor.py
doomedraven Feb 7, 2025
ec4c597
option to ignore_signals enabled by default
doomedraven Feb 7, 2025
863b853
style: Automatic code formatting
actions-user Feb 7, 2025
b87c0b2
malware bazaar apikey + some docs by copilot
doomedraven Feb 8, 2025
46c4d5f
style: Automatic code formatting
actions-user Feb 8, 2025
db1ab36
Update test_analysis_manager.py
doomedraven Feb 9, 2025
53c3106
playing with copilot for docs + tests (#2488)
doomedraven Feb 9, 2025
72ddfbe
style: Automatic code formatting
actions-user Feb 9, 2025
6bf8860
sync
doomedraven Feb 9, 2025
9e7c59d
style: Automatic code formatting
actions-user Feb 9, 2025
d646a4b
threatfox
Feb 11, 2025
2d4cdb1
threatfox
Feb 11, 2025
42ff0a6
Merge branch 'master' of github.com:kevoreilly/CAPEv2
doomedraven Feb 11, 2025
e968263
decode name on size error
doomedraven Feb 11, 2025
ada4c18
style: Automatic code formatting
actions-user Feb 11, 2025
bcb43ae
Update abstracts.py
doomedraven Feb 11, 2025
7a12e78
style: Automatic code formatting
actions-user Feb 11, 2025
24ca507
add ports to enriched hosts data
doomedraven Feb 11, 2025
7b76ace
Update objects.py
doomedraven Feb 11, 2025
318a462
magic cleanup
doomedraven Feb 11, 2025
9436fb6
Add Mandiant Intelligence API lookup (#2489)
enzok Feb 11, 2025
2941a69
style: Automatic code formatting
actions-user Feb 11, 2025
b66b7b2
selfextract conf renamed to integrations conf
doomedraven Feb 11, 2025
04955d8
try/except commit
doomedraven Feb 11, 2025
971fc5f
style: Automatic code formatting
actions-user Feb 11, 2025
2276808
pyre2
doomedraven Feb 11, 2025
abd7eb6
ci: Update requirements.txt
actions-user Feb 11, 2025
c01ab40
fix cryptography vuln
doomedraven Feb 11, 2025
4451402
ci: Update requirements.txt
actions-user Feb 11, 2025
f89c890
ruff
doomedraven Feb 12, 2025
df2152c
peepdf update and test (#2491)
enzok Feb 12, 2025
2f25345
sync (#2490)
doomedraven Feb 12, 2025
c636963
Fix template _subfile_info.html (#2495)
ClaudioWayne Feb 17, 2025
c85a484
admin_utils.py fix
doomedraven Feb 17, 2025
d7519b0
fix yara_details for subfiles (#2496)
ClaudioWayne Feb 17, 2025
1ab9a14
unify abusech config
doomedraven Feb 18, 2025
8f6768d
fix LibvirtGLib
doomedraven Feb 19, 2025
b93ca6c
Merge branch 'master' of github.com:kevoreilly/CAPEv2
doomedraven Feb 19, 2025
2e5f9d6
A couple of ruff %s fixes were missed
rkoumis Feb 20, 2025
48b3638
Merge pull request #2498 from rkoumis/ruff-follow-up
kevoreilly Feb 20, 2025
33a91c4
fix peer address parse (#2499)
karlhiramoto Feb 24, 2025
85102a7
fix tun logging (#2500)
karlhiramoto Feb 25, 2025
7065425
Monitor updates: see changelog for details
kevoreilly Feb 26, 2025
6751aad
Rebuild monitors
kevoreilly Feb 26, 2025
7d85f06
Monitor update: Improve handling of bogus VirtualSize values in PE se…
kevoreilly Feb 27, 2025
a798e3c
Monitor: Further small refinement to PE section table parsing
kevoreilly Feb 27, 2025
f256c32
Monitor updates: see changelog for details
kevoreilly Feb 28, 2025
c7fea21
Staging (#2494)
doomedraven Mar 1, 2025
ba61597
Replace apt-get with apt and enforce sudo and -y usage in installer/c…
t-mtsmt Mar 1, 2025
0a2a93f
add rtf file test (#2503)
doomedraven Mar 2, 2025
bbad628
gemini config
doomedraven Mar 3, 2025
e4e80e8
Fix demux (#2506)
xiangchen96 Mar 3, 2025
5decca4
Fix platform None (#2507)
xiangchen96 Mar 3, 2025
7f73a66
Fix CAPA 9 (#2510)
xiangchen96 Mar 4, 2025
9177b6d
Fix downloaders order (#2511)
enzok Mar 5, 2025
bdda36f
Bump jinja2 from 3.1.5 to 3.1.6 (#2512)
dependabot[bot] Mar 6, 2025
9c35614
ci: Update requirements.txt
actions-user Mar 6, 2025
be42bbe
Improve linux analysis (#2513)
xiangchen96 Mar 6, 2025
5b9e9ac
capa 9 (#2515)
doomedraven Mar 7, 2025
fd9240a
fix 2514
doomedraven Mar 7, 2025
0a8bd38
better key check
doomedraven Mar 8, 2025
46f0aea
Update views.py
doomedraven Mar 11, 2025
6155590
Update index.html
doomedraven Mar 11, 2025
2290da0
Update report.html
doomedraven Mar 11, 2025
f03b3a9
SSO auth (#2519)
doomedraven Mar 11, 2025
676b769
SSO auth
doomedraven Mar 12, 2025
cc1662e
sync
doomedraven Mar 12, 2025
d76672a
fix content not defined
doomedraven Mar 13, 2025
0305803
improve logging
doomedraven Mar 13, 2025
7eac36f
Prevent Suricata family names from losing their capitalisation (e.g. …
kevoreilly Mar 13, 2025
61efe53
test (#2521)
doomedraven Mar 14, 2025
257bb8a
ensure FD close of logs (#2505)
doomedraven Mar 14, 2025
4850f63
Update capa.py
doomedraven Mar 14, 2025
aa4d529
Update resultserver.py
doomedraven Mar 14, 2025
8399e53
Update monitor.rst
doomedraven Mar 15, 2025
72e1f12
Update kvm.conf.default
doomedraven Mar 16, 2025
c64ec44
run mitmdump in network namespace (#2525)
karlhiramoto Mar 18, 2025
dee3d21
add mitmproxy/netns to sudoers
doomedraven Mar 18, 2025
3bd8eab
remove win7 from docs
doomedraven Mar 19, 2025
a808afa
fix: missing fi in cape2.sh (#2527)
taida957789 Mar 19, 2025
d167d2b
Update database.py
doomedraven Mar 19, 2025
b409151
Mitmdump updates (#2529)
enzok Mar 19, 2025
f671954
Mongo cleanup (#2530)
doomedraven Mar 21, 2025
08cb790
Fix and update kvm-qemu.sh (#2531)
ClaudioWayne Mar 21, 2025
9afe610
fix wrong libvirt-version (#2532)
ClaudioWayne Mar 21, 2025
c8543b8
Update report_doc.py
doomedraven Mar 24, 2025
de43845
Update malwarebazaar.py - tests are useless
doomedraven Mar 24, 2025
0f47ccc
Allow disabling linux strace update_file_descriptors (#2534)
xiangchen96 Mar 24, 2025
f3c7ec0
docs: remove pinned Pillow version from guest installation
kevoreilly Mar 25, 2025
3ea2577
Bump django from 5.1.5 to 5.1.7 (#2538)
dependabot[bot] Mar 28, 2025
e7220e3
Update views.py
doomedraven Mar 28, 2025
a8392a2
httpreplay and virtmanager install fix (#2540)
ClaudioWayne Mar 28, 2025
21b0043
Bump django from 5.1.5 to 5.1.7 (#2539)
dependabot[bot] Mar 28, 2025
6d07a0b
Bump gunicorn from 22.0.0 to 23.0.0 (#2533)
dependabot[bot] Mar 28, 2025
3295045
ci: Update requirements.txt
actions-user Mar 28, 2025
b168d6a
Monitor updates: see changelog for details
kevoreilly Apr 2, 2025
350c001
Update disposable_domain_list.txt
doomedraven Apr 2, 2025
9999881
cleaners (#2542)
doomedraven Apr 2, 2025
c25af94
Update cleaners_utils.py
doomedraven Apr 2, 2025
6dc86b5
Bump django from 5.1.7 to 5.1.8 (#2543)
dependabot[bot] Apr 2, 2025
af1b81b
cleaners
doomedraven Apr 3, 2025
4515462
cleaners
doomedraven Apr 4, 2025
c389db1
cleaners
doomedraven Apr 4, 2025
a7658eb
API TLP RED (#2546)
doomedraven Apr 7, 2025
b96e463
vt_upload (#2549)
doomedraven Apr 7, 2025
845688c
Bump django from 5.1.7 to 5.1.8 (#2548)
dependabot[bot] Apr 7, 2025
ea60bb3
sample_search_in_mongo_conf (#2550)
doomedraven Apr 7, 2025
f66350d
yara-ci
doomedraven Apr 7, 2025
387cc97
Sideloading detection & monitor sideloader countermeasure
kevoreilly Apr 7, 2025
586fc83
Sideloader: add error handling to copy operations
kevoreilly Apr 7, 2025
d3685a5
detect_dll_sideloading: catch specific exceptions (e.g., OSError, Per…
kevoreilly Apr 7, 2025
760e01e
Sideloader: fix issue with child processes not being properly sideloa…
kevoreilly Apr 7, 2025
8be3cd7
Sideloading detection: filter system directories
kevoreilly Apr 8, 2025
7ffdd39
Sideloading detection: filter previous directories
kevoreilly Apr 8, 2025
3bf32eb
dont install pdns by default
doomedraven Apr 9, 2025
e5c000d
Sideloader: restrict version proxy deployment to detection of side-lo…
kevoreilly Apr 9, 2025
19b716a
useragent switcher for firefox (#2554)
dsecuma Apr 9, 2025
e1e477b
files no backwards compatibility (#2557)
doomedraven Apr 10, 2025
7e01a88
add suricata files to collection (#2558)
doomedraven Apr 11, 2025
2058096
cleanup (#2556)
doomedraven Apr 11, 2025
ffd80fe
Minor typos fix (#2559)
bartblaze Apr 11, 2025
ae5db79
Migrations related to 9999881 (#2560)
josh-feather Apr 11, 2025
ee202d1
Bump schema version to 4e000e02a409 (#2562)
josh-feather Apr 11, 2025
7391c3a
cleaners
doomedraven Apr 14, 2025
3bc131d
cleaners
doomedraven Apr 14, 2025
2d7e004
Sideloading detection & monitor sideloader countermeasure
kevoreilly Apr 14, 2025
29a1766
peepdf5 (#2555)
doomedraven Apr 14, 2025
dd91cf2
ci: Update requirements.txt
actions-user Apr 14, 2025
2eaab17
Update web_utils.py
doomedraven Apr 15, 2025
563fd24
mitre better error handling if not installed
doomedraven Apr 16, 2025
872f70e
fix: update cleanup logic to use direct config values and handle empt…
MHM98 Apr 19, 2025
ae80409
sync
doomedraven Apr 19, 2025
cea4650
install libvmi bash script fix (#2569)
minaton-ru Apr 22, 2025
7a77a7e
Simplify Mongo Delete Functions (#2567)
josh-feather Apr 24, 2025
633ad51
remove vol strings
doomedraven Apr 24, 2025
5042d9d
Bump h11 from 0.14.0 to 0.16.0 (#2570)
dependabot[bot] Apr 24, 2025
7523adf
cleaner fix delete from db (#2573)
doomedraven Apr 25, 2025
a72e6f4
cleaner fix delete from db (#2574)
doomedraven Apr 25, 2025
c68a67c
add deepwiki
doomedraven Apr 28, 2025
abae20d
Monitor updates: see changelog for details
kevoreilly Apr 28, 2025
a06cb30
Loader: fix Win7 compatibility, use WaitForDebugEvent instead of unav…
kevoreilly Apr 28, 2025
c9a7cee
Update processing.conf.default
doomedraven Apr 29, 2025
a2da40e
fix: make Wireshark installation non-interactive (#2577)
sunba91-su Apr 29, 2025
293bb07
Update reporting.conf.default
doomedraven Apr 29, 2025
8e3e47f
Apply DEBIAN_FRONTEND=noninteractive globally in install script (#2578)
sunba91-su Apr 30, 2025
6134535
demux (#2579)
doomedraven Apr 30, 2025
e48852c
fix cleaner
doomedraven Apr 30, 2025
9c8abc0
Fix issue with agent creating analyzer as grandchild process instead …
kevoreilly May 7, 2025
8afbf6f
Fix agent test script (test_agent.py) to handle recent changes (thank…
kevoreilly May 7, 2025
44d6106
PPLInject: Improve logging output if DLL transaction fails due to ins…
kevoreilly May 8, 2025
09d18f0
Monitor update: Allow monitor to load without config ini file - defau…
kevoreilly May 8, 2025
014b383
update latrodectus yara
enzok May 10, 2025
eab3d1d
Merge pull request #2595 from enzok/update
kevoreilly May 10, 2025
994dc11
Monitor updates: see changelog for details
kevoreilly May 23, 2025
da49cc4
Socks5Systemz update: detection & config extraction, parser update al…
kevoreilly May 23, 2025
3fd2a7e
Use config settings to enable/disable QemuScreenshots (#2601)
ChrisThibodeaux May 25, 2025
a254f39
Bump setuptools from 75.8.0 to 78.1.1 (#2600)
dependabot[bot] May 25, 2025
8e7983e
ci: Update requirements.txt
actions-user May 25, 2025
ce38632
Bump django from 5.1.8 to 5.1.9 (#2593)
dependabot[bot] May 25, 2025
e5c0ae4
After calling delete_tasks, open a new session (#2592)
rkoumis May 25, 2025
1f43d81
Bump django from 5.1.8 to 5.1.9 (#2605)
dependabot[bot] May 25, 2025
18244a9
fixed flare-capa, flare-floss and GUI Buttons (#2598)
ClaudioWayne May 25, 2025
e8aaff6
test
doomedraven May 25, 2025
a23b166
Update poetry.lock
doomedraven May 25, 2025
dc658cc
ci: Update requirements.txt
actions-user May 25, 2025
a460f07
Update analysis_manager.py
doomedraven May 30, 2025
f045493
Update web_utils.py
doomedraven May 30, 2025
5cd0358
dont clean pending, it has it own command
doomedraven May 30, 2025
e9142ad
Monitor update: Fix bug in retarget_relative_displacement() relative …
kevoreilly Jun 3, 2025
f515531
Monitor update: correction to previous commit
kevoreilly Jun 3, 2025
4191bb8
bump parsers
doomedraven Jun 4, 2025
a9627a5
ci: Update requirements.txt
actions-user Jun 4, 2025
460a4c0
Bump h11 from 0.14.0 to 0.16.0 (#2610)
dependabot[bot] Jun 4, 2025
5cd3819
Update web.rst
doomedraven Jun 4, 2025
691653a
add md5 and sha256 indexes in mongodb (#2609)
doomedraven Jun 5, 2025
d0c37c2
fix: forbidden escape sequence \r (#2612)
Neo23x0 Jun 6, 2025
22992be
Monitor update: Fix format string vulnerability in debugger StringsOu…
kevoreilly Jun 6, 2025
0907c41
generate zipped json report (#2614)
doomedraven Jun 6, 2025
1ed7629
Bump django from 5.1.9 to 5.1.10 (#2615)
dependabot[bot] Jun 6, 2025
3468ef1
Monitor update: WMI hooks
kevoreilly Jun 6, 2025
0f50f93
Bump requests from 2.32.2 to 2.32.4 (#2618)
dependabot[bot] Jun 10, 2025
46a74ca
ci: Update requirements.txt
actions-user Jun 10, 2025
d69ffd5
Bump h11 from 0.14.0 to 0.16.0 (#2619)
dependabot[bot] Jun 10, 2025
dcd0083
Bump django from 5.1.9 to 5.1.10 (#2620)
dependabot[bot] Jun 10, 2025
b8520e9
Monitor update: WMI hooks: add handling for VT_NULL and enable WMI_Ge…
kevoreilly Jun 10, 2025
d123184
Agent: Fix issue with analyzer directory creation lacking required AC…
kevoreilly Jun 11, 2025
2c97b9b
Update changelog per previous commit
kevoreilly Jun 11, 2025
8f94b85
fix missed tags
doomedraven Jun 12, 2025
1893060
Update agent tests to remove "tmp" prefix in line with recent agent u…
kevoreilly Jun 12, 2025
36d973d
Agent test: fix issue with random prefixes being used in test_mktemp_…
kevoreilly Jun 12, 2025
91a2bea
Update cleaners_utils.py
doomedraven Jun 12, 2025
0ae5d09
Formbook: update unhook bypass & config extraction
kevoreilly Jun 13, 2025
02c59ae
update nitrogenloader
enzok Jun 16, 2025
66423db
Adaptix Beacon yara
enzok Jun 16, 2025
52e4b43
Merge pull request #2624 from enzok/updates-01
kevoreilly Jun 17, 2025
6e06823
Update NitrogenLoader.yar
enzok Jun 17, 2025
42c2a3e
Refine rule
enzok Jun 17, 2025
93399f0
Update NitrogenLoader.yar
enzok Jun 17, 2025
22bc73a
Merge pull request #2626 from enzok/enzok-patch-1
kevoreilly Jun 18, 2025
8f33b86
Add detection for 'Amatera' from Proofpoint blog https://www.proofpoi…
kevoreilly Jun 19, 2025
359936d
Direct sysenter capture via 'sysbp' (e.g. Amatera)
kevoreilly Jun 20, 2025
bfc6db1
Restrict icacls excecution to Win32
josh-feather Jun 23, 2025
2b05a48
Merge pull request #2629 from josh-feather/2621-only-run-icacls-on-win32
kevoreilly Jun 23, 2025
e988840
Rescind sysenter breakpoint yara - too general
kevoreilly Jun 24, 2025
846b2a2
Amatera syscall capture
kevoreilly Jun 25, 2025
6fa9b9a
Defeat false positives
enzok Jun 26, 2025
3892929
Merge pull request #2631 from enzok/enzok-patch-2
kevoreilly Jun 27, 2025
674bcd7
Modify kvm-qemu.sh to apply changes in #1634 back (#2606)
MHM98 Jun 30, 2025
3ead163
Bump urllib3 from 2.3.0 to 2.5.0 (#2627)
dependabot[bot] Jun 30, 2025
f874fa0
Bump protobuf from 5.29.3 to 5.29.5 (#2625)
dependabot[bot] Jun 30, 2025
78c98f9
Update analysis_manager.py (#2611)
doomedraven Jun 30, 2025
a7bb9ef
feat(scoring): Implement dedicated scoring logic for URL analysis (#2…
AxelSecurity Jun 30, 2025
20e8081
Update views.py
doomedraven Jul 1, 2025
01cb2c1
FIX: replace <WOOT> with proper env in replace_seabios_clues_public f…
MHM98 Jul 1, 2025
1caa2a5
Update requirements.rst
doomedraven Jul 4, 2025
9686af2
Fix azure machinery bug when gathering relevant machines (#2638)
ChrisThibodeaux Jul 7, 2025
b409864
Update Lumma detection
kevoreilly Jul 8, 2025
f431786
sflock update to include 7zz
doomedraven Jul 8, 2025
50e2a79
ci: Update requirements.txt
actions-user Jul 8, 2025
93ec7fb
Bump urllib3 from 2.3.0 to 2.5.0 (#2639)
dependabot[bot] Jul 8, 2025
c902e75
Revert "sflock update to include 7zz"
doomedraven Jul 8, 2025
f4ed923
ci: Update requirements.txt
actions-user Jul 8, 2025
e89975e
prevent dns rebinding to internal networks (#2640)
dsecuma Jul 8, 2025
75f406c
sflock with 7zz
doomedraven Jul 8, 2025
716c17e
ci: Update requirements.txt
actions-user Jul 8, 2025
827819f
Create copilot-instructions.md
doomedraven Jul 8, 2025
296f34b
sflock
doomedraven Jul 9, 2025
7508350
ci: Update requirements.txt
actions-user Jul 9, 2025
91a9fd7
sflock
doomedraven Jul 9, 2025
53790e9
ci: Update requirements.txt
actions-user Jul 9, 2025
833a37e
Update copilot-instructions.md
doomedraven Jul 9, 2025
313be0c
Update cape2.sh
doomedraven Jul 10, 2025
0598aaa
sflock
doomedraven Jul 10, 2025
9204d4b
ci: Update requirements.txt
actions-user Jul 10, 2025
b4124a5
Bump urllib3 from 2.3.0 to 2.5.0 (#2643)
dependabot[bot] Jul 10, 2025
ba20b04
Tighten FormhookB monitor yara (again!) - fixes #2648
kevoreilly Jul 16, 2025
f741105
Update kvm-qemu.sh
doomedraven Jul 23, 2025
b467cfe
suricata fixes. Socket mode deprecated since Suricata 8 (#2652)
doomedraven Jul 25, 2025
4c64012
Installer script fixes (#2585)
ChrisThibodeaux Jul 26, 2025
57c5102
Update reporting.conf.default
doomedraven Jul 28, 2025
ce89210
Add PolarProxy plugin for TLS MiTM (#2656)
aaron-boyd Jul 31, 2025
80c37f6
format fixes
Jul 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions .github/actions/python-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ runs:
if: ${{ runner.os == 'Linux' }}
shell: bash
run: |
sudo apt update && sudo apt-get install -y --no-install-recommends libxml2-dev libxslt-dev python3-dev libgeoip-dev ssdeep libfuzzy-dev p7zip-full innoextract unrar upx
sudo apt update && sudo apt-get install -y --no-install-recommends libxml2-dev libxslt-dev python3-dev libgeoip-dev ssdeep libfuzzy-dev 7zip innoextract unrar upx

- name: Install poetry
shell: bash
run: PIP_BREAK_SYSTEM_PACKAGES=1 pip install poetry poetry-plugin-export
#- name: Python Poetry Action
# uses: abatilo/[email protected]

- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
Expand All @@ -27,4 +29,4 @@ runs:
- name: Install requirements
shell: bash
run: |
PIP_BREAK_SYSTEM_PACKAGES=1 poetry install --no-interaction --no-root
PIP_BREAK_SYSTEM_PACKAGES=1 poetry install --no-interaction
58 changes: 58 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copilot Instructions for CAPEv2

## General Architecture
- CAPEv2 is an automated malware analysis platform, based on Cuckoo Sandbox, with extensions for dynamic, static, and network analysis.
- The backend is mainly Python, using SQLAlchemy for the database and Django/DRF for the web API.
- Main components include:
- `lib/cuckoo/core/database.py`: database logic and ORM.
- `web/apiv2/views.py`: REST API endpoints (Django REST Framework).
- `lib/cuckoo/common/`: shared utilities, configuration, helpers.
- `storage/`: analysis results and temporary files.
- Typical flow: sample upload → DB registration → VM assignment → analysis → result storage → API query.

## Conventions and Patterns
- Heavy use of SQLAlchemy 2.0 ORM, with explicit sessions and nested transactions (`begin_nested`).
- Database models (Sample, Task, Machine, etc.) are always managed via `Database` object methods.
- API endpoints always return a dict with `error`, `data`, and, if applicable, `error_value` keys.
- Validation and request argument parsing is centralized in helpers (`parse_request_arguments`, etc.).
- Integrity errors (e.g., duplicates) are handled with `try/except IntegrityError` and recovery of the existing object.
- Tags are managed as comma-separated strings and normalized before associating to models.
- Code avoids mutable global variables; configuration is accessed via `Config` objects.

## Developer Workflows
- No Makefile or standard build scripts; dependency management is usually via `poetry` or `pip`.
- For testing, use virtual environments and run scripts manually.
- Typical backend startup is via Django (`manage.py runserver`), and analysis workers are launched separately.
- Database changes require manual migrations (see Alembic comments in `database.py`).

## Integrations and Dependencies
- Optional integration with MongoDB and Elasticsearch, controlled by configuration (`reporting.conf`).
- The system can use different compression tools (zlib, 7zip) depending on config.
- Sample analysis may invoke external utilities (e.g., Sflock, PE parsers).

## Key Pattern Examples
- IntegrityError handling example:
```python
try:
with self.session.begin_nested():
self.session.add(sample)
except IntegrityError:
sample = self.session.scalar(select(Sample).where(Sample.md5 == file_md5))
```
- API response example:
```python
return Response({"error": False, "data": result})
```
- Tag assignment example:
```python
tags = ",".join(set(_tags))
```

## Key Files
- `lib/cuckoo/core/database.py`: database logic, sample/task registration, machine management.
- `web/apiv2/views.py`: REST endpoints, validation, high-level business logic.
- `lib/cuckoo/common/`: utilities, helpers, configuration.

---

If you introduce new endpoints, helpers, or models, follow the validation, error handling, and standard response patterns. See the files above for implementation examples.
4 changes: 2 additions & 2 deletions .github/workflows/export-requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
uses: actions/checkout@v4

- name: Install poetry
run: pip install poetry
run: pip install poetry poetry-plugin-export --user

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
# check-latest: true
check-latest: true
python-version: ${{ matrix.python-version }}
cache: 'poetry'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10"]

steps:
- name: Check out repository code
Expand Down
33 changes: 10 additions & 23 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04 # ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10"]
steps:
- name: Check out repository code
uses: actions/checkout@v4
Expand All @@ -34,32 +34,24 @@ jobs:

- name: Install pyattck
run: |
poetry run pip install pyattck==7.1.2 maco
poetry run pip install git+https://github.com/CAPESandbox/pyattck maco

- name: Run Ruff
run: poetry run ruff . --line-length 132 --ignore E501,E402
run: poetry run ruff check . --output-format=github .

- name: Run unit tests
run: poetry run python -m pytest --import-mode=append

- name: See if any parser changed
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
src:
- 'modules/processing/parsers/CAPE/*.py'

- name: Test parsers only if any parser changed
if: steps.changes.outputs.src == 'true'
run: poetry run python -m pytest tests_parsers -s --import-mode=append
# see the mypy configuration in pyproject.toml
- name: Run mypy
run: poetry run mypy

format:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10"]
if: ${{ github.ref == 'refs/heads/master' }}

steps:
Expand All @@ -71,20 +63,15 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Format with black
run: poetry run black .

# to be replaced with ruff
- name: Format imports with isort
run: poetry run isort .

- name: Commit changes if any
# Skip this step if being run by nektos/act
if: ${{ !env.ACT }}
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
if output=$(git status --porcelain) && [ ! -z "$output" ]; then
git pull
git add .
git commit -m "style: Automatic code formatting" -a
git push
fi
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ A huge thank you to @D00m3dR4v3n for single-handedly porting CAPE to Python 3.
## Installation recommendations and scripts for optimal performance
* Python3
* agent.py is tested with python (3.7.2|3.8) x86. __You should use x86 python version inside of the VM!__
* host tested with python3 version 3.7, 3.8, 3.10, but newer versions should work too
* host tested with python3 version 3.10, 3.12, but newer versions should work too

* __Only rooter should be executed as root__, the rest as __cape__ user. Running as root will mess with permissions.
1. Become familiar with the [documentation](https://capev2.readthedocs.io/en/latest/) and __do read ALL__ config files inside of `conf` folder!
2. For best compabitility we strongly suggest installing on [Ubuntu 22.04 LTS](https://ubuntu.com/#download) and using Windows 10 21H2 as target.
2. For best compabitility we strongly suggest installing on [Ubuntu 24.04 LTS](https://ubuntu.com/#download) and using Windows 10 21H2 as target.
3. `kvm-qemu.sh` and `cape2.sh` __SHOULD BE__ executed from `tmux` session to prevent any OS problems if ``ssh`` connections breaks.
4. [KVM](https://github.com/kevoreilly/CAPEv2/blob/master/installer/kvm-qemu.sh) is recommended as the hypervisor.
* Replace `<username>` with a real pattern.
Expand Down Expand Up @@ -228,3 +228,4 @@ If you use CAPEv2 in your work, please cite it as specified in the "Cite this re

### Docs
* [ReadTheDocs](https://capev2.readthedocs.io/en/latest/#)
* [DeepWiki](https://deepwiki.com/kevoreilly/CAPEv2/1-overview) - AI generated, some might be wrong but generally pretty accurate.
37 changes: 17 additions & 20 deletions agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import http.server
import ipaddress
import json
import multiprocessing
import os
import platform
import random
Expand All @@ -30,7 +29,7 @@
from zipfile import ZipFile

try:
import re2 as re
import re2 as re # type: ignore
except ImportError:
import re

Expand All @@ -44,7 +43,7 @@
if sys.maxsize > 2**32 and sys.platform == "win32":
sys.exit("You should install python3 x86! not x64")

AGENT_VERSION = "0.18"
AGENT_VERSION = "0.20"
AGENT_FEATURES = [
"execpy",
"execute",
Expand Down Expand Up @@ -96,7 +95,7 @@ def _missing_(cls, value):
AGENT_BROWSER_EXT_PATH = ""
AGENT_BROWSER_LOCK = Lock()
ANALYZER_FOLDER = ""
agent_mutexes = {}
agent_mutexes: dict = {}
"""Holds handles of mutexes held by the agent."""
state = {
"status": Status.INIT,
Expand Down Expand Up @@ -177,12 +176,12 @@ def __init__(self):

def run(
self,
host: ipaddress.IPv4Address = "0.0.0.0",
host: ipaddress.IPv4Address = ipaddress.IPv4Address("0.0.0.0"),
port: int = 8000,
event: multiprocessing.Event = None,
event = None,
):
socketserver.ThreadingTCPServer.allow_reuse_address = True
self.s = socketserver.ThreadingTCPServer((host, port), self.handler)
self.s = socketserver.ThreadingTCPServer((str(host), port), self.handler)

# tell anyone waiting that they're good to go
if event:
Expand Down Expand Up @@ -226,7 +225,6 @@ def handle(self, obj):
self.close_connection = True

def shutdown(self):

# BaseServer also features a .shutdown() method, but you can't use
# that from the same thread as that will deadlock the whole thing.
if hasattr(self, "s"):
Expand All @@ -248,7 +246,7 @@ def __init__(self, status_code=200, **kwargs):
def init(self):
pass

def json(self):
def json(self) -> str:
for valkey in self.values:
if isinstance(self.values[valkey], bytes):
self.values[valkey] = self.values[valkey].decode("utf8", "replace")
Expand Down Expand Up @@ -324,8 +322,8 @@ def headers(self, obj):


class request:
form = {}
files = {}
form: dict = {}
files: dict = {}
client_ip = None
client_port = None
method = None
Expand All @@ -334,7 +332,7 @@ class request:
}


app = MiniHTTPServer()
app: MiniHTTPServer = MiniHTTPServer()


def isAdmin():
Expand Down Expand Up @@ -378,7 +376,7 @@ def get_subprocess_status():
"""Return the subprocess status."""
async_subprocess = state.get("async_subprocess")
message = "Analysis status"
exitcode = async_subprocess.exitcode
exitcode = async_subprocess.poll()
if exitcode is None or (sys.platform == "win32" and exitcode == 259):
# Process is still running.
state["status"] = Status.RUNNING
Expand Down Expand Up @@ -546,7 +544,7 @@ def do_mkdir():
@app.route("/mktemp", methods=("GET", "POST"))
def do_mktemp():
suffix = request.form.get("suffix", "")
prefix = request.form.get("prefix", "tmp")
prefix = request.form.get("prefix", "")
dirpath = request.form.get("dirpath")

try:
Expand All @@ -562,11 +560,13 @@ def do_mktemp():
@app.route("/mkdtemp", methods=("GET", "POST"))
def do_mkdtemp():
suffix = request.form.get("suffix", "")
prefix = request.form.get("prefix", "tmp")
prefix = request.form.get("prefix", "")
dirpath = request.form.get("dirpath")

try:
dirpath = tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=dirpath)
if sys.platform == "win32":
subprocess.call(["icacls", dirpath, "/inheritance:e", "/grant", "BUILTIN\\Users:(OI)(CI)(RX)"])
except Exception:
return json_exception("Error creating temporary directory")

Expand Down Expand Up @@ -713,9 +713,7 @@ def background_subprocess(command_args, cwd, base64_encode, shell=False):

def spawn(args, cwd, base64_encode, shell=False):
"""Kick off a subprocess in the background."""
run_subprocess_args = [args, cwd, base64_encode, shell]
proc = multiprocessing.Process(target=background_subprocess, name=f"child process {args[1]}", args=run_subprocess_args)
proc.start()
proc = subprocess.Popen(args, cwd=cwd, shell=shell)
state["status"] = Status.RUNNING
state["description"] = ""
state["async_subprocess"] = proc
Expand Down Expand Up @@ -765,7 +763,7 @@ def do_browser_ext():
AGENT_BROWSER_LOCK.acquire()
if not AGENT_BROWSER_EXT_PATH:
try:
ext_tmpdir = tempfile.mkdtemp(prefix="tmp")
ext_tmpdir = tempfile.mkdtemp(prefix="")
except Exception:
AGENT_BROWSER_LOCK.release()
return json_exception("Error creating temporary directory")
Expand Down Expand Up @@ -799,7 +797,6 @@ def do_kill():


if __name__ == "__main__":
multiprocessing.set_start_method("spawn")
parser = argparse.ArgumentParser()
parser.add_argument("host", nargs="?", default="0.0.0.0")
parser.add_argument("port", type=int, nargs="?", default=8000)
Expand Down
Loading
Loading