Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/merge with latest #16

Merged
merged 177 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
cf8a3ca
Make Database creation more explicit and don't initialize it during m…
Mar 28, 2024
bfbc888
Simplify database calls and use higher-level transactions.
Mar 28, 2024
0e7c240
Update tests to work with updated database mechanics.
Mar 28, 2024
8392843
Move the AnalysisManager to its own module.
Apr 1, 2024
96fddc7
Overhaul the scheduler.
Apr 1, 2024
08c5aab
Update the unit tests for the database.
Apr 1, 2024
8af4e18
Update the remaining unit tests.
Apr 1, 2024
a68f2fe
Allow a "reserved" machine to be used when a tag is provided for a ta…
Apr 1, 2024
6323f60
Follow the recommended procedure for not reusing connections from a p…
Apr 1, 2024
ed5f57e
Merge pull request #2037 from tbeadle/database-and-scheduler-overhaul
doomedraven Apr 2, 2024
bfa20bd
Remove test_scheduler.py. It has been moved/updated in test_analysis_…
Apr 2, 2024
5b0b021
Fix bug in analysis_manager.
Apr 2, 2024
fa52ae0
Fix analysis_manager tests.
Apr 2, 2024
9d9ef1f
Merge pull request #2040 from tbeadle/database-and-scheduler-overhaul
doomedraven Apr 2, 2024
bd03801
Merge branch 'master' into staging
doomedraven Apr 3, 2024
555de24
add customizable cape config directory
doomedraven Apr 3, 2024
a239be3
Update dist.py
doomedraven Apr 3, 2024
273f080
Merge branch 'master' into staging
doomedraven Apr 3, 2024
379724d
Update analysis_manager.py
doomedraven Apr 3, 2024
3ae8ce3
cleanup
doomedraven Apr 4, 2024
ddccfdc
Merge branch 'master' into staging
doomedraven Apr 5, 2024
7d9cf94
Update machinery_manager.py
doomedraven Apr 6, 2024
4b20664
fix issue with creation of the machinery lock.
Apr 8, 2024
5e3be81
Merge branch 'master' into staging
doomedraven Apr 8, 2024
b3f19c6
Merge pull request #2049 from tbeadle/machinery-lock-fix
doomedraven Apr 9, 2024
99a36f7
START the thr_maintain_scaling_bounded_semaphore thread.
Apr 10, 2024
559a21d
Update poetry.lock.
Apr 10, 2024
5f5b70e
Merge pull request #2055 from tbeadle/start-scaling-thread
doomedraven Apr 10, 2024
c1faff3
ci: Update requirements.txt
actions-user Apr 10, 2024
f370903
Merge branch 'master' into staging
doomedraven Apr 10, 2024
0172745
Merge branch 'staging' of https://github.com/kevoreilly/CAPEv2 into s…
doomedraven Apr 10, 2024
90134aa
fix a few Windows analyzer bugs, add test coverage
nbargnesi Apr 11, 2024
c89a476
Merge pull request #2056 from nbargnesi/win-analyzer-test-fixes
doomedraven Apr 11, 2024
d89b096
Merge branch 'master' into staging
doomedraven Apr 15, 2024
520d65b
Rename option for interactive desktop as simply 'interactive', remove…
kevoreilly Apr 16, 2024
4390032
Merge branch 'master' into staging
doomedraven Apr 17, 2024
9502969
Interactive mode: inject desktop (explorer) process
kevoreilly Apr 17, 2024
cc4d767
Merge branch 'master' into staging
doomedraven Apr 20, 2024
0413b56
Update analyzer.py
doomedraven Apr 24, 2024
6e70d44
Added tests for analyzer; bug fix (#2083)
rkoumis Apr 25, 2024
b37f899
Merge branch 'master' into staging
doomedraven May 6, 2024
899e96c
manual_detonation
May 6, 2024
5673ecb
manual_detonation
May 6, 2024
21c679f
Fix submit.py (#2111)
tbeadle May 8, 2024
fa94c91
analyzer: remove mistyped and useless debug output when procmemdump n…
kevoreilly May 10, 2024
9c8d6da
Update optional_dependencies.txt
doomedraven May 13, 2024
196234b
another place of pymongo
May 15, 2024
1111ec4
Merge branch 'master' of github.com:kevoreilly/CAPEv2
May 15, 2024
c406880
Changes have been added for handling smtp with tls by httpreplay. (#2…
piolug93 May 15, 2024
edb9dba
Update file_extra_info.py
doomedraven May 17, 2024
cf092aa
style: Automatic code formatting
actions-user May 17, 2024
5ac7929
Update process.py
doomedraven May 18, 2024
b1df219
style: Automatic code formatting
actions-user May 18, 2024
56007a2
added nginx config enable in docs (#2121)
Zer0Risk May 19, 2024
cee4412
added multiple search clauses in behavioral search view (#1951)
federicofantini May 19, 2024
72d78c8
Update api.conf.default
doomedraven May 19, 2024
e1d29a8
Merge branch 'master' of https://github.com/kevoreilly/CAPEv2
doomedraven May 19, 2024
9663d04
yara-x
doomedraven May 19, 2024
9450147
yara x support (#2124)
doomedraven May 20, 2024
a64f735
style: Automatic code formatting
actions-user May 20, 2024
810972a
Update changelog.md
doomedraven May 20, 2024
8ab7061
Update changelog.md
doomedraven May 20, 2024
5754b9d
fix guac
doomedraven May 20, 2024
0a1d445
Update web.rst
doomedraven May 20, 2024
807dd9f
Merge branch 'master' into InteractiveExplorer
doomedraven May 20, 2024
61c39b4
Update data
doomedraven May 20, 2024
2cda834
Merge pull request #2070 from kevoreilly/InteractiveExplorer
kevoreilly May 20, 2024
368ca10
style: Automatic code formatting
actions-user May 20, 2024
9a543e7
Monitor update: Debugger fixes/improvements, misc other fixes (see ca…
kevoreilly May 20, 2024
839c138
Merge branch 'master' into staging
doomedraven May 20, 2024
9cb4162
Update data
doomedraven May 20, 2024
7b43180
Update poetry.lock
doomedraven May 20, 2024
21b0c7c
ci: Update requirements.txt
actions-user May 20, 2024
df14080
Merge pull request #2041 from kevoreilly/staging
doomedraven May 20, 2024
2900ec1
style: Automatic code formatting
actions-user May 20, 2024
d30ae63
Update analysis_manager.py
doomedraven May 20, 2024
336ad13
reapply tid kwarg bug fix used in thread inject
nbargnesi May 20, 2024
7b733d8
---
dependabot[bot] May 21, 2024
a0e5fb8
Merge pull request #2125 from nbargnesi/master-fixes-post-staging-mer…
doomedraven May 21, 2024
26a6c4a
Merge pull request #2126 from kevoreilly/dependabot/pip/requests-2.32.0
doomedraven May 21, 2024
a21d8f8
ci: Update requirements.txt
actions-user May 21, 2024
a045456
Update database.py
doomedraven May 21, 2024
8d63021
style: Automatic code formatting
actions-user May 21, 2024
efdaf49
Monitor update: Hook full set of service APIs in sechost.dll
kevoreilly May 21, 2024
245ac2e
analyzer fix
enzok May 21, 2024
8e7d2a9
Merge pull request #2127 from enzok/patch-3
kevoreilly May 21, 2024
cfa6c7a
store_vnc_port is a possible attribute of self.machinery_manager.mach…
May 21, 2024
9268364
Merge pull request #2128 from tbeadle/store-vnc-port-fix
doomedraven May 21, 2024
16fbe0b
Formbook config extraction: add a couple more patterns for recent var…
kevoreilly May 21, 2024
4eb1ff5
Minor test fix.
May 21, 2024
852ad23
Merge pull request #2129 from tbeadle/minor-test-update
doomedraven May 21, 2024
04ef3c0
Update capa.py
doomedraven May 22, 2024
8f68a79
style: Automatic code formatting
actions-user May 22, 2024
1452e22
small fix
enzok May 22, 2024
6576cd7
Merge pull request #2131 from enzok/patch-1
doomedraven May 22, 2024
eb30aa7
style: Automatic code formatting
actions-user May 22, 2024
3c8b28b
Monitor update: Enhance DnsQuery* hooks to capture DNS server lists (…
kevoreilly May 22, 2024
193e03b
Socks5Systemz detection & config extraction
kevoreilly May 22, 2024
eb70f66
style: Automatic code formatting
actions-user May 22, 2024
de1b31b
Update README.md
doomedraven May 23, 2024
3d82c5f
feat(linux): add linux packages to submission form
xiangchen96 May 23, 2024
477033b
Merge pull request #2134 from xiangchen96/add_linux_packages_form
doomedraven May 23, 2024
61b965d
add king rat extractors (#2135)
doomedraven May 23, 2024
ba6817d
style: Automatic code formatting
actions-user May 23, 2024
ecb3436
Update dist.py
doomedraven May 24, 2024
dcf0df1
Update process.py
doomedraven May 24, 2024
d5d96fa
style: Automatic code formatting
actions-user May 24, 2024
0e58a3b
Tweak log wording for file uploads in resultserver
kevoreilly May 24, 2024
1f66ab3
Update database.py
doomedraven May 24, 2024
3dc394f
Another Formbook tweak
kevoreilly May 24, 2024
44a6759
Quickbind config and yara (#2137)
enzok May 24, 2024
219906a
Update database.py
doomedraven May 24, 2024
3ea57a5
Fix main database usage in dist.py. (#2138)
tbeadle May 24, 2024
fdc552d
style: Automatic code formatting
actions-user May 24, 2024
fc9eff9
disable yara-x suggestion to install as we saw some negative performa…
doomedraven May 27, 2024
b0930cc
Update cleaners_utils.py
doomedraven May 27, 2024
5387c62
style: Automatic code formatting
actions-user May 27, 2024
687a831
Update mongodb.py
doomedraven May 27, 2024
000ce49
style: Automatic code formatting
actions-user May 27, 2024
acfa2a7
allow_static jobs when no available VMs (#2140)
doomedraven May 27, 2024
e08c6bb
Bug fix in qemu shutdown (#2141)
xalicex May 28, 2024
6f8d82b
style: Automatic code formatting
actions-user May 28, 2024
38b3ce4
Scheduler fix (#2142)
tbeadle May 28, 2024
e9e9a81
add platform for some exclusive OS modules (#2144)
dsecuma May 30, 2024
6e4640a
style: Automatic code formatting
actions-user May 30, 2024
66b33d5
Update cape2.sh
doomedraven May 30, 2024
c5cc9e3
prevent errors if module has not platform value (#2146)
dsecuma May 30, 2024
5a03392
Update web_utils.py
doomedraven May 30, 2024
71a138e
Fix 7zip password being b'infected' (#2147)
xiangchen96 May 30, 2024
37c7bec
Update Quickbind.yar (#2148)
enzok May 30, 2024
2b49dcb
Update Oyster yara and parsing (#2149)
enzok May 30, 2024
89be658
Fix enforce_timeout (#2151)
xiangchen96 Jun 3, 2024
8f5442a
Fix stop, use guest name (#2152)
xiangchen96 Jun 4, 2024
add8f8c
Analyzer: remove noisy debug/warning output from process::open() method
kevoreilly Jun 4, 2024
0d7ea52
requests bump
doomedraven Jun 4, 2024
60c3d5a
ci: Update requirements.txt
actions-user Jun 4, 2024
4000968
Monitor update: New hooks (GetAddrInfoExW, CLSIDFromProgIDEx), 64-bit…
kevoreilly Jun 4, 2024
e2fe111
fix magic
doomedraven Jun 5, 2024
be0ec54
ci: Update requirements.txt
actions-user Jun 5, 2024
217b2a5
magic
doomedraven Jun 5, 2024
f0c83d2
ci: Update requirements.txt
actions-user Jun 5, 2024
c49d125
Allow plugins to run that do not have platform config value (#2154)
josh-feather Jun 6, 2024
21a6691
Update Quickbind.py (#2155)
enzok Jun 6, 2024
b6e840d
style: Automatic code formatting
actions-user Jun 6, 2024
0c1fd4a
Community.py cleanup option (#2156)
cccs-mog Jun 6, 2024
1d8063b
style: Automatic code formatting
actions-user Jun 6, 2024
82d1fbc
magic
doomedraven Jun 7, 2024
25fa621
ci: Update requirements.txt
actions-user Jun 7, 2024
b940693
Allow plugins to run that do not have platform config value (#2157)
josh-feather Jun 7, 2024
c8513ad
Allow setting package in linux (#2158)
xiangchen96 Jun 7, 2024
70c9989
Update test_mitre.py
doomedraven Jun 7, 2024
a2a7e8a
Update community.py
doomedraven Jun 7, 2024
9765ef8
Update test_mitre.py
doomedraven Jun 7, 2024
28da61a
Add deb.py, fix strace.py (#2160)
xiangchen96 Jun 7, 2024
9e56d11
Monitor update: Fix for 64-bit Firefox
kevoreilly Jun 10, 2024
99dd2cd
Agent: support streaming a file off the guest. (#2161)
karlhiramoto Jun 11, 2024
e060749
style: Automatic code formatting
actions-user Jun 11, 2024
1e442e1
Fix bug when finding tasks not requiring machinery. (#2168)
tbeadle Jun 11, 2024
6729b0b
Update quarantine.py
doomedraven Jun 12, 2024
3935afa
style: Automatic code formatting
actions-user Jun 12, 2024
413a493
Monitor update: Unpacker enhancement: capture modified mapped images
kevoreilly Jun 12, 2024
ec37a5d
Update quarantine.py
doomedraven Jun 12, 2024
26e5e61
Update quarantine.py
doomedraven Jun 12, 2024
95c6f21
Update quarantine.py
doomedraven Jun 12, 2024
6b4d1ff
Update quarantine.py
doomedraven Jun 12, 2024
8135fe2
Update kvm-qemu.sh
doomedraven Jun 13, 2024
3c495d4
capa 7.1.0
doomedraven Jun 14, 2024
2dc76f9
ci: Update requirements.txt
actions-user Jun 14, 2024
dab1d69
Fix correct storage path for 7zip (#2170)
xiangchen96 Jun 16, 2024
eae3c56
fix dnfile 0.15 parsers (#2171)
doomedraven Jun 17, 2024
296d3d5
Update Njrat.py
doomedraven Jun 17, 2024
317b861
Update Quickbind yara (#2173)
enzok Jun 17, 2024
ac53512
Update cape2.sh (#2174)
demon-i386 Jun 18, 2024
d80245a
Bump urllib3 from 2.0.7 to 2.2.2 (#2177)
dependabot[bot] Jun 18, 2024
d374a72
ci: Update requirements.txt
actions-user Jun 18, 2024
c0ec56b
dont install pyre2 anymore
doomedraven Jun 18, 2024
e05d683
Merge branch 'master' of https://github.com/polyswarm/CAPEv2 into fea…
sbneto Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ Please contribute to this project by helping create new signatures, parsers, or

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

## Installation recommendations and scripts for optimal performance
* __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.
Expand Down
36 changes: 30 additions & 6 deletions agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import subprocess
import sys
import tempfile
import time
import traceback
from io import StringIO
from typing import Iterable
Expand Down Expand Up @@ -174,8 +175,8 @@ def run(
port: int = 8000,
event: multiprocessing.Event = None,
):
socketserver.TCPServer.allow_reuse_address = True
self.s = socketserver.TCPServer((host, port), self.handler)
socketserver.ThreadingTCPServer.allow_reuse_address = True
self.s = socketserver.ThreadingTCPServer((host, port), self.handler)

# tell anyone waiting that they're good to go
if event:
Expand Down Expand Up @@ -219,6 +220,7 @@ 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 Down Expand Up @@ -258,26 +260,47 @@ def headers(self, obj):
class send_file:
"""Wrapper that represents Flask.send_file functionality."""

def __init__(self, path, encoding):
def __init__(self, path, encoding, streaming):
self.length = None
self.path = path
self.status_code = 200
self.encoding = encoding
self.streaming = False
if streaming == "1":
self.streaming = True

def okay_to_send(self):
return os.path.isfile(self.path) and os.access(self.path, os.R_OK)

def init(self):
if self.okay_to_send():
if self.encoding != BASE_64_ENCODING:
if self.encoding != BASE_64_ENCODING and not self.streaming:
self.length = os.path.getsize(self.path)
else:
self.status_code = 404

def write_streaming(self, httplog, sock):
"""Streaming output. similar to using 'tail -f <file>"""

with open(self.path, "rb") as f:
while True:
line = f.readline()
if not line:
time.sleep(0.1)
continue
try:
sock.write(line)
except (BrokenPipeError, ConnectionResetError):
httplog.log_message(f"Client disconnected while reading {self.path}")
break

def write(self, httplog, sock):
if not self.okay_to_send():
return

if self.streaming:
self.write_streaming(httplog, sock)
return
try:
with open(self.path, "rb") as f:
buf = f.read(1024 * 1024)
Expand All @@ -290,7 +313,8 @@ def write(self, httplog, sock):
httplog.log_error(f"Error reading file {self.path}: {ex}")

def headers(self, obj):
obj.send_header("Content-Length", self.length)
if self.length is not None:
obj.send_header("Content-Length", self.length)


class request:
Expand Down Expand Up @@ -565,7 +589,7 @@ def do_retrieve():
if "filepath" not in request.form:
return json_error(400, "No filepath has been provided")

return send_file(request.form["filepath"], request.form.get("encoding", ""))
return send_file(request.form["filepath"], request.form.get("encoding", ""), request.form.get("streaming", ""))


@app.route("/extract", methods=["POST"])
Expand Down
4 changes: 4 additions & 0 deletions agent/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ def teardown_method(self):
shutil.rmtree(DIRPATH, ignore_errors=True)
assert not os.path.isdir(DIRPATH)

if sys.platform == "win32":
# shutdown will hang on win32 without this
self.agent_process.terminate()

# Ensure agent process completes; release resources.
self.agent_process.join()
self.agent_process.close()
Expand Down
14 changes: 14 additions & 0 deletions analyzer/linux/modules/packages/deb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python
# Copyright (C) 2024 xiangchen96
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE file for details.

from lib.core.packages import Package


class Deb(Package):
"""Deb analysis package."""

def prepare(self):
self.args = [self.target] + self.args
self.target = "dpkg -i"
9 changes: 3 additions & 6 deletions analyzer/linux/modules/packages/perl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE file for details.

from os import system

from lib.core.packages import Package


class Perl(Package):
"""Mach-O executable analysys package."""
"""Perl script analysis package."""

def prepare(self):
# Make sure that our target is executable
# /usr/bin/open will handle it
system(f'/bin/chmod +x "{self.target}"')
self.args = [self.target] + self.args
self.target = "/usr/bin/perl"
Loading