本文整理汇总了Python中w3af.core.ui.console.console_ui.ConsoleUI类的典型用法代码示例。如果您正苦于以下问题:Python ConsoleUI类的具体用法?Python ConsoleUI怎么用?Python ConsoleUI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConsoleUI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_load_misc_settings
def test_save_load_misc_settings(self):
# Save the settings
commands_to_run = ['misc-settings set msf_location /etc/',
'profiles save_as %s' % self.get_profile_name(),
'exit']
expected = ('Profile saved.',)
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
assert_result, msg = self.startswith_expected_in_output(expected)
self.assertTrue(assert_result, msg)
self._assert_exists(self.get_profile_name())
# Clean the mocked stdout
self._mock_stdout.clear()
# Load the settings
commands_to_run = ['profiles',
'use %s' % self.get_profile_name(),
'back',
'misc-settings view',
'exit']
expected = ('/etc/',)
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
assert_result, msg = self.all_expected_substring_in_output(expected)
self.assertTrue(assert_result, msg)
示例2: test_menu_browse_target
def test_menu_browse_target(self):
commands_to_run = ['target', 'back', 'exit']
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
expected = ('w3af>>> ', 'w3af/config:target>>> ')
assert_result, msg = self.all_expected_in_output(expected)
self.assertTrue(assert_result, msg)
示例3: test_menu_set_option_auto_save
def test_menu_set_option_auto_save(self):
commands_to_run = ['target set target http://moth/',
'target view',
'exit']
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
expected_start_with = ('| target ',
'The configuration has been saved.')
assert_result, msg = self.startswith_expected_in_output(expected_start_with)
self.assertTrue(assert_result, msg)
示例4: test_load_profile_not_exists
def test_load_profile_not_exists(self):
commands_to_run = ['profiles',
'help',
'use do_not_exist',
'exit']
expected = ('The profile "do_not_exist.pw3af" wasn\'t found.',)
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
assert_result, msg = self.startswith_expected_in_output(expected)
self.assertTrue(assert_result, msg)
示例5: test_save_as_profile_no_param
def test_save_as_profile_no_param(self):
commands_to_run = ['profiles',
'use OWASP_TOP10',
'save_as',
'exit']
expected = ('Parameter missing, please see the help',)
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
assert_result, msg = self.startswith_expected_in_output(expected)
self.assertTrue(assert_result, msg)
示例6: test_menu_set_option_invalid_case01
def test_menu_set_option_invalid_case01(self):
# Invalid port
commands_to_run = ['target', 'set target http://moth:301801/', 'view',
'back', 'exit']
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
expected_start_with = ('Invalid URL configured by user,',
# Because nothing was really saved and the
# config is empty, this will succeed
'The configuration has been saved.')
assert_result, msg = self.startswith_expected_in_output(expected_start_with)
self.assertTrue(assert_result, msg)
示例7: TestAcceptDisclaimer
class TestAcceptDisclaimer(unittest.TestCase):
def setUp(self):
self.console_ui = ConsoleUI(do_upd=False)
class dummy_true(Mock):
accepted_disclaimer = True
class dummy_false(Mock):
accepted_disclaimer = False
@patch('w3af.core.ui.console.console_ui.StartUpConfig', new_callable=dummy_false)
@patch('__builtin__.raw_input', return_value='')
def test_not_saved_not_accepted(self, mocked_startup_cfg, mocked_input):
self.assertFalse(self.console_ui.accept_disclaimer())
@patch('w3af.core.ui.console.console_ui.StartUpConfig', new_callable=dummy_false)
@patch('__builtin__.raw_input', return_value='y')
def test_not_saved_accepted(self, mocked_startup_cfg, mocked_input):
self.assertTrue(self.console_ui.accept_disclaimer())
@patch('w3af.core.ui.console.console_ui.StartUpConfig', new_callable=dummy_true)
def test_saved(self, mocked_startup_cfg):
self.assertTrue(self.console_ui.accept_disclaimer())
示例8: test_save_as_profile
def test_save_as_profile(self):
commands_to_run = ['profiles',
'use OWASP_TOP10',
'save_as unittest',
'exit']
expected = ('Profile saved.',)
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
assert_result, msg = self.startswith_expected_in_output(expected)
self.assertTrue(assert_result, msg)
self._assert_exists('unittest')
示例9: test_menu_simple_save
def test_menu_simple_save(self):
commands_to_run = ['plugins crawl config dir_file_bruter',
'set file_wordlist /etc/passwd',
'save',
'view',
'back',
'exit']
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
expected_start_with = (' /etc/passwd ',
'The configuration has been saved.')
assert_result, msg = self.all_expected_substring_in_output(expected_start_with)
self.assertTrue(assert_result, msg)
示例10: test_menu_plugin_desc
def test_menu_plugin_desc(self):
commands_to_run = ['plugins',
'infrastructure desc zone_h',
'back',
'exit']
expected = ('This plugin searches the zone-h.org',
'result. The information stored in',
'previous defacements to the target website.')
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
assert_result, msg = self.startswith_expected_in_output(expected)
self.assertTrue(assert_result, msg)
示例11: test_menu_save_with_dependencies_error
def test_menu_save_with_dependencies_error(self):
commands_to_run = ['plugins audit config rfi',
'set use_w3af_site false',
'set listen_address abc',
'save',
'view',
'back',
'exit']
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
expected_start_with = ('Identified an error with the user-defined settings',)
assert_result, msg = self.startswith_expected_in_output(expected_start_with)
self.assertTrue(assert_result, msg)
示例12: test_menu_set_option_case01
def test_menu_set_option_case01(self):
commands_to_run = ['target', 'set target http://moth/', 'save', 'view',
'back', 'exit']
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
expected = ('w3af>>> ', 'w3af/config:target>>> ',
'The configuration has been saved.\r\n')
assert_result, msg = self.all_expected_in_output(expected)
self.assertTrue(assert_result, msg)
expected_start_with = ('| http://moth/',)
assert_result, msg = self.all_expected_substring_in_output(expected_start_with)
self.assertTrue(assert_result, msg)
示例13: test_load_profile_exists
def test_load_profile_exists(self):
commands_to_run = ['profiles',
'help',
'use OWASP_TOP10',
'exit']
expected = (
'The plugins configured by the scan profile have been enabled',
'Please set the target URL',
' | Use a profile.')
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
assert_result, msg = self.all_expected_substring_in_output(expected)
self.assertTrue(assert_result, msg)
示例14: test_load_profile_by_filepath
def test_load_profile_by_filepath(self):
tmp_profile = tempfile.NamedTemporaryFile(suffix='.pw3af')
commands_to_run = ['profiles',
'help',
'use ' + tmp_profile.name,
'exit']
expected = (
'The plugins configured by the scan profile have been enabled',
'Please set the target URL',
' | Use a profile.')
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
assert_result, msg = self.all_expected_substring_in_output(expected)
self.assertTrue(assert_result, msg)
示例15: test_menu_save_with_dependencies_success
def test_menu_save_with_dependencies_success(self):
commands_to_run = ['plugins audit config rfi',
'set use_w3af_site false',
'set listen_address 127.0.0.1',
'set listen_port 8081',
'save',
'view',
'back',
'exit']
self.console = ConsoleUI(commands=commands_to_run, do_upd=False)
self.console.sh()
expected_start_with = ('127.0.0.1',
'8081')
assert_result, msg = self.all_expected_substring_in_output(expected_start_with)
self.assertTrue(assert_result, msg)