forked from cuckoosandbox/cuckoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalysisinfo.py
More file actions
59 lines (49 loc) · 1.87 KB
/
Copy pathanalysisinfo.py
File metadata and controls
59 lines (49 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright (C) 2010-2014 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
import time
import json
import logging
from datetime import datetime
from lib.cuckoo.core.database import Database
from lib.cuckoo.common.abstracts import Processing
from lib.cuckoo.common.constants import CUCKOO_VERSION
log = logging.getLogger(__name__)
class AnalysisInfo(Processing):
"""General information about analysis session."""
def run(self):
"""Run information gathering.
@return: information dict.
"""
self.key = "info"
try:
started = time.strptime(self.task["started_on"], "%Y-%m-%d %H:%M:%S")
started = datetime.fromtimestamp(time.mktime(started))
ended = time.strptime(self.task["completed_on"], "%Y-%m-%d %H:%M:%S")
ended = datetime.fromtimestamp(time.mktime(ended))
except:
log.critical("Failed to get start/end time from Task.")
duration = -1
else:
duration = (ended - started).seconds
db = Database()
# Fetch sqlalchemy object.
task = db.view_task(self.task["id"], details=True)
if task and task.guest:
# Get machine description ad json.
machine = task.guest.to_dict()
# Remove useless task_id.
del(machine["task_id"])
# Save.
self.task["machine"] = machine
return dict(
version=CUCKOO_VERSION,
started=self.task["started_on"],
ended=self.task.get("completed_on", "none"),
duration=duration,
id=int(self.task["id"]),
category=self.task["category"],
custom=self.task["custom"],
machine=self.task["machine"],
package=self.task["package"]
)