Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: c2a6fdf1de
Fetching contributors…

Cannot retrieve contributors at this time

executable file 118 lines (92 sloc) 3.764 kB
#!/usr/bin/env python
# Copyright (C) 2010-2012 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
import os
import sys
import shutil
import urllib2
import argparse
import tempfile
from zipfile import ZipFile
from StringIO import StringIO
ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..")
sys.path.append(ROOT)
import lib.cuckoo.common.colors as colors
URL = "https://github.com/cuckoobox/community/zipball/master"
def download_archive():
try:
data = urllib2.urlopen(URL).read()
except Exception as e:
print("ERROR: Unable to download archive: %s" % e)
sys.exit(-1)
zip_data = StringIO()
zip_data.write(data)
archive = ZipFile(zip_data, "r")
temp_dir = tempfile.mkdtemp()
archive.extractall(temp_dir)
archive.close()
final_dir = os.path.join(temp_dir, os.listdir(temp_dir)[0])
return (temp_dir, final_dir)
def install(enabled, force, rewrite):
(temp, source) = download_archive()
folders = {"signatures" : os.path.join("modules", "signatures")}
for category in enabled:
folder = folders[category]
print("\nInstalling %s" % colors.cyan(category.upper()))
origin = os.path.join(source, folder)
for file_name in os.listdir(origin):
destination = os.path.join(ROOT, folder, file_name)
if not rewrite:
if os.path.exists(destination):
print("File \"%s\" already exists, %s" % (file_name, colors.yellow("skipped")))
continue
install = False
if not force:
while 1:
choice = raw_input("Do you want to install file \"%s\"? [yes/no] " % file_name)
if choice.lower() == "yes":
install = True
break
elif choice.lower() == "no":
break
else:
continue
else:
install = True
if install:
shutil.copy(os.path.join(origin, file_name), destination)
print("File \"%s\" %s" % (file_name, colors.green("installed")))
shutil.rmtree(temp)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-a", "--all", help="Download everything", action="store_true", required=False)
parser.add_argument("-s", "--signatures", help="Download Cuckoo signatures", action="store_true", required=False)
#parser.add_argument("-p", "--processing", help="Download processing modules", action="store_true", required=False)
#parser.add_argument("-m", "--machinemanagers", help="Download machine managers", action="store_true", required=False)
#parser.add_argument("-r", "--reporting", help="Download reporting modules", action="store_true", required=False)
parser.add_argument("-f", "--force", help="Install files without confirmation", action="store_true", required=False)
parser.add_argument("-w", "--rewrite", help="Rewrite existing files", action="store_true", required=False)
args = parser.parse_args()
enabled = []
force = False
rewrite = False
if args.all:
enabled.append("signatures")
else:
if args.signatures:
enabled.append("signatures")
if not enabled:
print(colors.red("You need to enable some category!\n"))
parser.print_help()
return
if args.force:
force = True
if args.rewrite:
rewrite = True
install(enabled, force, rewrite)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass
Jump to Line
Something went wrong with that request. Please try again.