cuckoosandbox / cuckoo

Cuckoo Sandbox is an automated dynamic malware analysis system
http://www.cuckoosandbox.org
Other
5.55k stars 1.71k forks source link

TypeError: community() got an unexpected keyword argument 'file' #3021

Open Ekultek opened 4 years ago

Ekultek commented 4 years ago
My issue is:

While running cuckoo community I receive the following error:

Traceback (most recent call last):
  File "/usr/local/bin/cuckoo", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
TypeError: community() got an unexpected keyword argument 'file'
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:

$ cuckoo -d

           _______                   _____                    _____
          /::\    \                 /\    \                  /\    \
         /::::\    \               /::\____\                /::\    \
        /::::::\    \             /::::|   |               /::::\    \
       /::::::::\    \           /:::::|   |              /::::::\    \
      /:::/~~\:::\    \         /::::::|   |             /:::/\:::\    \
     /:::/    \:::\    \       /:::/|::|   |            /:::/  \:::\    \
    /:::/    / \:::\    \     /:::/ |::|   |           /:::/    \:::\    \
   /:::/____/   \:::\____\   /:::/  |::|___|______    /:::/    / \:::\    \
  |:::|    |     |:::|    | /:::/   |::::::::\    \  /:::/    /   \:::\ ___\
  |:::|____|     |:::|    |/:::/    |:::::::::\____\/:::/____/  ___\:::|    |
   \:::\    \   /:::/    / \::/    / ~~~~~/:::/    /\:::\    \ /\  /:::|____|
    \:::\    \ /:::/    /   \/____/      /:::/    /  \:::\    /::\ \::/    /
     \:::\    /:::/    /                /:::/    /    \:::\   \:::\ \/____/
      \:::\__/:::/    /                /:::/    /      \:::\   \:::\____\
       \::::::::/    /                /:::/    /        \:::\  /:::/    /
        \::::::/    /                /:::/    /          \:::\/:::/    /
         \::::/    /                /:::/    /            \::::::/    /
          \::/____/                /:::/    /              \::::/    /
           ~~                      \::/    /                \::/____/
                                    \/____/
                                                       it's Cuckoo!

 Cuckoo Sandbox 2.0.6
 www.cuckoosandbox.org
 Copyright (c) 2010-2018

2020-05-03 21:38:20,714 [cuckoo.core.startup] DEBUG: Imported modules...
2020-05-03 21:38:20,718 [cuckoo.core.startup] DEBUG: Imported "auxiliary" modules:
2020-05-03 21:38:20,718 [cuckoo.core.startup] DEBUG:     |-- MITM
2020-05-03 21:38:20,718 [cuckoo.core.startup] DEBUG:     |-- Reboot
2020-05-03 21:38:20,718 [cuckoo.core.startup] DEBUG:     |-- Services
2020-05-03 21:38:20,718 [cuckoo.core.startup] DEBUG:     `-- Sniffer
2020-05-03 21:38:20,718 [cuckoo.core.startup] DEBUG: Imported "machinery" modules:
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- vSphere
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- KVM
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- ESX
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- XenServer
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- VirtualBox
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- Avd
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- QEMU
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- VMware
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     `-- Physical
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG: Imported "processing" modules:
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- AnalysisInfo
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- ApkInfo
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- Baseline
2020-05-03 21:38:20,719 [cuckoo.core.startup] DEBUG:     |-- BehaviorAnalysis
2020-05-03 21:38:20,720 [cuckoo.core.startup] DEBUG:     |-- Debug
2020-05-03 21:38:20,720 [cuckoo.core.startup] DEBUG:     |-- Droidmon
2020-05-03 21:38:20,720 [cuckoo.core.startup] DEBUG:     |-- Dropped
2020-05-03 21:38:20,720 [cuckoo.core.startup] DEBUG:     |-- DroppedBuffer
2020-05-03 21:38:20,720 [cuckoo.core.startup] DEBUG:     |-- Extracted
2020-05-03 21:38:20,720 [cuckoo.core.startup] DEBUG:     |-- GooglePlay
...

$ cuckoo api
2020-05-03 21:38:52,101 [werkzeug] INFO:  * Running on http://localhost:8090/ (Press CTRL+C to quit)

$ cuckoo clean
$

# the only issue is when I run cuckoo community:
$ cuckoo community
Traceback (most recent call last):
  File "/usr/local/bin/cuckoo", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
TypeError: community() got an unexpected keyword argument 'file'

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?

Ekultek commented 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()