1
2
3
4
5 import time
6 import json
7 import logging
8 from datetime import datetime
9
10 from lib.cuckoo.core.database import Database
11 from lib.cuckoo.common.abstracts import Processing
12 from lib.cuckoo.common.constants import CUCKOO_VERSION
13
14 log = logging.getLogger(__name__)
15
17 """General information about analysis session."""
18
20 """Run information gathering.
21 @return: information dict.
22 """
23 self.key = "info"
24
25 try:
26 started = time.strptime(self.task["started_on"], "%Y-%m-%d %H:%M:%S")
27 started = datetime.fromtimestamp(time.mktime(started))
28 ended = time.strptime(self.task["completed_on"], "%Y-%m-%d %H:%M:%S")
29 ended = datetime.fromtimestamp(time.mktime(ended))
30 except:
31 log.critical("Failed to get start/end time from Task.")
32 duration = -1
33 else:
34 duration = (ended - started).seconds
35
36 db = Database()
37
38
39 task = db.view_task(self.task["id"], details=True)
40
41 if task and task.guest:
42
43 machine = task.guest.to_dict()
44
45 del(machine["task_id"])
46
47 self.task["machine"] = machine
48
49 return dict(
50 version=CUCKOO_VERSION,
51 started=self.task["started_on"],
52 ended=self.task.get("completed_on", "none"),
53 duration=duration,
54 id=int(self.task["id"]),
55 category=self.task["category"],
56 custom=self.task["custom"],
57 machine=self.task["machine"],
58 package=self.task["package"]
59 )
60