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
4ef9e2f5
Commit
4ef9e2f5
authored
Jun 25, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introducing setg command
parent
e3a9952d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
exploits.py
routersploit/exploits.py
+6
-1
interpreter.py
routersploit/interpreter.py
+15
-0
No files found.
routersploit/exploits.py
View file @
4ef9e2f5
...
@@ -6,10 +6,14 @@ import time
...
@@ -6,10 +6,14 @@ import time
from
routersploit.utils
import
print_status
,
NonStringIterable
from
routersploit.utils
import
print_status
,
NonStringIterable
GLOBAL_OPTS
=
{}
class
Option
(
object
):
class
Option
(
object
):
""" Exploit attribute that is set by the end user. """
""" Exploit attribute that is set by the end user. """
def
__init__
(
self
,
default
,
description
=
""
,
validators
=
()):
def
__init__
(
self
,
default
,
description
=
""
,
validators
=
()):
self
.
label
=
None
if
isinstance
(
validators
,
NonStringIterable
):
if
isinstance
(
validators
,
NonStringIterable
):
self
.
validators
=
validators
self
.
validators
=
validators
else
:
else
:
...
@@ -20,7 +24,7 @@ class Option(object):
...
@@ -20,7 +24,7 @@ class Option(object):
self
.
data
=
WeakKeyDictionary
()
self
.
data
=
WeakKeyDictionary
()
def
__get__
(
self
,
instance
,
owner
):
def
__get__
(
self
,
instance
,
owner
):
return
self
.
data
.
get
(
instance
,
self
.
default
)
return
self
.
data
.
get
(
instance
,
GLOBAL_OPTS
.
get
(
self
.
label
,
self
.
default
)
)
def
__set__
(
self
,
instance
,
value
):
def
__set__
(
self
,
instance
,
value
):
self
.
data
[
instance
]
=
self
.
_apply_widgets
(
value
)
self
.
data
[
instance
]
=
self
.
_apply_widgets
(
value
)
...
@@ -47,6 +51,7 @@ class ExploitOptionsAggregator(type):
...
@@ -47,6 +51,7 @@ class ExploitOptionsAggregator(type):
for
key
,
value
in
attrs
.
iteritems
():
for
key
,
value
in
attrs
.
iteritems
():
if
isinstance
(
value
,
Option
):
if
isinstance
(
value
,
Option
):
value
.
label
=
key
attrs
[
'exploit_attributes'
]
.
update
({
key
:
value
.
description
})
attrs
[
'exploit_attributes'
]
.
update
({
key
:
value
.
description
})
elif
key
==
"__info__"
:
elif
key
==
"__info__"
:
attrs
[
"_{}{}"
.
format
(
name
,
key
)]
=
value
attrs
[
"_{}{}"
.
format
(
name
,
key
)]
=
value
...
...
routersploit/interpreter.py
View file @
4ef9e2f5
...
@@ -5,6 +5,7 @@ import traceback
...
@@ -5,6 +5,7 @@ import traceback
import
atexit
import
atexit
from
routersploit.exceptions
import
RoutersploitException
from
routersploit.exceptions
import
RoutersploitException
from
routersploit.exploits
import
GLOBAL_OPTS
from
routersploit
import
utils
from
routersploit
import
utils
if
sys
.
platform
==
"darwin"
:
if
sys
.
platform
==
"darwin"
:
...
@@ -301,6 +302,20 @@ class RoutersploitInterpreter(BaseInterpreter):
...
@@ -301,6 +302,20 @@ class RoutersploitInterpreter(BaseInterpreter):
return
self
.
current_module
.
options
return
self
.
current_module
.
options
@utils.module_required
@utils.module_required
def
command_setg
(
self
,
*
args
,
**
kwargs
):
key
,
_
,
value
=
args
[
0
]
.
partition
(
' '
)
if
key
in
self
.
current_module
.
options
:
GLOBAL_OPTS
[
key
]
=
value
utils
.
print_success
({
key
:
value
})
else
:
utils
.
print_error
(
"You can't set option '{}'.
\n
"
"Available options: {}"
.
format
(
key
,
self
.
current_module
.
options
))
@utils.stop_after
(
2
)
def
complete_setg
(
self
,
text
,
*
args
,
**
kwargs
):
return
self
.
complete_set
(
text
,
*
args
,
**
kwargs
)
@utils.module_required
def
get_opts
(
self
,
*
args
):
def
get_opts
(
self
,
*
args
):
""" Generator returning module's Option attributes (option_name, option_value, option_description)
""" Generator returning module's Option attributes (option_name, option_value, option_description)
...
...
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