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
7e8a7a99
Commit
7e8a7a99
authored
8 years ago
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sorting commands in command suggestions.
parent
6b40a74d
master
…
v3.4.4
v3.4.3
v3.4.2
v3.4.0
v3.3.0
v3.2.0
v3.1.0
v3.0.0
v2.2.1
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
16 deletions
+19
-16
exploits.py
routersploit/exploits.py
+0
-1
interpreter.py
routersploit/interpreter.py
+11
-7
test_completer.py
routersploit/test/test_completer.py
+3
-3
test_interpreter.py
routersploit/test/test_interpreter.py
+5
-5
No files found.
routersploit/exploits.py
View file @
7e8a7a99
...
...
@@ -121,4 +121,3 @@ class Exploit(object):
def
__str__
(
self
):
return
self
.
__module__
.
split
(
'.'
,
2
)
.
pop
()
.
replace
(
'.'
,
os
.
sep
)
This diff is collapsed.
Click to expand it.
routersploit/interpreter.py
View file @
7e8a7a99
...
...
@@ -175,6 +175,11 @@ 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
.
module_commands
=
[
'run'
,
'back'
,
'set '
,
'setg '
,
'check'
]
self
.
module_commands
.
extend
(
self
.
global_commands
)
self
.
module_commands
.
sort
()
self
.
modules
=
utils
.
index_modules
()
self
.
main_modules_dirs
=
[
module
for
module
in
os
.
listdir
(
utils
.
MODULES_DIR
)
if
not
module
.
startswith
(
"__"
)]
...
...
@@ -243,20 +248,19 @@ class RoutersploitInterpreter(BaseInterpreter):
matches
.
add
(
""
.
join
((
text
,
head
,
sep
)))
return
list
(
map
(
utils
.
humanize_path
,
matches
))
# humanize output, replace dots to forward slashes
def
suggested_commands
(
self
):
# TODO: sorted list, factor out generic commands
def
suggested_commands
(
self
):
""" Entry point for intelligent tab completion.
Based on state of interpreter this method will return intelligent suggestions.
:return: list of most accurate command suggestions
"""
if
self
.
current_module
:
module_commands
=
[
'run'
,
'back'
,
'set '
,
'setg '
,
'show '
,
'check'
,
'exec '
,
'help'
,
'exit'
]
if
GLOBAL_OPTS
.
keys
():
return
itertools
.
chain
(
module_commands
,
(
'unsetg '
,))
return
module_commands
if
self
.
current_module
and
GLOBAL_OPTS
:
return
sorted
(
itertools
.
chain
(
self
.
module_commands
,
(
'unsetg '
,)))
elif
self
.
current_module
:
return
self
.
module_commands
else
:
return
[
'use '
,
'exec'
,
'help'
,
'exit'
,
'show '
]
return
self
.
global_commands
def
command_back
(
self
,
*
args
,
**
kwargs
):
self
.
current_module
=
None
...
...
This diff is collapsed.
Click to expand it.
routersploit/test/test_completer.py
View file @
7e8a7a99
...
...
@@ -89,7 +89,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
self
.
set_module
()
self
.
rsf
.
send
(
"
\t\t
"
)
self
.
assertPrompt
(
'
back check exec exit help run set setg show
\r\n
'
,
'
exec exit help run set setg show use
\r\n
'
,
self
.
module_prompt
(
'FTP Bruteforce'
)
)
...
...
@@ -182,7 +182,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
self
.
set_module
()
self
.
rsf
.
send
(
"
\t\t
"
)
self
.
assertPrompt
(
"
check exec exit help run set setg show
\r\n
"
,
"
exec exit help run set setg show use
\r\n
"
,
self
.
module_prompt
(
'FTP Bruteforce'
),
)
...
...
@@ -194,7 +194,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
self
.
rsf
.
send
(
"setg target foo
\r\n
"
)
self
.
rsf
.
send
(
"
\t\t
"
)
self
.
assertPrompt
(
" show
\r\n
check exit run setg unsetg
\r\n
"
,
' use
\r\n
check exit run setg unsetg
\r\n
'
,
self
.
module_prompt
(
'FTP Bruteforce'
),
)
...
...
This diff is collapsed.
Click to expand it.
routersploit/test/test_interpreter.py
View file @
7e8a7a99
...
...
@@ -254,23 +254,23 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
self
.
assertEqual
(
self
.
module_prompt_default
(
'UnnamedModule'
),
self
.
interpreter
.
prompt
)
def
test_suggested_commands_with_loaded_module_and_no_global_value_set
(
self
):
self
.
assertEqual
(
self
.
assert
Items
Equal
(
list
(
self
.
interpreter
.
suggested_commands
()),
[
'run'
,
'back'
,
'set '
,
'setg '
,
'show '
,
'check'
,
'exec '
,
'help'
,
'exit'
]
# Extra space at the end because of following param
[
'
use '
,
'
run'
,
'back'
,
'set '
,
'setg '
,
'show '
,
'check'
,
'exec '
,
'help'
,
'exit'
]
# 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
(
self
.
assert
Items
Equal
(
list
(
self
.
interpreter
.
suggested_commands
()),
[
'run'
,
'back'
,
'set '
,
'setg '
,
'show '
,
'check'
,
'exec '
,
'help'
,
'exit'
,
'unsetg '
]
# Extra space at the end because of following param
[
'
use '
,
'
run'
,
'back'
,
'set '
,
'setg '
,
'show '
,
'check'
,
'exec '
,
'help'
,
'exit'
,
'unsetg '
]
# 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
[
'
use '
,
'exec'
,
'help'
,
'exit'
,
'show
'
]
[
'
exec '
,
'exit'
,
'help'
,
'show '
,
'use
'
]
)
@mock.patch
(
'importlib.import_module'
)
...
...
This diff is collapsed.
Click to expand it.
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