Exemple #1
0
    def test_wrapped_w3af(self):
        """
        Strange behaviour when wrapping w3af_console
        https://github.com/andresriancho/w3af/issues/1299
        """
        # Just in case... we don't want to break other tests
        startup_cfg = StartUpConfig()
        startup_cfg.last_upd = datetime.date.today()
        startup_cfg.set_accepted_disclaimer(True)
        startup_cfg.save()

        # The easy way to do this was to simply pass 'python' to Popen
        # but now that we want to run the tests in virtualenv, we need to
        # find the "correct" / "virtual" python executable using which and
        # then pass that one to Popen
        python_executable = sys.executable
        
        p = subprocess.Popen([python_executable, 'w3af_console', '-n'],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE,
                             stdin=subprocess.PIPE,
                             shell=False,
                             universal_newlines=True)

        # Now we run a new ConsoleUI that will load the saved settings. We
        # should see /tmp/ as the value for msf_location
        commands_to_run = ['profiles',
                           'back',
                           'misc-settings',
                           'view',
                           'back',
                           'exit']

        expected_output = 'msf_location'

        stdout, stderr = p.communicate('\r'.join(commands_to_run) + '\r')

        msg = 'Failed to find "%s" in "%s" using "%s" as python executable.'
        msg = msg % (expected_output, stdout, python_executable)
        self.assertIn(expected_output, stdout, msg)
Exemple #2
0
    def test_wrapped_w3af(self):
        """
        Strange behaviour when wrapping w3af_console
        https://github.com/andresriancho/w3af/issues/1299
        """
        # Just in case... we don't want to break other tests
        startup_cfg = StartUpConfig()
        startup_cfg.last_upd = datetime.date.today()
        startup_cfg.set_accepted_disclaimer(True)
        startup_cfg.save()

        # The easy way to do this was to simply pass 'python' to Popen
        # but now that we want to run the tests in virtualenv, we need to
        # find the "correct" / "virtual" python executable using which and
        # then pass that one to Popen
        python_executable = sys.executable

        p = subprocess.Popen([python_executable, 'w3af_console', '-n'],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE,
                             stdin=subprocess.PIPE,
                             shell=False,
                             universal_newlines=True)

        # Now we run a new ConsoleUI that will load the saved settings. We
        # should see /tmp/ as the value for msf_location
        commands_to_run = [
            'profiles', 'back', 'misc-settings', 'view', 'back', 'exit'
        ]

        expected_output = 'msf_location'

        stdout, stderr = p.communicate('\r'.join(commands_to_run) + '\r')

        msg = 'Failed to find "%s" in "%s" using "%s" as python executable.'
        msg = msg % (expected_output, stdout, python_executable)
        self.assertIn(expected_output, stdout, msg)