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
75 lines (64 loc) · 2.35 KB
/
Copy pathanalysisinfo.py
File metadata and controls
75 lines (64 loc) · 2.35 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Copyright (C) 2010-2015 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
import time
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"
if "started_on" not in self.task:
return dict(
version=CUCKOO_VERSION,
started="none",
ended="none",
duration="none",
id=int(self.task["id"]),
category="unknown",
custom="unknown",
machine=None,
package="unknown"
)
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.
machine = task.guest.to_dict()
# Remove superfluous fields.
del machine["task_id"]
del machine["id"]
else:
machine = None
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"],
owner=self.task["owner"],
machine=machine,
package=self.task["package"],
platform=self.task["platform"],
options=self.task["options"],
)