modules.processing.targetinfo

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

# Source Code for Module modules.processing.targetinfo

     1  # Copyright (C) 2010-2013 Claudio Guarnieri.
     2  # Copyright (C) 2014-2016 Cuckoo Foundation.
     3  # This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
     4  # See the file 'docs/LICENSE' for copying permission.
     5
     6  import os.path
     7
     8  from lib.cuckoo.common.abstracts import Processing
     9  from lib.cuckoo.common.objects import File
    10
    11 -class TargetInfo(Processing):
    12      """General information about a file."""
    13
    14 -    def run(self):
    15          """Run file information gathering.
    16          @return: information dict.
    17          """
    18          self.key = "target"
    19          if not self.task:
    20              return {"category": "unknown", "file": {"name": "unknown"}}
    21
    22          target_info = {"category": self.task["category"]}
    23
    24          # We have to deal with file or URL targets.
    25          if self.task["category"] == "file":
    26              target_info["file"] = {}
    27
    28              # et's try to get as much information as possible, i.e., the
    29              # filename if the file is not available anymore.
    30              if os.path.exists(self.file_path):
    31                  target_info["file"] = File(self.file_path).get_all()
    32
    33              target_info["file"]["name"] = File(self.task["target"]).get_name()
    34          elif self.task["category"] == "url":
    35              target_info["url"] = self.task["target"]
    36
    37          return target_info
    38