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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
14 deletions
+20
-14
interpreter.py
routersploit/interpreter.py
+4
-10
autopwn.py
routersploit/modules/scanners/autopwn.py
+1
-1
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
...
...
@@ -19,7 +19,6 @@ class BaseInterpreter(object):
history_length
=
100
global_help
=
""
def
__init__
(
self
):
self
.
setup
()
self
.
banner
=
""
...
...
@@ -369,13 +368,8 @@ class RoutersploitInterpreter(BaseInterpreter):
def
command_check
(
self
,
*
args
,
**
kwargs
):
try
:
result
=
self
.
current_module
.
check
()
if
result
is
None
:
return
if
not
self
.
current_module
.
target
:
utils
.
print_error
(
"No target set"
)
return
except
:
utils
.
print_error
(
traceback
.
format_exc
(
sys
.
exc_info
()))
except
Exception
as
error
:
utils
.
print_error
(
error
)
else
:
if
result
is
True
:
utils
.
print_success
(
"Target is vulnerable"
)
...
...
@@ -387,10 +381,10 @@ class RoutersploitInterpreter(BaseInterpreter):
def
command_help
(
self
,
*
args
,
**
kwargs
):
print
(
self
.
global_help
)
if
self
.
current_module
:
print
()
print
(
self
.
module_help
)
print
(
"
\n
"
,
self
.
module_help
)
def
command_exec
(
self
,
*
args
,
**
kwargs
):
print
(
' '
.
join
(
args
))
call
(
' '
.
join
(
args
))
def
command_exit
(
self
,
*
args
,
**
kwargs
):
...
...
routersploit/modules/scanners/autopwn.py
View file @
a940aadd
...
...
@@ -71,4 +71,4 @@ class Exploit(exploits.Exploit):
print_error
(
"Device is not vulnerable to any exploits!
\n
"
)
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):
print
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):
print_error
.
assert_called_once_with
(
'Target is not vulnerable'
)
@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
:
mock_check
.
return_value
=
"something"
self
.
interpreter
.
command_check
()
...
...
@@ -102,9 +102,21 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
print_status
.
assert_called_once_with
(
'Target could not be verified'
)
@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
:
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
(
'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