Пример #1
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        self._resolver_context = context.Context()
        test_file = self._GetTestFilePath(['lvm.raw'])
        self._SkipIfPathNotExists(test_file)

        path_spec = os_path_spec.OSPathSpec(location=test_file)
        self._raw_path_spec = raw_path_spec.RawPathSpec(parent=path_spec)
Пример #2
0
  def setUp(self):
    """Sets up the needed objects used throughout the test."""
    super(SplitRawFileTest, self).setUp()
    test_file = self._GetTestFilePath(['ext2.splitraw.000'])
    self._SkipIfPathNotExists(test_file)

    path_spec = os_path_spec.OSPathSpec(location=test_file)
    self._raw_path_spec = raw_path_spec.RawPathSpec(parent=path_spec)
Пример #3
0
  def setUp(self):
    """Sets up the needed objects used throughout the test."""
    test_file = self._GetTestFilePath(['gpt.raw'])
    self._SkipIfPathNotExists(test_file)

    path_spec = os_path_spec.OSPathSpec(location=test_file)
    path_spec = raw_path_spec.RawPathSpec(parent=path_spec)
    self._gpt_path_spec = gpt_path_spec.GPTPathSpec(
        location='/', parent=path_spec)
Пример #4
0
    def testComparable(self):
        """Tests the path specification comparable property."""
        path_spec = raw_path_spec.RawPathSpec(parent=self._path_spec)

        self.assertIsNotNone(path_spec)

        expected_comparable = '\n'.join(['type: TEST', 'type: RAW', ''])

        self.assertEqual(path_spec.comparable, expected_comparable)
Пример #5
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        super(LVMImageFileTest, self).setUp()
        test_file = self._GetTestFilePath(['lvm.raw'])
        self._SkipIfPathNotExists(test_file)

        path_spec = os_path_spec.OSPathSpec(location=test_file)
        self._raw_path_spec = raw_path_spec.RawPathSpec(parent=path_spec)
        self._lvm_path_spec = lvm_path_spec.LVMPathSpec(
            parent=self._raw_path_spec, volume_index=0)
Пример #6
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        test_file = self._GetTestFilePath(['apfs.raw'])
        self._SkipIfPathNotExists(test_file)

        path_spec = os_path_spec.OSPathSpec(location=test_file)
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)
        self._apfs_container_path_spec = (
            apfs_container_path_spec.APFSContainerPathSpec(location='/',
                                                           parent=path_spec))
Пример #7
0
  def testOpenCloseLocation(self):
    """Test the open and close functionality using a location."""
    self._TestOpenCloseLocation(self._raw_path_spec)

    # Try open with a path specification that has no parent.
    path_spec = raw_path_spec.RawPathSpec(parent=self._os_path_spec)
    path_spec.parent = None

    with self.assertRaises(errors.PathSpecError):
      self._TestOpenCloseLocation(path_spec)
Пример #8
0
 def setUp(self):
     """Sets up the needed objects used throughout the test."""
     test_file = self._GetTestFilePath(['apfs.dmg'])
     path_spec = os_path_spec.OSPathSpec(location=test_file)
     path_spec = raw_path_spec.RawPathSpec(parent=path_spec)
     self._partition_path_spec = tsk_partition_path_spec.TSKPartitionPathSpec(
         location='/p1', parent=path_spec)
     self._apfs_container_path_spec = (
         apfs_container_path_spec.APFSContainerPathSpec(
             location='/', parent=self._partition_path_spec))
Пример #9
0
  def testGetFileSystemTypeIndicatorsNTFS(self):
    """Tests the GetFileSystemTypeIndicators function on a NTFS file system."""
    test_file = self._GetTestFilePath(['ntfs.raw'])
    self._SkipIfPathNotExists(test_file)

    path_spec = os_path_spec.OSPathSpec(location=test_file)
    path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

    expected_type_indicators = [definitions.PREFERRED_NTFS_BACK_END]
    type_indicators = analyzer.Analyzer.GetFileSystemTypeIndicators(path_spec)
    self.assertEqual(type_indicators, expected_type_indicators)
Пример #10
0
  def testGetFileSystemTypeIndicatorsXFS(self):
    """Tests the GetFileSystemTypeIndicators function on an XFS file system."""
    test_file = self._GetTestFilePath(['xfs.raw'])
    self._SkipIfPathNotExists(test_file)

    path_spec = os_path_spec.OSPathSpec(location=test_file)
    path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

    expected_type_indicators = [definitions.TYPE_INDICATOR_XFS]
    type_indicators = analyzer.Analyzer.GetFileSystemTypeIndicators(path_spec)
    self.assertEqual(type_indicators, expected_type_indicators)
Пример #11
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        self._resolver_context = context.Context()
        test_file = self._GetTestFilePath(['apfs.dmg'])
        path_spec = os_path_spec.OSPathSpec(location=test_file)
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)
        self._partition_path_spec = tsk_partition_path_spec.TSKPartitionPathSpec(
            location='/p1', parent=path_spec)
        self._apfs_container_path_spec = (
            apfs_container_path_spec.APFSContainerPathSpec(
                location='/', parent=self._partition_path_spec))

        self._file_system = apfs_container_file_system.APFSContainerFileSystem(
            self._resolver_context)
        self._file_system.Open(self._apfs_container_path_spec)
Пример #12
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        self._resolver_context = context.Context()
        test_file = self._GetTestFilePath(['apfs_encrypted.dmg'])
        path_spec = os_path_spec.OSPathSpec(location=test_file)
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)
        partition_path_spec = tsk_partition_path_spec.TSKPartitionPathSpec(
            location='/p1', parent=path_spec)
        self._apfs_container_path_spec = (
            apfs_container_path_spec.APFSContainerPathSpec(
                location='/apfs1', parent=partition_path_spec))
        self._apfs_path_spec = apfs_path_spec.APFSPathSpec(
            location='/', parent=self._apfs_container_path_spec)

        resolver.Resolver.key_chain.SetCredential(
            self._apfs_container_path_spec, 'password', self._APFS_PASSWORD)

        self._file_system = apfs_file_system.APFSFileSystem(
            self._resolver_context)
        self._file_system.Open(self._apfs_path_spec)
Пример #13
0
    def testGetBasePathSpecsPartitionedImage(self):
        """Tests the GetBasePathSpecs function on a partitioned image."""
        test_file = self._GetTestFilePath([u'tsk_volume_system.raw'])
        test_scanner = volume_scanner.VolumeScanner()

        test_os_path_spec = os_path_spec.OSPathSpec(location=test_file)
        test_raw_path_spec = raw_path_spec.RawPathSpec(
            parent=test_os_path_spec)
        test_tsk_partition_path_spec = tsk_partition_path_spec.TSKPartitionPathSpec(
            location=u'/p2',
            part_index=6,
            start_offset=0x0002c000,
            parent=test_raw_path_spec)
        test_tsk_path_spec = tsk_path_spec.TSKPathSpec(
            location=u'/', parent=test_tsk_partition_path_spec)

        expected_base_path_specs = [test_tsk_path_spec.comparable]

        base_path_specs = test_scanner.GetBasePathSpecs(test_file)
        base_path_specs = [
            base_path_spec.comparable for base_path_spec in base_path_specs
        ]

        self.assertEqual(base_path_specs, expected_base_path_specs)
Пример #14
0
    def testGetBasePathSpecs(self):
        """Test the GetBasePathSpecs() function."""
        test_file = os.path.join(u'test_data', u'tsk_volume_system.raw')
        test_scanner = volume_scanner.VolumeScanner()

        test_os_path_spec = os_path_spec.OSPathSpec(location=test_file)
        test_raw_path_spec = raw_path_spec.RawPathSpec(
            parent=test_os_path_spec)
        test_tsk_partition_path_spec = tsk_partition_path_spec.TSKPartitionPathSpec(
            location=u'/p2',
            part_index=6,
            start_offset=0x0002c000,
            parent=test_raw_path_spec)
        test_tsk_path_spec = tsk_path_spec.TSKPathSpec(
            location=u'/', parent=test_tsk_partition_path_spec)

        expected_base_path_specs = [test_tsk_path_spec.comparable]

        base_path_specs = test_scanner.GetBasePathSpecs(test_file)
        base_path_specs = [
            base_path_spec.comparable for base_path_spec in base_path_specs
        ]

        self.assertEqual(base_path_specs, expected_base_path_specs)
Пример #15
0
    def testGlobRawAlphabeticalSuffix(self):
        """Test the glob function for a RAW alphabetical suffix scheme."""
        segment_filenames = ['imageaaa']
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        # Test single segment file: aaa.
        path_spec = fake_path_spec.FakePathSpec(location='/imageaaa')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test non exiting segment file: aaa.
        expected_segment_file_path_specs = []

        path_spec = fake_path_spec.FakePathSpec(location='/bogusaaa')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: aaa-aak.
        segment_filenames = [
            'imageaaa', 'imageaab', 'imageaac', 'imageaad', 'imageaae',
            'imageaaf', 'imageaag', 'imageaah', 'imageaai', 'imageaaj',
            'imageaak'
        ]
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location='/imageaaa')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: AAA-AAk.
        segment_filenames = [
            'imageAAA', 'imageAAB', 'imageAAC', 'imageAAD', 'imageAAE',
            'imageAAF', 'imageAAG', 'imageAAH', 'imageAAI', 'imageAAJ',
            'imageAAK'
        ]
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location='/imageAAA')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)
Пример #16
0
 def setUp(self):
   """Sets up the needed objects used throughout the test."""
   super(SplitRawFileTest, self).setUp()
   test_file = os.path.join(u'test_data', u'image.raw.000')
   path_spec = os_path_spec.OSPathSpec(location=test_file)
   self._raw_path_spec = raw_path_spec.RawPathSpec(parent=path_spec)
Пример #17
0
    def testGlobRawNumericSuffix(self):
        """Test the glob function for a RAW numeric suffix scheme."""
        segment_filenames = ['image1']
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        # Test single segment file: 000.
        path_spec = fake_path_spec.FakePathSpec(location='/image1')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test non exiting segment file: 000.
        expected_segment_file_path_specs = []

        path_spec = fake_path_spec.FakePathSpec(location='/bogus1')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: 000-010.
        segment_filenames = [
            'image0', 'image1', 'image2', 'image3', 'image4', 'image5',
            'image6', 'image7', 'image8', 'image9', 'image10'
        ]
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location='/image0')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: 1-10.
        segment_filenames = [
            'image1', 'image2', 'image3', 'image4', 'image5', 'image6',
            'image7', 'image8', 'image9', 'image10'
        ]
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location='/image1')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: 001-010.
        segment_filenames = [
            'image001', 'image002', 'image003', 'image004', 'image005',
            'image006', 'image007', 'image008', 'image009', 'image010'
        ]
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location='/image001')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)
Пример #18
0
    def testGlobRawNumericExtension(self):
        """Test the glob function for a RAW numeric extension scheme."""
        segment_filenames = [u'image.000']
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        # Test single segment file: 000.
        path_spec = fake_path_spec.FakePathSpec(location=u'/image.000')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test non exiting segment file: 000.
        expected_segment_file_path_specs = []

        path_spec = fake_path_spec.FakePathSpec(location=u'/bogus.000')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: 000-010.
        segment_filenames = [
            u'image.000', u'image.001', u'image.002', u'image.003',
            u'image.004', u'image.005', u'image.006', u'image.007',
            u'image.008', u'image.009', u'image.010'
        ]
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location=u'/image.000')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: 001-010.
        segment_filenames = [
            u'image.001', u'image.002', u'image.003', u'image.004',
            u'image.005', u'image.006', u'image.007', u'image.008',
            u'image.009', u'image.010'
        ]
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location=u'/image.001')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test multiple segment files: 1-10.
        segment_filenames = [
            u'image.1', u'image.2', u'image.3', u'image.4', u'image.5',
            u'image.6', u'image.7', u'image.8', u'image.9', u'image.10'
        ]
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location=u'/image.1')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)
Пример #19
0
    def testGlobRawSinglecExtension(self):
        """Test the glob function for a RAW single extension scheme."""
        # Test single segment file: dd.
        segment_filenames = ['ímynd.dd']
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location='/ímynd.dd')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test single segment file: dmg.
        segment_filenames = ['image.dmg']
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location='/image.dmg')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test single segment file: img.
        segment_filenames = ['image.img']
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location='/image.img')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)

        # Test single segment file: raw.
        segment_filenames = ['image.raw']
        expected_segment_file_path_specs = []
        file_system = self._BuildFileFakeFileSystem(
            segment_filenames, expected_segment_file_path_specs)

        path_spec = fake_path_spec.FakePathSpec(location='/image.raw')
        path_spec = raw_path_spec.RawPathSpec(parent=path_spec)

        segment_file_path_specs = raw.RawGlobPathSpec(file_system, path_spec)
        self.assertEqual(len(segment_file_path_specs),
                         len(expected_segment_file_path_specs))
        self.assertEqual(segment_file_path_specs,
                         expected_segment_file_path_specs)
Пример #20
0
 def setUp(self):
   """Sets up the needed objects used throughout the test."""
   super(RawFileTest, self).setUp()
   test_file = os.path.join(u'test_data', u'ímynd.dd')
   self._os_path_spec = os_path_spec.OSPathSpec(location=test_file)
   self._raw_path_spec = raw_path_spec.RawPathSpec(parent=self._os_path_spec)