Commit b1e77def by fwkz

Adding widgets functionality.

parent 9751ee5a
......@@ -16,4 +16,5 @@ from routersploit.utils import (
from routersploit import exploits
from routersploit import wordlists
from routersploit import widgets
......@@ -3,14 +3,19 @@ from itertools import chain
import threading
import time
from routersploit.utils import print_status
from routersploit.utils import print_status, NonStringIterable
class Option(object):
""" Exploit attribute that is set by the end user. """
def __init__(self, default, description=""):
self.default = default
def __init__(self, default, description="", widgets=()):
if isinstance(widgets, NonStringIterable):
self.widgets = widgets
else:
self.widgets = (widgets,)
self.default = self._apply_widgets(default)
self.description = description
self.data = WeakKeyDictionary()
......@@ -18,7 +23,12 @@ class Option(object):
return self.data.get(instance, self.default)
def __set__(self, instance, value):
self.data[instance] = value
self.data[instance] = self._apply_widgets(value)
def _apply_widgets(self, value):
for widget in self.widgets:
value = widget(value)
return value
class ExploitOptionsAggregator(type):
......
def url(address):
"""Sanitize url.
Converts address to valid HTTP url.
"""
if address.startswith("http://") or address.startswith("https://"):
return address
else:
return "http://{}".format(address)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment