Skip to content

Commit 0b63105

Browse files
Update usages with expected location of 7zz binary (#2667)
1 parent 4b7d506 commit 0b63105

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

.github/actions/python-setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ runs:
1212
if: ${{ runner.os == 'Linux' }}
1313
shell: bash
1414
run: |
15-
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
15+
sudo apt update && sudo apt-get install -y --no-install-recommends libxml2-dev libxslt-dev python3-dev libgeoip-dev ssdeep libfuzzy-dev innoextract unrar upx
1616
1717
- name: Install poetry
1818
shell: bash

.github/workflows/python-package.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ jobs:
3232
with:
3333
python-version: ${{ matrix.python-version }}
3434

35+
- name: Setup 7zz binary
36+
run: |
37+
mkdir -p data/
38+
wget -q https://github.com/CAPESandbox/community/raw/master/data/7zz -O data/7zz
39+
chmod +x data/7zz
40+
3541
- name: Install pyattck
3642
run: |
3743
poetry run pip install git+https://github.com/CAPESandbox/pyattck maco

conf/default/processing.conf.default

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ filesdir = files
174174
# Amount of text to carve from plaintext files (bytes)
175175
buffer = 8192
176176
#Used for creating an archive of extracted files
177-
7zbin = /usr/bin/7z
177+
7zbin = data/7zz
178178
zippass = infected
179179
# Runmode "cli" options
180180
bin = /usr/bin/suricata

conf/default/reporting.conf.default

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ zipprocdump = yes
157157
zipprocstrings = yes
158158
# pyzipper or 7zip
159159
compressiontool = pyzipper
160-
sevenzippath = /usr/bin/7z
160+
sevenzippath = data/7zz
161161

162162
# Community
163163
[misp]

lib/cuckoo/common/integrations/file_extra_info.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@
114114
unautoit_binary = os.path.join(CUCKOO_ROOT, integration_conf.UnAutoIt_extract.binary)
115115
if integration_conf.Inno_extract.binary:
116116
innoextact_binary = os.path.join(CUCKOO_ROOT, integration_conf.Inno_extract.binary)
117-
sevenzip_binary = "/usr/bin/7z"
117+
sevenzip_binary = os.path.join(CUCKOO_ROOT, "data/7zz")
118118
if integration_conf.SevenZip_unpack.binary:
119119
tmp_sevenzip_binary = os.path.join(CUCKOO_ROOT, integration_conf.SevenZip_unpack.binary)
120120
if path_exists(tmp_sevenzip_binary):
121121
sevenzip_binary = tmp_sevenzip_binary
122+
# fallback
123+
if not path_exists(sevenzip_binary):
124+
sevenzip_binary = "/usr/bin/7z"
122125

123126
if processing_conf.trid.enabled:
124127
trid_binary = os.path.join(CUCKOO_ROOT, processing_conf.trid.identifier)
@@ -688,7 +691,7 @@ def msi_extract(file: str, *, filetype: str, **kwargs) -> ExtractorReturnType:
688691
return
689692

690693
extracted_files = []
691-
# sudo apt install msitools or 7z
694+
# sudo apt install msitools
692695
with extractor_ctx(file, "MsiExtract", prefix="msidump_", folder=tools_folder) as ctx:
693696
tempdir = ctx["tempdir"]
694697
output = False
@@ -707,7 +710,7 @@ def msi_extract(file: str, *, filetype: str, **kwargs) -> ExtractorReturnType:
707710
]
708711
else:
709712
output = run_tool(
710-
["7z", "e", f"-o{tempdir}", "-y", file],
713+
[sevenzip_binary, "e", f"-o{tempdir}", "-y", file],
711714
universal_newlines=True,
712715
stderr=subprocess.PIPE,
713716
)

modules/processing/suricata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def run(self):
7171
SURICATA_FILES_DIR = self.options.get("filesdir")
7272
SURICATA_RUNMODE = self.options.get("runmode")
7373
SURICATA_FILE_BUFFER = self.options.get("buffer", 8192)
74-
Z7_PATH = self.options.get("7zbin")
74+
Z7_PATH = os.path.join(CUCKOO_ROOT, self.options.get("7zbin"))
7575
FILES_ZIP_PASS = self.options.get("zippass")
7676

7777
# Socket
@@ -396,7 +396,7 @@ def run(self):
396396
log.warning("Unable to delete suricata file subdirectories: %s", e)
397397

398398
if SURICATA_FILES_DIR_FULL_PATH and path_exists(SURICATA_FILES_DIR_FULL_PATH) and Z7_PATH and path_exists(Z7_PATH):
399-
# /usr/bin/7z a -pinfected -y files.zip files-json.log files
399+
# /opt/CAPEv2/data/7zz a -pinfected -y files.zip files-json.log files
400400
cmdstr = f"cd {self.logs_path} && {Z7_PATH} a -p{FILES_ZIP_PASS} -y files.zip {SURICATA_FILE_LOG} {SURICATA_FILES_DIR}"
401401
ret, _, stderr = self.cmd_wrapper(cmdstr)
402402
if ret > 1:

0 commit comments

Comments
 (0)