Package modules :: Package processing :: Module analysisinfo
[hide private]
[frames] | no frames]

Source Code for Module modules.processing.analysisinfo

 1  # Copyright (C) 2010-2015 Cuckoo Foundation. 
 2  # This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org 
 3  # See the file 'docs/LICENSE' for copying permission. 
 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   
16 -class AnalysisInfo(Processing):
17 """General information about analysis session.""" 18
19 - def run(self):
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 # Fetch sqlalchemy object. 39 task = db.view_task(self.task["id"], details=True) 40 41 if task and task.guest: 42 # Get machine description ad json. 43 machine = task.guest.to_dict() 44 # Remove useless task_id. 45 del(machine["task_id"]) 46 # Save. 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