Commit 1444f4f1 by fwkz

Differentiate CTRL+D and CTRL+C

parent 0a14e8bb
...@@ -83,10 +83,12 @@ class BaseInterpreter(object): ...@@ -83,10 +83,12 @@ class BaseInterpreter(object):
command_handler(args) command_handler(args)
except RoutersploitException as err: except RoutersploitException as err:
utils.print_error(err) utils.print_error(err)
except (KeyboardInterrupt, EOFError): except EOFError:
print() print()
utils.print_status("routersploit stopped") utils.print_status("routersploit stopped")
break break
except KeyboardInterrupt:
print()
def complete(self, text, state): def complete(self, text, state):
"""Return the next possible completion for 'text'. """Return the next possible completion for 'text'.
...@@ -386,4 +388,4 @@ class RoutersploitInterpreter(BaseInterpreter): ...@@ -386,4 +388,4 @@ class RoutersploitInterpreter(BaseInterpreter):
os.system(args[0]) os.system(args[0])
def command_exit(self, *args, **kwargs): def command_exit(self, *args, **kwargs):
raise KeyboardInterrupt raise EOFError
...@@ -152,8 +152,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase): ...@@ -152,8 +152,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
self.interpreter.current_module = None self.interpreter.current_module = None
self.assertEqual(self.raw_prompt_default, self.interpreter.prompt) self.assertEqual(self.raw_prompt_default, self.interpreter.prompt)
def test_custom_module_\ def test_custom_module_prompt(self):
(self):
self.prepare_prompt_env_variables(module_prompt="*{host}*{module} >>>") self.prepare_prompt_env_variables(module_prompt="*{host}*{module} >>>")
module_name = "module_name" module_name = "module_name"
self.interpreter.current_module._MagicMock__info__ = {'name': module_name} self.interpreter.current_module._MagicMock__info__ = {'name': module_name}
...@@ -431,7 +430,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase): ...@@ -431,7 +430,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
) )
def test_command_exit(self): def test_command_exit(self):
with self.assertRaises(KeyboardInterrupt): with self.assertRaises(EOFError):
self.interpreter.command_exit() self.interpreter.command_exit()
@mock.patch('os.system') @mock.patch('os.system')
......
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