Commit b479e5a5 by Joshua Abraham

Made search tab complete and other fixes

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