From 1059b72abdf92a4ba5a1e18844897867e7bbeccb Mon Sep 17 00:00:00 2001 From: DoomedRaven Date: Tue, 31 Dec 2019 12:39:00 +0100 Subject: [PATCH] allow download graphs and few bug fixes --- web/analysis/views.py | 16 ++++----- web/api/views.py | 38 +++++++++++----------- web/submission/views.py | 16 +++++---- web/templates/analysis/CAPE/index.html | 2 +- web/templates/analysis/dropped/index.html | 2 +- web/templates/analysis/procdump/index.html | 2 +- web/templates/analysis/static/_pe32.html | 2 +- 7 files changed, 40 insertions(+), 38 deletions(-) diff --git a/web/analysis/views.py b/web/analysis/views.py index 12c18c19a97..24ebfd8aed5 100644 --- a/web/analysis/views.py +++ b/web/analysis/views.py @@ -885,6 +885,10 @@ def file(request, category, task_id, dlfile): if category == "sample": path = os.path.join(CUCKOO_ROOT, "storage", "binaries", dlfile) + elif category == "bingraph": + path = os.path.join(CUCKOO_ROOT, "storage", "analyses", str(task_id), "bingraph", file_name+"-ent.svg") + file_name = file_name+"-ent.svg" + cd = "image/svg+xml" elif category in ("samplezip", "dropped", "droppedzip", "CAPE", "CAPEZIP", "procdump", "procdumpzip", "memdumpzip"): # ability to download password protected zip archives path = "" @@ -900,11 +904,9 @@ def file(request, category, task_id, dlfile): else: path = buf elif category.startswith("procdump"): - buf = os.path.join(CUCKOO_ROOT, "storage", "analyses", task_id, "procdump", file_name) - path = buf + path = os.path.join(CUCKOO_ROOT, "storage", "analyses", task_id, "procdump", file_name) elif category.startswith("memdumpzip"): - buf = os.path.join(CUCKOO_ROOT, "storage", "analyses", task_id, "memory", file_name) - path = buf + path = os.path.join(CUCKOO_ROOT, "storage", "analyses", task_id, "memory", file_name) file_name += ".dmp" TMPDIR = "/tmp" if path and category in ("samplezip", "droppedzip", "CAPEZIP", "procdumpzip", "memdumpzip"): @@ -922,16 +924,14 @@ def file(request, category, task_id, dlfile): path = os.path.join(CUCKOO_ROOT, "storage", "analyses", task_id, "rtf_objects", file_name) elif category == "pcap": file_name += ".pcap" - path = os.path.join(CUCKOO_ROOT, "storage", "analyses", - task_id, "dump.pcap") + path = os.path.join(CUCKOO_ROOT, "storage", "analyses", task_id, "dump.pcap") cd = "application/vnd.tcpdump.pcap" elif category == "screenshot": file_name += ".jpg" path = os.path.join(CUCKOO_ROOT, "storage", "analyses", task_id, "shots", file_name) cd = "image/jpeg" elif category == "usage": - path = os.path.join(CUCKOO_ROOT, "storage", "analyses", - task_id, "aux", "usage.svg") + path = os.path.join(CUCKOO_ROOT, "storage", "analyses", task_id, "aux", "usage.svg") file_name = "usage.svg" cd = "image/svg+xml" elif category in extmap: diff --git a/web/api/views.py b/web/api/views.py index 77964803506..965e7987839 100644 --- a/web/api/views.py +++ b/web/api/views.py @@ -545,26 +545,26 @@ def tasks_create_file(request): continue for entry in task_machines: try: - task_ids_new = db.demux_sample_and_add_to_db(file_path=path, - package=package, - timeout=timeout, - priority=priority, - options=options, - machine=entry, - platform=platform, - tags=tags, - custom=custom, - memory=memory, - enforce_timeout=enforce_timeout, - clock=clock, - shrike_url=shrike_url, - shrike_msg=shrike_msg, - shrike_sid=shrike_sid, - shrike_refer=shrike_refer - ) + task_ids_new = db.demux_sample_and_add_to_db( + file_path=path, + package=package, + timeout=timeout, + priority=priority, + options=options, + machine=entry, + platform=platform, + tags=tags, + custom=custom, + memory=memory, + enforce_timeout=enforce_timeout, + clock=clock, + shrike_url=shrike_url, + shrike_msg=shrike_msg, + shrike_sid=shrike_sid, + shrike_refer=shrike_refer + ) except CuckooDemuxError as e: - resp = {"error": True, - "error_value": e} + resp = {"error": True, "error_value": e} return jsonize(resp, response=True) if task_ids_new: diff --git a/web/submission/views.py b/web/submission/views.py index c5d02e1b9df..2f9cd9f0686 100644 --- a/web/submission/views.py +++ b/web/submission/views.py @@ -35,9 +35,11 @@ # this required for hash searches FULL_DB = False HAVE_DIST = False -repconf = Config("reporting") cfg = Config("cuckoo") +routing = Config("routing") +repconf = Config("reporting") processing = Config("processing") + db = Database() if repconf.distributed.enabled: @@ -72,11 +74,11 @@ def load_vms_tags(): all_tags = list() if HAVE_DIST and repconf.distributed.enabled: try: - db = session() + tmp_db = session() for vm in db.query(Machine).all(): all_tags += vm.tags all_tags = sorted([_f for _f in all_tags if _f]) - db.close() + tmp_db.close() except Exception as e: print(e) @@ -561,10 +563,10 @@ def index(request, resubmit_hash=False): "vpns": list(vpns.values()), "socks5s": list(socks5s.values()), "socks5s_random": socks5s_random, - "route": cfg.routing.route, - "internet": cfg.routing.internet, - "inetsim": cfg.routing.inetsim, - "tor": cfg.routing.tor, + "route": routing.routing.route, + "internet": routing.routing.internet, + "inetsim": routing.inetsim.enabled, + "tor": routing.tor.enabled, "config": enabledconf, "resubmit": resubmit_hash, "tags": sorted(list(set(all_tags))), diff --git a/web/templates/analysis/CAPE/index.html b/web/templates/analysis/CAPE/index.html index 436398d02bc..6f65c73bd82 100644 --- a/web/templates/analysis/CAPE/index.html +++ b/web/templates/analysis/CAPE/index.html @@ -193,7 +193,7 @@ {% endif %} {% if graphs.bingraph.enabled and graphs.bingraph.content|getkey:file.sha256 %} -

BinGraph

+

BinGraph Download graph

{{ graphs.bingraph.content|getkey:file.sha256|safe }} {% endif %} diff --git a/web/templates/analysis/dropped/index.html b/web/templates/analysis/dropped/index.html index 12a56b377f4..54ce8d4c4c1 100644 --- a/web/templates/analysis/dropped/index.html +++ b/web/templates/analysis/dropped/index.html @@ -108,7 +108,7 @@ {% endif %} {% if graphs.bingraph.enabled and graphs.bingraph.content|getkey:file.sha256 %} -

BinGraph

+

BinGraph Download graph

{{ graphs.bingraph.content|getkey:file.sha256|safe }} {% endif %} diff --git a/web/templates/analysis/procdump/index.html b/web/templates/analysis/procdump/index.html index 76ae1a92c9b..6bca6629ff0 100644 --- a/web/templates/analysis/procdump/index.html +++ b/web/templates/analysis/procdump/index.html @@ -99,7 +99,7 @@ {% endif %} {% if graphs.bingraph.enabled and graphs.bingraph.content|getkey:file.sha256 %} -

BinGraph

+

BinGraph Download graph

{{ graphs.bingraph.content|getkey:file.sha256|safe }} {% endif %} diff --git a/web/templates/analysis/static/_pe32.html b/web/templates/analysis/static/_pe32.html index 0d28c71e64f..5a56c76be4c 100644 --- a/web/templates/analysis/static/_pe32.html +++ b/web/templates/analysis/static/_pe32.html @@ -1,7 +1,7 @@
{% load key_tags %} {% if graphs.bingraph.enabled and graphs.bingraph.content|getkey:analysis.target.file.sha256 %} -

BinGraph

+

BinGraph Download graph

{{ graphs.bingraph.content|getkey:analysis.target.file.sha256|safe }} {% endif %} {% if analysis.static and analysis.static.pe %}