Commit b479e5a5 by Joshua Abraham

Made search tab complete and other fixes

parent 311d72d9
......@@ -181,7 +181,7 @@ class RoutersploitInterpreter(BaseInterpreter):
self.prompt_hostname = 'rsf'
self.show_sub_commands = ('info', 'options', 'devices', 'all', 'creds', 'exploits', 'scanners')
self.global_commands = sorted(['use ', 'exec ', 'help', 'exit', 'show '])
self.global_commands = sorted(['use ', 'exec ', 'help', 'exit', 'show ', 'search '])
self.module_commands = ['run', 'back', 'set ', 'setg ', 'check']
self.module_commands.extend(self.global_commands)
self.module_commands.sort()
......@@ -459,9 +459,9 @@ class RoutersploitInterpreter(BaseInterpreter):
def command_search(self, *args, **kwargs):
for arg in args:
matches = [s for s in self.modules if arg in str(s)]
matches = [s for s in self.modules if arg in s]
for match in matches:
print(match.replace('.', '/'))
utils.print_info(match.replace('.', '/'))
def command_exit(self, *args, **kwargs):
raise EOFError
......@@ -70,9 +70,7 @@ class Exploit(exploits.Exploit):
def check(self):
try:
conn = telnetlib.Telnet(self.target, self.port)
except:
return False
output = conn.read_until("login:")
if 'Grandstream' in output:
return True
except Exception:
return False
else:
return 'Grandstream' in conn.read_until("login:")
......@@ -256,21 +256,21 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
def test_suggested_commands_with_loaded_module_and_no_global_value_set(self):
self.assertEqual(
list(self.interpreter.suggested_commands()),
['back', 'check', 'exec ', 'exit', 'help', 'run', 'set ', 'setg ', 'show ', 'use '] # Extra space at the end because of following param
['back', 'check', 'exec ', 'exit', 'help', 'run', 'search ', 'set ', 'setg ', 'show ', 'use '] # Extra space at the end because of following param
)
def test_suggested_commands_with_loaded_module_and_global_value_set(self):
GLOBAL_OPTS['key'] = 'value'
self.assertEqual(
list(self.interpreter.suggested_commands()),
['back', 'check', 'exec ', 'exit', 'help', 'run', 'set ', 'setg ', 'show ', 'unsetg ', 'use '] # Extra space at the end because of following param
['back', 'check', 'exec ', 'exit', 'help', 'run', 'search ', 'set ', 'setg ', 'show ', 'unsetg ', 'use '] # Extra space at the end because of following param
)
def test_suggested_commands_without_loaded_module(self):
self.interpreter.current_module = None
self.assertEqual(
self.interpreter.suggested_commands(), # Extra space at the end because of following param
['exec ', 'exit', 'help', 'show ', 'use ']
['exec ', 'exit', 'help', 'search ', 'show ', 'use ']
)
@mock.patch('importlib.import_module')
......
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