Skip to content

Commit

Permalink
Closes #85 and #30, add exec feature, edit check
Browse files Browse the repository at this point in the history
Add help menus and help command
Add exec feature to be kinda msfconsole-y
Edit check behavior to be a little clearer/more logical
  • Loading branch information
maxzinkus committed May 13, 2016
1 parent c420a95 commit 7b89464
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions routersploit/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import traceback
import atexit
from subprocess import call

from routersploit.exceptions import RoutersploitException
from routersploit import utils
Expand All @@ -16,6 +17,8 @@
class BaseInterpreter(object):
history_file = os.path.expanduser("~/.history")
history_length = 100
global_help = ""


def __init__(self):
self.setup()
Expand Down Expand Up @@ -146,6 +149,18 @@ def suggested_commands(self):

class RoutersploitInterpreter(BaseInterpreter):
history_file = os.path.expanduser("~/.rsf_history")
global_help = """Global commands:
help Print this help menu
use <module> Select a module for usage
exec <shell command> <args> Execute a command in a shell
exit Exit RouterSploit"""

module_help = """Module commands:
run Run the selected module with the given options
back De-select the current module
set <option name>=<option value> Set an option for the selected module
show [info|options|devices] Print information, options, or target devices for a module
check Check if a given target is vulnerable to a selected module's exploit"""

def __init__(self):
super(RoutersploitInterpreter, self).__init__()
Expand Down Expand Up @@ -231,9 +246,9 @@ def suggested_commands(self):
:return: list of most accurate command suggestions
"""
if self.current_module:
return ['run', 'back', 'set ', 'show ', 'check', 'exit']
return ['run', 'back', 'set ', 'show ', 'check', 'exec', 'help', 'exit']
else:
return ['use ', 'exit']
return ['use ', 'exec', 'help', 'exit']

def command_back(self, *args, **kwargs):
self.current_module = None
Expand Down Expand Up @@ -349,6 +364,11 @@ def complete_show(self, text, *args, **kwargs):

@utils.module_required
def command_check(self, *args, **kwargs):
if self.current_module.check() == None:
return
if not self.current_module.target:
utils.print_error("No target set")
return
try:
result = self.current_module.check()
except:
Expand All @@ -361,5 +381,14 @@ def command_check(self, *args, **kwargs):
else:
utils.print_status("Target could not be verified")

def command_help(self, *args, **kwargs):
print(self.global_help)
if self.current_module:
print()
print(self.module_help)

def command_exec(self, *args, **kwargs):
call(' '.join(args))

def command_exit(self, *args, **kwargs):
raise KeyboardInterrupt

0 comments on commit 7b89464

Please sign in to comment.