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
a665f517
Commit
a665f517
authored
May 14, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/DeltaHeavy/routersploit
into DeltaHeavy-master
parents
bd731f2d
1c0648e5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
11 deletions
+43
-11
.gitignore
.gitignore
+3
-0
interpreter.py
routersploit/interpreter.py
+34
-2
test_completer.py
routersploit/test/test_completer.py
+2
-2
test_interpreter.py
routersploit/test/test_interpreter.py
+4
-7
No files found.
.gitignore
View file @
a665f517
...
@@ -64,3 +64,6 @@ target/
...
@@ -64,3 +64,6 @@ target/
# VS Code
# VS Code
.vscode
.vscode
# virtualenv
venv/
routersploit/interpreter.py
View file @
a665f517
...
@@ -3,6 +3,7 @@ import os
...
@@ -3,6 +3,7 @@ import os
import
sys
import
sys
import
traceback
import
traceback
import
atexit
import
atexit
from
subprocess
import
call
from
routersploit.exceptions
import
RoutersploitException
from
routersploit.exceptions
import
RoutersploitException
from
routersploit
import
utils
from
routersploit
import
utils
...
@@ -16,6 +17,8 @@ else:
...
@@ -16,6 +17,8 @@ else:
class
BaseInterpreter
(
object
):
class
BaseInterpreter
(
object
):
history_file
=
os
.
path
.
expanduser
(
"~/.history"
)
history_file
=
os
.
path
.
expanduser
(
"~/.history"
)
history_length
=
100
history_length
=
100
global_help
=
""
def
__init__
(
self
):
def
__init__
(
self
):
self
.
setup
()
self
.
setup
()
...
@@ -146,6 +149,18 @@ class BaseInterpreter(object):
...
@@ -146,6 +149,18 @@ class BaseInterpreter(object):
class
RoutersploitInterpreter
(
BaseInterpreter
):
class
RoutersploitInterpreter
(
BaseInterpreter
):
history_file
=
os
.
path
.
expanduser
(
"~/.rsf_history"
)
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
):
def
__init__
(
self
):
super
(
RoutersploitInterpreter
,
self
)
.
__init__
()
super
(
RoutersploitInterpreter
,
self
)
.
__init__
()
...
@@ -231,9 +246,9 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -231,9 +246,9 @@ class RoutersploitInterpreter(BaseInterpreter):
:return: list of most accurate command suggestions
:return: list of most accurate command suggestions
"""
"""
if
self
.
current_module
:
if
self
.
current_module
:
return
[
'run'
,
'back'
,
'set '
,
'show '
,
'check'
,
'exit'
]
return
[
'run'
,
'back'
,
'set '
,
'show '
,
'check'
,
'ex
ec'
,
'help'
,
'ex
it'
]
else
:
else
:
return
[
'use '
,
'exit'
]
return
[
'use '
,
'ex
ec'
,
'help'
,
'ex
it'
]
def
command_back
(
self
,
*
args
,
**
kwargs
):
def
command_back
(
self
,
*
args
,
**
kwargs
):
self
.
current_module
=
None
self
.
current_module
=
None
...
@@ -259,6 +274,9 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -259,6 +274,9 @@ class RoutersploitInterpreter(BaseInterpreter):
utils
.
print_status
(
"Running module..."
)
utils
.
print_status
(
"Running module..."
)
try
:
try
:
self
.
current_module
.
run
()
self
.
current_module
.
run
()
except
KeyboardInterrupt
:
print
()
utils
.
print_error
(
"Operation cancelled by user"
)
except
:
except
:
utils
.
print_error
(
traceback
.
format_exc
(
sys
.
exc_info
()))
utils
.
print_error
(
traceback
.
format_exc
(
sys
.
exc_info
()))
...
@@ -351,6 +369,11 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -351,6 +369,11 @@ class RoutersploitInterpreter(BaseInterpreter):
def
command_check
(
self
,
*
args
,
**
kwargs
):
def
command_check
(
self
,
*
args
,
**
kwargs
):
try
:
try
:
result
=
self
.
current_module
.
check
()
result
=
self
.
current_module
.
check
()
if
result
is
None
:
return
if
not
self
.
current_module
.
target
:
utils
.
print_error
(
"No target set"
)
return
except
:
except
:
utils
.
print_error
(
traceback
.
format_exc
(
sys
.
exc_info
()))
utils
.
print_error
(
traceback
.
format_exc
(
sys
.
exc_info
()))
else
:
else
:
...
@@ -361,5 +384,14 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -361,5 +384,14 @@ class RoutersploitInterpreter(BaseInterpreter):
else
:
else
:
utils
.
print_status
(
"Target could not be verified"
)
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
):
def
command_exit
(
self
,
*
args
,
**
kwargs
):
raise
KeyboardInterrupt
raise
KeyboardInterrupt
routersploit/test/test_completer.py
View file @
a665f517
...
@@ -32,7 +32,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
...
@@ -32,7 +32,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
def
test_raw_commands_no_module
(
self
):
def
test_raw_commands_no_module
(
self
):
self
.
rsf
.
send
(
"
\t\t
"
)
self
.
rsf
.
send
(
"
\t\t
"
)
self
.
assertPrompt
(
'ex
it
use
\r\n
'
,
self
.
raw_prompt
)
self
.
assertPrompt
(
'ex
ec exit help
use
\r\n
'
,
self
.
raw_prompt
)
def
test_complete_use_raw
(
self
):
def
test_complete_use_raw
(
self
):
self
.
rsf
.
send
(
"u
\t\t
"
)
self
.
rsf
.
send
(
"u
\t\t
"
)
...
@@ -89,7 +89,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
...
@@ -89,7 +89,7 @@ class RoutersploitCompleterTest(RoutersploitTestCase):
self
.
set_module
()
self
.
set_module
()
self
.
rsf
.
send
(
"
\t\t
"
)
self
.
rsf
.
send
(
"
\t\t
"
)
self
.
assertPrompt
(
self
.
assertPrompt
(
'back check ex
it
run set show
\r\n
'
,
'back check ex
ec exit help
run set show
\r\n
'
,
self
.
module_prompt
(
'FTP Bruteforce'
)
self
.
module_prompt
(
'FTP Bruteforce'
)
)
)
...
...
routersploit/test/test_interpreter.py
View file @
a665f517
...
@@ -94,7 +94,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
...
@@ -94,7 +94,7 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
print_error
.
assert_called_once_with
(
'Target is not vulnerable'
)
print_error
.
assert_called_once_with
(
'Target is not vulnerable'
)
@mock.patch
(
'routersploit.utils.print_status'
)
@mock.patch
(
'routersploit.utils.print_status'
)
def
test_command_check_target_could_not_be_verified
_1
(
self
,
print_status
):
def
test_command_check_target_could_not_be_verified
(
self
,
print_status
):
with
mock
.
patch
.
object
(
self
.
interpreter
.
current_module
,
'check'
)
as
mock_check
:
with
mock
.
patch
.
object
(
self
.
interpreter
.
current_module
,
'check'
)
as
mock_check
:
mock_check
.
return_value
=
"something"
mock_check
.
return_value
=
"something"
self
.
interpreter
.
command_check
()
self
.
interpreter
.
command_check
()
...
@@ -102,12 +102,9 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
...
@@ -102,12 +102,9 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
print_status
.
assert_called_once_with
(
'Target could not be verified'
)
print_status
.
assert_called_once_with
(
'Target could not be verified'
)
@mock.patch
(
'routersploit.utils.print_status'
)
@mock.patch
(
'routersploit.utils.print_status'
)
def
test_command_check_
target_could_not_be_verified_2
(
self
,
print_status
):
def
test_command_check_
not_supported_by_module
(
self
,
print_status
):
with
mock
.
patch
.
object
(
self
.
interpreter
.
current_module
,
'check'
)
as
mock_check
:
with
mock
.
patch
.
object
(
self
.
interpreter
.
current_module
,
'check'
)
as
mock_check
:
mock_check
.
return_value
=
None
mock_check
.
return_value
=
None
self
.
interpreter
.
command_check
()
mock_check
.
assert_called_once_with
()
print_status
.
assert_called_once_with
(
'Target could not be verified'
)
@mock.patch
(
'sys.exc_info'
)
@mock.patch
(
'sys.exc_info'
)
@mock.patch
(
'traceback.format_exc'
)
@mock.patch
(
'traceback.format_exc'
)
...
@@ -179,14 +176,14 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
...
@@ -179,14 +176,14 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
def
test_suggested_commands_with_loaded_module
(
self
):
def
test_suggested_commands_with_loaded_module
(
self
):
self
.
assertEqual
(
self
.
assertEqual
(
self
.
interpreter
.
suggested_commands
(),
self
.
interpreter
.
suggested_commands
(),
[
'run'
,
'back'
,
'set '
,
'show '
,
'check'
,
'exit'
]
# Extra space at the end because of following param
[
'run'
,
'back'
,
'set '
,
'show '
,
'check'
,
'ex
ec'
,
'help'
,
'ex
it'
]
# 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
[
'use '
,
'exit'
]
[
'use '
,
'ex
ec'
,
'help'
,
'ex
it'
]
)
)
@mock.patch
(
'importlib.import_module'
)
@mock.patch
(
'importlib.import_module'
)
...
...
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