Commit 66be5de2 by fwkz

'show' command available globally

parent ac339a95
......@@ -255,7 +255,7 @@ class RoutersploitInterpreter(BaseInterpreter):
return itertools.chain(module_commands, ('unsetg ',))
return module_commands
else:
return ['use ', 'exec', 'help', 'exit']
return ['use ', 'exec', 'help', 'exit', 'show ']
def command_back(self, *args, **kwargs):
self.current_module = None
......@@ -352,6 +352,7 @@ class RoutersploitInterpreter(BaseInterpreter):
else:
yield opt_key, opt_value, opt_description
@utils.module_required
def _show_info(self, *args, **kwargs):
utils.pprint_dict_in_order(
self.module_metadata,
......@@ -359,6 +360,7 @@ class RoutersploitInterpreter(BaseInterpreter):
)
utils.print_info()
@utils.module_required
def _show_options(self, *args, **kwargs):
target_opts = {'port', 'target'}
module_opts = set(self.current_module.options) - target_opts
......@@ -373,6 +375,7 @@ class RoutersploitInterpreter(BaseInterpreter):
utils.print_info()
@utils.module_required
def _show_devices(self, *args, **kwargs): # TODO: cover with tests
try:
devices = self.current_module._Exploit__info__['devices']
......@@ -389,7 +392,6 @@ class RoutersploitInterpreter(BaseInterpreter):
except KeyError:
print("\nTarget devices are not defined")
@utils.module_required
def command_show(self, *args, **kwargs):
sub_commands = ('info', 'options', 'devices')
sub_command = args[0]
......
......@@ -32,7 +32,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
def test_raw_commands_no_module(self):
self.rsf.send("\t\t")
self.assertPrompt('exec exit help use \r\n', self.raw_prompt)
self.assertPrompt('exec exit help show use \r\n', self.raw_prompt)
def test_complete_use_raw(self):
self.rsf.send("u\t\t")
......
......@@ -266,7 +266,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
self.interpreter.current_module = None
self.assertEqual(
self.interpreter.suggested_commands(), # Extra space at the end because of following param
['use ', 'exec', 'help', 'exit']
['use ', 'exec', 'help', 'exit', 'show ']
)
@mock.patch('importlib.import_module')
......@@ -491,9 +491,21 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
"module_required"
)
def test_if_command_show_has_module_required_decorator(self):
def test_if_command_show_info_has_module_required_decorator(self):
self.assertIsDecorated(
self.interpreter.command_show,
self.interpreter._show_info,
"module_required"
)
def test_if_command_show_options_has_module_required_decorator(self):
self.assertIsDecorated(
self.interpreter._show_options,
"module_required"
)
def test_if_command_show_devices_has_module_required_decorator(self):
self.assertIsDecorated(
self.interpreter._show_devices,
"module_required"
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment