modules.packages.pdf

Package modules :: Package packages :: Module pdf |
[hide private]
[frames] | no frames]

# Source Code for Module modules.packages.pdf

     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 logging
     7  import os
     8
     9  from _winreg import HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER
    10
    11  from lib.common.abstracts import Package
    12
    13  log = logging.getLogger(__name__)
    14
    15 -class PDF(Package):
    16      """PDF analysis package."""
    17      PATHS = [
    18          ("ProgramFiles", "Adobe", "Reader 8.0", "Reader", "AcroRd32.exe"),
    19          ("ProgramFiles", "Adobe", "Reader 9.0", "Reader", "AcroRd32.exe"),
    20          ("ProgramFiles", "Adobe", "Reader 10.0", "Reader", "AcroRd32.exe"),
    21          ("ProgramFiles", "Adobe", "Reader 11.0", "Reader", "AcroRd32.exe"),
    22          ("ProgramFiles", "Adobe", "Acrobat Reader DC", "Reader", "AcroRd32.exe"),
    23      ]
    24
    25      REGKEYS = [
    26          [
    27              HKEY_LOCAL_MACHINE,
    28              "SOFTWARE\\Adobe\\Acrobat Reader\\9.0\\AdobeViewer",
    29              {
    30                  # Accept EULA for Adobe Reader 9.0.
    31                  "EULA": 1,
    32              },
    33          ],
    34          [
    35              HKEY_CURRENT_USER,
    36              "SOFTWARE\\Adobe\\Acrobat Reader\\9.0\\AdobeViewer",
    37              {
    38                  # Accept EULA for Adobe Reader 9.0.
    39                  "EULA": 1,
    40              },
    41          ],
    42      ]
    43
    44 -    def start(self, path):
    45          reader = self.get_path("Adobe Reader")
    46
    47          # Enforce the .pdf file extension.
    48          if not path.endswith(".pdf"):
    49              os.rename(path, path + ".pdf")
    50              path += ".pdf"
    51              log.info("Submitted file is missing extension, added .pdf")
    52
    53          return self.execute(
    54              reader, args=[path], maximize=True, mode="pdf",
    55              trigger="file:%s" % path
    56          )
    57