Commit 7b89464f by Max Zinkus

Closes #85 and #30, add exec feature, edit check

Add help menus and help command
Add exec feature to be kinda msfconsole-y
Edit check behavior to be a little clearer/more logical
parent c420a95f
......@@ -3,6 +3,7 @@ import os
import sys
import traceback
import atexit
from subprocess import call
from routersploit.exceptions import RoutersploitException
from routersploit import utils
......@@ -16,6 +17,8 @@ else:
class BaseInterpreter(object):
history_file = os.path.expanduser("~/.history")
history_length = 100
global_help = ""
def __init__(self):
self.setup()
......@@ -146,6 +149,18 @@ class BaseInterpreter(object):
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__()
......@@ -231,9 +246,9 @@ class RoutersploitInterpreter(BaseInterpreter):
: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
......@@ -349,6 +364,11 @@ class RoutersploitInterpreter(BaseInterpreter):
@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:
......@@ -361,5 +381,14 @@ class RoutersploitInterpreter(BaseInterpreter):
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
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