Ejemplo n.º 1
0
    def test_verify_url(self):
        ctarget = CoreTarget()

        self.assertRaises(BaseFrameworkException, ctarget._verify_url,
                          URL_KLASS('ftp://www.google.com/'))
        
        self.assertTrue(ctarget._verify_url(URL_KLASS('http://www.google.com/')))
        self.assertTrue(ctarget._verify_url(URL_KLASS('http://www.google.com:39/')))
Ejemplo n.º 2
0
    def get_target(self):
        """
        :return: The profile target with the options (target_os,
                 target_framework, etc.)
        """
        # Get the plugin defaults with their types
        target_instance = CoreTarget()
        options = target_instance.get_options()

        for section in self._config.sections():
            # Section is something like audit.xss or crawl.web_spider
            # or [profile] or [target]
            if section == 'target':
                for option in self._config.options(section):
                    options[option].set_value(self._config.get(
                        section, option))

        return options
Ejemplo n.º 3
0
    def get_target(self):
        """
        :return: The profile target with the options (target_os,
                 target_framework, etc.)
        """
        # Get the plugin defaults with their types
        target_instance = CoreTarget()
        options = target_instance.get_options()

        for section in self._config.sections():
            # Section is something like audit.xss or crawl.web_spider
            # or [profile] or [target]
            if section == 'target':
                for option in self._config.options(section):
                    options[option].set_value(
                        self._config.get(section, option))

        return options
Ejemplo n.º 4
0
    def test_verify_file_target(self):
        ctarget = CoreTarget()

        target_file = '/tmp/moth.target'
        target = 'file://%s' % target_file

        target_file_handler = file(target_file, 'w')
        target_file_handler.write('http://moth/1\n')
        target_file_handler.write('http://moth/2\n')
        target_file_handler.close()

        options = ctarget.get_options()
        options['target'].set_value(target)
        ctarget.set_options(options)

        moth1 = URL_KLASS('http://moth/1')
        moth2 = URL_KLASS('http://moth/2')

        self.assertIn(moth1, cf.cf.get('targets'))
        self.assertIn(moth2, cf.cf.get('targets'))
Ejemplo n.º 5
0
    def test_verify_file_target(self):
        ctarget = CoreTarget()

        target_file = '/tmp/moth.target'
        target = 'file://%s' % target_file
        
        target_file_handler = file(target_file, 'w')
        target_file_handler.write('http://moth/1\n')
        target_file_handler.write('http://moth/2\n')
        target_file_handler.close()
        
        options = ctarget.get_options()
        options['target'].set_value(target)
        ctarget.set_options(options)
        
        moth1 = URL_KLASS('http://moth/1')
        moth2 = URL_KLASS('http://moth/2')
        
        self.assertIn(moth1, cf.cf.get('targets'))
        self.assertIn(moth2, cf.cf.get('targets'))
Ejemplo n.º 6
0
    def test_basic(self):
        opt_lst = CoreTarget().get_options()

        for opt in opt_lst:
            self.assertIn(opt.get_type(), OPTION_TYPES)
            self.assertTrue(opt.get_name())
            self.assertEqual(opt, opt)

            # Just verify that this doesn't crash and that the types
            # are correct
            self.assertIsInstance(opt.get_name(), basestring)
            self.assertIsInstance(opt.get_desc(), basestring)
            self.assertIsInstance(opt.get_type(), basestring)
            self.assertIsInstance(opt.get_help(), basestring)
            self.assertIsInstance(opt.get_value_str(), basestring)