Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
routersploit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
czos-dpend
routersploit
Commits
9a01c014
Commit
9a01c014
authored
Jul 03, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introducing show sub-commands: all, exploits, scanners, creds
parent
66be5de2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
7 deletions
+23
-7
interpreter.py
routersploit/interpreter.py
+21
-5
test_completer.py
routersploit/test/test_completer.py
+1
-1
test_interpreter.py
routersploit/test/test_interpreter.py
+1
-1
No files found.
routersploit/interpreter.py
View file @
9a01c014
...
...
@@ -173,6 +173,7 @@ class RoutersploitInterpreter(BaseInterpreter):
self
.
raw_prompt_template
=
None
self
.
module_prompt_template
=
None
self
.
prompt_hostname
=
'rsf'
self
.
show_sub_commands
=
(
'info'
,
'options'
,
'devices'
,
'all'
,
'creds'
,
'exploits'
,
'scanners'
)
self
.
modules
=
utils
.
index_modules
()
self
.
main_modules_dirs
=
[
module
for
module
in
os
.
listdir
(
utils
.
MODULES_DIR
)
if
not
module
.
startswith
(
"__"
)]
...
...
@@ -392,23 +393,38 @@ class RoutersploitInterpreter(BaseInterpreter):
except
KeyError
:
print
(
"
\n
Target devices are not defined"
)
def
__show_modules
(
self
,
root
):
# TODO: cover with tests
for
module
in
[
module
for
module
in
self
.
modules
if
module
.
startswith
(
root
)]:
print
(
module
.
replace
(
'.'
,
os
.
sep
))
def
_show_all
(
self
,
*
args
,
**
kwargs
):
# TODO: cover with tests
for
module
in
self
.
modules
:
print
(
module
)
def
_show_scanners
(
self
,
*
args
,
**
kwargs
):
# TODO: cover with tests
self
.
__show_modules
(
'scanners'
)
def
_show_exploits
(
self
,
*
args
,
**
kwargs
):
# TODO: cover with tests
self
.
__show_modules
(
'exploits'
)
def
_show_creds
(
self
,
*
args
,
**
kwargs
):
# TODO: cover with tests
self
.
__show_modules
(
'creds'
)
def
command_show
(
self
,
*
args
,
**
kwargs
):
sub_commands
=
(
'info'
,
'options'
,
'devices'
)
sub_command
=
args
[
0
]
try
:
getattr
(
self
,
"_show_{}"
.
format
(
sub_command
))(
*
args
,
**
kwargs
)
except
AttributeError
:
utils
.
print_error
(
"Unknown 'show' sub-command '{}'. "
"What do you want to show?
\n
"
"Possible choices are: {}"
.
format
(
sub_command
,
sub_commands
))
"Possible choices are: {}"
.
format
(
sub_command
,
s
elf
.
show_s
ub_commands
))
@utils.stop_after
(
2
)
def
complete_show
(
self
,
text
,
*
args
,
**
kwargs
):
sub_commands
=
[
'info'
,
'options'
,
'devices'
]
if
text
:
return
filter
(
lambda
command
:
command
.
startswith
(
text
),
sub_commands
)
return
[
command
for
command
in
self
.
show_sub_commands
if
command
.
startswith
(
text
)]
else
:
return
sub_commands
return
s
elf
.
show_s
ub_commands
@utils.module_required
def
command_check
(
self
,
*
args
,
**
kwargs
):
...
...
routersploit/test/test_completer.py
View file @
9a01c014
...
...
@@ -235,7 +235,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
self
.
set_module
()
self
.
rsf
.
send
(
"show
\t\t
"
)
self
.
assertPrompt
(
'
info options
\r\n
'
,
'
all creds devices exploits info options scanners
\r\n
'
,
self
.
module_prompt
(
'FTP Bruteforce'
)
)
...
...
routersploit/test/test_interpreter.py
View file @
9a01c014
...
...
@@ -477,7 +477,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
self
.
interpreter
.
command_show
(
'unknown_sub_command'
)
mock_print_error
.
assert_called_once_with
(
"Unknown 'show' sub-command 'unknown_sub_command'. "
"What do you want to show?
\n
"
"Possible choices are:
('info', 'options', 'devices')"
)
"Possible choices are:
{}"
.
format
(
self
.
interpreter
.
show_sub_commands
)
)
def
test_if_command_run_has_module_required_decorator
(
self
):
self
.
assertIsDecorated
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment