Ejemplo n.º 1
0
    def test_post_sample_file(self):
        """Test POST mimikatz sample file, should return True."""

        md5, sha1 = SampleFileHelpers.download_latest_mimikatz()

        url = reverse('incoming-sample', args={md5})

        with open('/tmp/x64/mimikatz.exe', 'rb') as fd:
            response = self.client.post(
                url, fd.read(), content_type='application/octet-stream')

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertTrue(SampleItem.objects.filter(md5=md5).exists())

        item = SampleItem.objects.get()
        item.delete()
Ejemplo n.º 2
0
    def test_delete_sample_removes_file(self):
        """Test delete SampleFile removes object from disk. Should return
           False."""
        md5, sha1 = SampleFileHelpers.download_latest_mimikatz()

        url = reverse('incoming-sample', args={md5})

        with open('/tmp/x64/mimikatz.exe', 'rb') as fd:
            self.client.post(url,
                             fd.read(),
                             content_type='application/octet-stream')

        self.assertTrue(SampleItem.objects.filter(md5=md5).exists())

        item = SampleItem.objects.get()
        path = item.sample.path

        self.assertTrue(access(path, R_OK))
        item.delete()

        self.assertFalse(access(path, R_OK))