Skip to content

Commit

Permalink
allow download graphs and few bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
doomedraven committed Dec 31, 2019
1 parent dc3c6cd commit 1059b72
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 38 deletions.
16 changes: 8 additions & 8 deletions web/analysis/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -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"):
Expand All @@ -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:
Expand Down
38 changes: 19 additions & 19 deletions web/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 9 additions & 7 deletions web/submission/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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))),
Expand Down
2 changes: 1 addition & 1 deletion web/templates/analysis/CAPE/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
{% endif %}
</table>
{% if graphs.bingraph.enabled and graphs.bingraph.content|getkey:file.sha256 %}
<h4>BinGraph</h4>
<h4>BinGraph <a href="{% url "file" "bingraph" analysis.info.id file.sha256 %}" class="btn btn-primary btn-small">Download graph</a></h4>
{{ graphs.bingraph.content|getkey:file.sha256|safe }}
{% endif %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/templates/analysis/dropped/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
{% endif %}
</table>
{% if graphs.bingraph.enabled and graphs.bingraph.content|getkey:file.sha256 %}
<h4>BinGraph</h4>
<h4>BinGraph <a href="{% url "file" "bingraph" analysis.info.id file.sha256 %}" class="btn btn-primary btn-small">Download graph</a></h4>
{{ graphs.bingraph.content|getkey:file.sha256|safe }}
{% endif %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/templates/analysis/procdump/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
{% endif %}
</table>
{% if graphs.bingraph.enabled and graphs.bingraph.content|getkey:file.sha256 %}
<h4>BinGraph</h4>
<h4>BinGraph <a href="{% url "file" "bingraph" analysis.info.id file.sha256 %}" class="btn btn-primary btn-small">Download graph</a></h4>
{{ graphs.bingraph.content|getkey:file.sha256|safe }}
{% endif %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/templates/analysis/static/_pe32.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<section id="static_analysis">
{% load key_tags %}
{% if graphs.bingraph.enabled and graphs.bingraph.content|getkey:analysis.target.file.sha256 %}
<h4>BinGraph</h4>
<h4>BinGraph <a href="{% url "file" "bingraph" analysis.info.id analysis.target.file.sha256 %}" class="btn btn-primary btn-small">Download graph</a></h4>
{{ graphs.bingraph.content|getkey:analysis.target.file.sha256|safe }}
{% endif %}
{% if analysis.static and analysis.static.pe %}
Expand Down

0 comments on commit 1059b72

Please sign in to comment.