Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: added zip compression for Json & html reports #254

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
44 changes: 40 additions & 4 deletions analyzer/windows/modules/auxiliary/human.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
def foreach_child(hwnd, lparam):
# List of buttons labels to click.
buttons = [
# english
"yes",
"ok",
"accept",
Expand All @@ -40,8 +41,8 @@ def foreach_child(hwnd, lparam):
"run",
"agree",
"enable",
"don't send",
"don't save",
"dont't send",
"dont't save",
"continue",
"unzip",
"open",
Expand All @@ -52,16 +53,51 @@ def foreach_child(hwnd, lparam):
"end",
"allow access",
"remind me later",
# german
"ja",
"weiter",
"akzeptieren",
"ende",
"starten",
"jetzt starten",
"neustarten",
"neu starten",
"jetzt neu starten",
"beenden",
"oeffnen",
"schliessen",
"installation weiterfuhren",
"fertig",
"beenden",
"fortsetzen",
"fortfahren",
"stimme zu",
"zustimmen",
"senden",
"nicht senden",
"speichern",
"nicht speichern",
"ausfuehren",
"spaeter",
"einverstanden"
]

# List of buttons labels to not click.
dontclick = [
# english
"check online for a solution",
"don't run",
"do not ask again until the next update is available",
"cancel",
"do not accept the agreement",
"i would like to help make reader even better"
"i would like to help make reader even better",
# german
"abbrechen",
"online nach losung suchen",
"abbruch",
"nicht ausfuehren",
"hilfe",
"stimme nicht zu"
]

classname = create_unicode_buffer(128)
Expand Down Expand Up @@ -176,7 +212,7 @@ def run(self):

# add some random data to the clipboard
randchars = list(" aaaabcddeeeeeefghhhiiillmnnnooooprrrsssttttuwy")
cliplen = random.randint(10,1000)
cliplen = random.randint(10, 1000)
clipval = []
for i in range(cliplen):
clipval.append(randchars[random.randint(0, len(randchars)-1)])
Expand Down
4 changes: 3 additions & 1 deletion conf/reporting.conf
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,14 @@ resublimit = 5
enabled = no
maxsimilar = 20

[compression]
[zcompression]
enabled = yes
zipmemdump = yes
zipmemstrings = yes
zipprocdump = yes
zipprocstrings = yes
ziprepjson = yes
ziprephtml = yes

[misp]
enabled = no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

import os
import zipfile
import logging

from lib.cuckoo.common.abstracts import Report
from lib.cuckoo.common.exceptions import CuckooReportError

log = logging.getLogger(__name__)
class Compression(Report):
"""Compresses analysis artifacts after processing/signatures are complete for permanent storage."""

Expand All @@ -16,6 +18,8 @@ def run(self, results):
zipprocdump = self.options.get("zipprocdump", False)
zipmemstrings = self.options.get("zipmemstrings", False)
zipprocstrings = self.options.get("zipprocstrings", False)
ziprepjson = self.options.get("ziprepjson", False)
ziprephtml = self.options.get("ziprephtml", False)

if "procmemory" in results and results["procmemory"]:
for proc in results["procmemory"]:
Expand Down Expand Up @@ -61,5 +65,29 @@ def run(self, results):
strings_path = "%s.zip" % (strings_path)
except Exception as e:
raise CuckooReportError("Error creating Full Memory Strings Zip File %s" % e)

rpath = self.reports_path
log.debug('repath %s, zip json: %s, zip html: %s, either params true %d, path exists: %d',self.reports_path,ziprepjson,ziprephtml, int(ziprepjson or ziprephtml), int(os.path.exists(rpath)))
if((ziprepjson or ziprephtml) and self.reports_path and os.path.exists(rpath)):
log.debug('zipping html or json reports')
rjfile=os.path.join(rpath, "report.json")
rhfile=os.path.join(rpath, "report.html")
log.debug('file 1: %s, file 2: %s',rjfile, rhfile)
if ziprepjson and os.path.exists(rjfile):
try:
f = zipfile.ZipFile("%s.zip" % (rjfile), "w", allowZip64=True)
f.write(rjfile, rpath, zipfile.ZIP_DEFLATED)
f.close()
os.remove(rjfile)
log.debug('finished compressing report json')
except Exception as e:
raise CuckooReportError("Error creating JSON Report Zip File %s" % e)
if ziprephtml and os.path.exists(rhfile):
try:
f = zipfile.ZipFile("%s.zip" % (rhfile), "w", allowZip64=True)
f.write(rhfile, rpath, zipfile.ZIP_DEFLATED)
f.close()
os.remove(rhfile)
log.debug('finished compressing report html')
except Exception as e:
raise CuckooReportError("Error creating HTML Report Zip File %s" % e)

4 changes: 2 additions & 2 deletions web/analysis/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,8 @@ def procdump(request, task_id, process_id, start, end):
@conditional_login_required(login_required, settings.WEB_AUTHENTICATION)
def filereport(request, task_id, category):
formats = {
"json": "report.json",
"html": "report.html",
"json": "report.json.zip",
"html": "report.html.zip",
"htmlsummary": "summary-report.html",
"pdf": "report.pdf",
"maec": "report.maec-4.1.xml",
Expand Down
4 changes: 2 additions & 2 deletions web/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,8 +1213,8 @@ def tasks_report(request, task_id, report_format="json"):
"error_value": "No reports created for task %s" % task_id}

formats = {
"json": "report.json",
"html": "report.html",
"json": "report.json.zip",
"html": "report.html.zip",
"htmlsummary": "summary-report.html",
"pdf": "report.pdf",
"maec": "report.maec-4.1.xml",
Expand Down