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
357c377c
Commit
357c377c
authored
May 14, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DeltaHeavy-master'
parents
bd731f2d
17fb3dbb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
10 deletions
+51
-10
.gitignore
.gitignore
+3
-0
interpreter.py
routersploit/interpreter.py
+28
-4
autopwn.py
routersploit/modules/scanners/autopwn.py
+1
-1
dlink_scan.py
routersploit/modules/scanners/dlink_scan.py
+1
-1
test_completer.py
routersploit/test/test_completer.py
+2
-2
test_interpreter.py
routersploit/test/test_interpreter.py
+16
-2
No files found.
.gitignore
View file @
357c377c
...
@@ -64,3 +64,6 @@ target/
...
@@ -64,3 +64,6 @@ target/
# VS Code
# VS Code
.vscode
.vscode
# virtualenv
venv/
routersploit/interpreter.py
View file @
357c377c
...
@@ -16,6 +16,7 @@ else:
...
@@ -16,6 +16,7 @@ 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 +147,18 @@ class BaseInterpreter(object):
...
@@ -146,6 +147,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 +244,9 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -231,9 +244,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 +272,9 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -259,6 +272,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,8 +367,8 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -351,8 +367,8 @@ 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
()
except
:
except
Exception
as
error
:
utils
.
print_error
(
traceback
.
format_exc
(
sys
.
exc_info
())
)
utils
.
print_error
(
error
)
else
:
else
:
if
result
is
True
:
if
result
is
True
:
utils
.
print_success
(
"Target is vulnerable"
)
utils
.
print_success
(
"Target is vulnerable"
)
...
@@ -361,5 +377,13 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -361,5 +377,13 @@ 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
(
"
\n
"
,
self
.
module_help
)
def
command_exec
(
self
,
*
args
,
**
kwargs
):
os
.
system
(
args
[
0
])
def
command_exit
(
self
,
*
args
,
**
kwargs
):
def
command_exit
(
self
,
*
args
,
**
kwargs
):
raise
KeyboardInterrupt
raise
KeyboardInterrupt
routersploit/modules/scanners/autopwn.py
View file @
357c377c
...
@@ -71,4 +71,4 @@ class Exploit(exploits.Exploit):
...
@@ -71,4 +71,4 @@ class Exploit(exploits.Exploit):
print_error
(
"Device is not vulnerable to any exploits!
\n
"
)
print_error
(
"Device is not vulnerable to any exploits!
\n
"
)
def
check
(
self
):
def
check
(
self
):
print_e
rror
(
"Check method is not available"
)
raise
NotImplementedE
rror
(
"Check method is not available"
)
routersploit/modules/scanners/dlink_scan.py
View file @
357c377c
...
@@ -68,4 +68,4 @@ class Exploit(exploits.Exploit):
...
@@ -68,4 +68,4 @@ class Exploit(exploits.Exploit):
print
print
def
check
(
self
):
def
check
(
self
):
print_e
rror
(
"Check method is not available"
)
raise
NotImplementedE
rror
(
"Check method is not available"
)
routersploit/test/test_completer.py
View file @
357c377c
...
@@ -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 @
357c377c
...
@@ -109,6 +109,15 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
...
@@ -109,6 +109,15 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
mock_check
.
assert_called_once_with
()
mock_check
.
assert_called_once_with
()
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_error'
)
def
test_command_check_not_supported_by_module
(
self
,
print_error
):
with
mock
.
patch
.
object
(
self
.
interpreter
.
current_module
,
'check'
)
as
mock_check
:
exception
=
NotImplementedError
(
"Not available"
)
mock_check
.
side_effect
=
exception
self
.
interpreter
.
command_check
()
mock_check
.
assert_called_once_with
()
print_error
.
assert_called_once_with
(
exception
)
@mock.patch
(
'sys.exc_info'
)
@mock.patch
(
'sys.exc_info'
)
@mock.patch
(
'traceback.format_exc'
)
@mock.patch
(
'traceback.format_exc'
)
@mock.patch
(
'routersploit.utils.print_error'
)
@mock.patch
(
'routersploit.utils.print_error'
)
...
@@ -179,14 +188,14 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
...
@@ -179,14 +188,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'
)
...
@@ -425,5 +434,10 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
...
@@ -425,5 +434,10 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
with
self
.
assertRaises
(
KeyboardInterrupt
):
with
self
.
assertRaises
(
KeyboardInterrupt
):
self
.
interpreter
.
command_exit
()
self
.
interpreter
.
command_exit
()
@mock.patch
(
'os.system'
)
def
test_command_exec
(
self
,
mock_system
):
self
.
interpreter
.
command_exec
(
"foo -bar"
)
mock_system
.
assert_called_once_with
(
"foo -bar"
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
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