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
a940aadd
Commit
a940aadd
authored
May 14, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handling check() method in scanners
parent
a665f517
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
15 deletions
+21
-15
interpreter.py
routersploit/interpreter.py
+4
-10
autopwn.py
routersploit/modules/scanners/autopwn.py
+2
-2
dlink_scan.py
routersploit/modules/scanners/dlink_scan.py
+1
-1
test_interpreter.py
routersploit/test/test_interpreter.py
+14
-2
No files found.
routersploit/interpreter.py
View file @
a940aadd
...
@@ -18,7 +18,6 @@ class BaseInterpreter(object):
...
@@ -18,7 +18,6 @@ class BaseInterpreter(object):
history_file
=
os
.
path
.
expanduser
(
"~/.history"
)
history_file
=
os
.
path
.
expanduser
(
"~/.history"
)
history_length
=
100
history_length
=
100
global_help
=
""
global_help
=
""
def
__init__
(
self
):
def
__init__
(
self
):
self
.
setup
()
self
.
setup
()
...
@@ -369,13 +368,8 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -369,13 +368,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
()
if
result
is
None
:
except
Exception
as
error
:
return
utils
.
print_error
(
error
)
if
not
self
.
current_module
.
target
:
utils
.
print_error
(
"No target set"
)
return
except
:
utils
.
print_error
(
traceback
.
format_exc
(
sys
.
exc_info
()))
else
:
else
:
if
result
is
True
:
if
result
is
True
:
utils
.
print_success
(
"Target is vulnerable"
)
utils
.
print_success
(
"Target is vulnerable"
)
...
@@ -387,10 +381,10 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -387,10 +381,10 @@ class RoutersploitInterpreter(BaseInterpreter):
def
command_help
(
self
,
*
args
,
**
kwargs
):
def
command_help
(
self
,
*
args
,
**
kwargs
):
print
(
self
.
global_help
)
print
(
self
.
global_help
)
if
self
.
current_module
:
if
self
.
current_module
:
print
()
print
(
"
\n
"
,
self
.
module_help
)
print
(
self
.
module_help
)
def
command_exec
(
self
,
*
args
,
**
kwargs
):
def
command_exec
(
self
,
*
args
,
**
kwargs
):
print
(
' '
.
join
(
args
))
call
(
' '
.
join
(
args
))
call
(
' '
.
join
(
args
))
def
command_exit
(
self
,
*
args
,
**
kwargs
):
def
command_exit
(
self
,
*
args
,
**
kwargs
):
...
...
routersploit/modules/scanners/autopwn.py
View file @
a940aadd
...
@@ -69,6 +69,6 @@ class Exploit(exploits.Exploit):
...
@@ -69,6 +69,6 @@ class Exploit(exploits.Exploit):
print_info
(
" - {}"
.
format
(
v
))
print_info
(
" - {}"
.
format
(
v
))
else
:
else
:
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 @
a940aadd
...
@@ -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_interpreter.py
View file @
a940aadd
...
@@ -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
(
self
,
print_status
):
def
test_command_check_target_could_not_be_verified
_1
(
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,9 +102,21 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
...
@@ -102,9 +102,21 @@ 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_
not_supported_by_module
(
self
,
print_status
):
def
test_command_check_
target_could_not_be_verified_2
(
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
(
'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'
)
...
...
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