Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion conf/reporting.conf
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,9 @@ network = no
ids_files = no
dropped = no
registry = no
mutexes = no
mutexes = no

[zipdownload]
enabled = no
password = infected
deletezip = yes
43 changes: 41 additions & 2 deletions web/analysis/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import json
import zipfile
import tempfile
import subprocess

from django.conf import settings
from wsgiref.util import FileWrapper
Expand Down Expand Up @@ -799,15 +800,28 @@ def report(request, task_id):
def file(request, category, task_id, dlfile):
file_name = dlfile
cd = ""

zipfile = False

extmap = {
"memdump" : ".dmp",
"memdumpstrings" : ".dmp.strings",
}

if enabledconf["zipdownload"]:
zippassword = Config("reporting").zipdownload.password
deletezip = Config("reporting").zipdownload.deletezip



if category == "sample":
path = os.path.join(CUCKOO_ROOT, "storage", "binaries", dlfile)
file_name += ".bin"
#create zip file for download
if enabledconf["zipdownload"]:
file_name = create_enc_zip(path, file_name, zippassword)
path += ".zip"
zipfile = True
else:
file_name += ".bin"
elif category == "pcap":
file_name += ".pcap"
# Forcefully grab dump.pcap, serve it as [sha256].pcap
Expand Down Expand Up @@ -862,6 +876,10 @@ def file(request, category, task_id, dlfile):
{"error": "Category not defined"},
context_instance=RequestContext(request))

#setting the content type in case of zip download
if enabledconf["zipdownload"] and zipfile:
cd = "application/zip"

if not cd:
cd = "application/octet-stream"

Expand All @@ -875,8 +893,29 @@ def file(request, category, task_id, dlfile):

resp["Content-Length"] = os.path.getsize(path)
resp["Content-Disposition"] = "attachment; filename=" + file_name

#optionally deleting the zip after sending
if enabledconf["zipdownload"] and deletezip and zipfile:
os.remove(path)

return resp

def create_enc_zip(path, file_name, password):
passparam = ''
try:
#set password if set in config
if not password == '':
passparam = '-p' + password
rc = subprocess.call(['7z', 'a', passparam, '-y', path + ".zip", path])
if rc == 0:
file_name += ".zip"
#zip error return normal bin
return file_name
except:
return render_to_response("error.html",
{"error": "File not found"},
context_instance=RequestContext(request))

@require_safe
def procdump(request, task_id, process_id, start, end):
origname = process_id + ".dmp"
Expand Down