Example #1
0
class TestExploitSourceFileComplicatedUrl(unittest.TestCase):
    def setUp(self):
        self.test_data_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), '..', 'test_data')

        self.exploit_file = os.path.join(self.test_data_path, 'exploit-source',
                                         'platforms', 'linux', 'remote',
                                         'two_different_one_same_cve.txt')

        self.exploit_source = ExploitSource(
            'exploit-source',
            'http://www.exploit-source.com/two_different_one_same_cve.txt')
        self.mock_source = ExploitSource('exploit-source', self.exploit_file)

    @mock.patch('requests.get')
    def test_exploits(self, mock_url_call):
        mock_url_call.return_value = mock.MagicMock(
            status_code=200,
            headers={'content-type': "application/json"},
            content=self.mock_source.read())
        exploits = self.exploit_source.exploits()
        self.assertEqual(len(exploits), 1)
        self.assertEqual(
            exploits[0]['exploit'],
            'Q1ZFLTIwMTctMDAwNSBDVkUtMjAxNy0wMDA2CkNWRS0yMDE3LTAwMDU=')
        self.assertEqual(len(exploits[0]['cves']), 2)
        self.assertIn('CVE-2017-0005', exploits[0]['cves'])
        self.assertIn('CVE-2017-0006', exploits[0]['cves'])
        self.assertEqual(exploits[0]['id'], 'two_different_one_same_cve')
        self.assertEqual('exploit-source', exploits[0]['source'])
Example #2
0
class TestExploitSourceFileComplicated(unittest.TestCase):
    def setUp(self):
        self.test_data_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), '..', 'test_data')

        self.exploit_file = os.path.join(self.test_data_path, 'exploit-source',
                                         'platforms', 'linux', 'remote',
                                         'two_different_one_same_cve.txt')

        self.exploit_source = ExploitSource('exploit-source',
                                            self.exploit_file)

    def test_data_is_not_list(self):
        self.assertFalse(isinstance(self.exploit_source.data, list))

    def test_exploits(self):
        exploits = self.exploit_source.exploits()
        self.assertEqual(len(self.exploit_source.exploits()), 1)
        self.assertEqual(
            exploits[0]['exploit'],
            'Q1ZFLTIwMTctMDAwNSBDVkUtMjAxNy0wMDA2CkNWRS0yMDE3LTAwMDU=')
        self.assertEqual(len(exploits[0]['cves']), 2)
        self.assertIn('CVE-2017-0005', exploits[0]['cves'])
        self.assertIn('CVE-2017-0006', exploits[0]['cves'])
        self.assertEqual(exploits[0]['id'], 'two_different_one_same_cve')
        self.assertEqual('exploit-source', exploits[0]['source'])
Example #3
0
    def setUp(self):
        self.test_data_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), '..', 'test_data')

        self.exploit_dir = os.path.join(self.test_data_path, 'exploit-source')

        self.exploit_source = ExploitSource('exploit-source', self.exploit_dir)
Example #4
0
    def setUp(self):
        self.test_data_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), '..', 'test_data')

        self.exploit_file = os.path.join(self.test_data_path, 'exploit-source',
                                         'platforms', 'linux', 'remote',
                                         'two_different_one_same_cve.txt')

        self.exploit_source = ExploitSource('exploit-source',
                                            self.exploit_file)
Example #5
0
    def setUp(self):
        self.test_data_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), '..', 'test_data')

        self.exploit_file = os.path.join(self.test_data_path, 'exploit-source',
                                         'platforms', 'linux', 'local',
                                         'one_cve.py')

        self.exploit_source = ExploitSource('exploit-source',
                                            self.exploit_file)
Example #6
0
class TestExploitSourceDir(unittest.TestCase):
    def setUp(self):
        self.test_data_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), '..', 'test_data')

        self.exploit_dir = os.path.join(self.test_data_path, 'exploit-source')

        self.exploit_source = ExploitSource('exploit-source', self.exploit_dir)

    def test_exploits(self):
        exploits = self.exploit_source.exploits()
        self.assertEqual(len(exploits), 7)
Example #7
0
class TestExploitSourceFile(unittest.TestCase):
    def setUp(self):
        self.test_data_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), '..', 'test_data')

        self.exploit_file = os.path.join(self.test_data_path, 'exploit-source',
                                         'platforms', 'linux', 'local',
                                         'one_cve.py')

        self.exploit_source = ExploitSource('exploit-source',
                                            self.exploit_file)

    def test_data_is_not_list(self):
        self.assertFalse(isinstance(self.exploit_source.data, list))

    def test_exploits(self):
        exploits = self.exploit_source.exploits()
        self.assertEqual(len(exploits), 1)
        self.assertEqual(exploits[0]['exploit'], 'Q1ZFLTIwMTctMQo=')
        self.assertEqual(len(exploits[0]['cves']), 1)
        self.assertIn('CVE-2017-1', exploits[0]['cves'])
        self.assertEqual(exploits[0]['id'], 'one_cve')
        self.assertEqual('exploit-source', exploits[0]['source'])
Example #8
0
 def modify_source(self, source_name, location):
     self.sources[source_name] = ExploitSource(source_name, location)