Open Ekultek opened 4 years ago
Anyone having this problem, save this into cuckoo_community.py
and run it with python:
import io
import os
import tarfile
import argparse
import requests
try:
raw_input
except:
raw_input = input
class Parser(argparse.ArgumentParser):
def __init__(self):
super(Parser, self).__init__()
@staticmethod
def optparse():
parser = argparse.ArgumentParser()
parser.add_argument(
"-f", "--force", default=False, dest="forceDown", help="Force overwrite of current file (*default=False)"
)
parser.add_argument(
"-b", "--branch", default="master", dest="downBranch",
help="Pull from a different branch besides master (*default=master)"
)
parser.add_argument(
"-F", "--file-path", default=None, dest="existingDown",
help="Pass an existing community tar.gz (*default=None)"
)
parser.add_argument(
"-p", "--path", default="{}/.cuckoo".format(os.path.expanduser("~")),
dest="downPath", help="Pass the CUCKOO path (*default=~/.cuckoo)"
)
return parser.parse_args()
URL = "https://github.com/cuckoosandbox/community/archive/{}.tar.gz"
def do_fetch(branch="master", force=False, filepath=None, root_path="/opt/cuckoo"):
if filepath is not None:
buff = open(filepath, 'rb').read()
else:
print("Downloading.. {}".format(branch))
req = requests.get(URL.format(branch))
if req.status_code != 200:
raise Exception(
"Error fetching branch: {} .."
"From URL: {}".format(branch, URL.format(branch))
)
buff = req.content
t = tarfile.TarFile.open(fileobj=io.BytesIO(buff), mode="r:gz")
folders = {
"modules/signatures": "signatures".format(root_path),
"data/monitor": "monitor".format(root_path),
"data/yara": "yara".format(root_path),
"agent": "agent".format(root_path),
"analyzer": "analyzer".format(root_path)
}
members = t.getmembers()
directory = members[0].name.split("/")[0]
for start_folder, dest_folder in folders.items():
if not os.path.exists(dest_folder):
os.makedirs(dest_folder)
start_name = "{}/{}".format(directory, start_folder)
for member in members:
if not member.name.startswith(start_name) or start_name == member.name:
continue
filepath = "{}/{}/{}".format(root_path, dest_folder, member.name[len(start_name)+1:])
if member.isdir():
os.makedirs(filepath)
continue
if os.path.exists(filepath) and not force:
print("not overwriting file")
continue
if member.issym():
t.makelink(member, filepath)
continue
if not os.path.exists(os.path.dirname(filepath)):
os.makedirs(os.path.dirname(filepath))
print("extracted {}..".format(member.name[len(start_name)+1:]))
open(filepath, "wb").write(t.extractfile(member).read())
def main():
opts = Parser().optparse()
do_fetch(branch=opts.downBranch, force=opts.forceDown, filepath=opts.existingDown, root_path=opts.downPath)
if __name__ == "__main__":
main()
My issue is:
While running
cuckoo community
I receive the following error:My Cuckoo version and operating system are:
Cuckoo version:
Cuckoo Sandbox 2.0.6
OS:Ubuntu 18.04.4 LTS
This can be reproduced by:
Running
cuckoo community
The log, error, files etc can be found at:
no log, just errors out
I am able to run all other cuckoo commands such as the following:
I found a couple of issues that are similar to this but none of them had any workarounds or fixes for it, and one of them stated to "uninstall click" which doesn't make sense, since click is the reason it's failing. (I tried anyways, didn't work). Is there any known workaround for this issue?