diff --git a/lib/core/common.py b/lib/core/common.py index e970005c5..ea1574039 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -55,6 +55,7 @@ from lib.core.convert import htmlunescape from lib.core.convert import unicodeencode from lib.core.convert import urldecode from lib.core.convert import urlencode +from lib.core.decorators import cachedmethod from lib.core.enums import CHARSET_TYPE from lib.core.enums import DBMS from lib.core.enums import EXPECTED @@ -492,15 +493,6 @@ class Backend: def isOs(os): return Backend.getOs() is not None and Backend.getOs().lower() == os.lower() -# Reference: http://code.activestate.com/recipes/325205-cache-decorator-in-python-24/ -def cachedmethod(f, cache={}): - def _(*args, **kwargs): - key = (f, tuple(args), frozenset(kwargs.items())) - if key not in cache: - cache[key] = f(*args, **kwargs) - return cache[key] - return _ - def paramToDict(place, parameters=None): """ Split the parameters into names and values, check if these parameters diff --git a/lib/core/decorators.py b/lib/core/decorators.py new file mode 100644 index 000000000..8dc893a08 --- /dev/null +++ b/lib/core/decorators.py @@ -0,0 +1,8 @@ +# Reference: http://code.activestate.com/recipes/325205-cache-decorator-in-python-24/ +def cachedmethod(f, cache={}): + def _(*args, **kwargs): + key = (f, tuple(args), frozenset(kwargs.items())) + if key not in cache: + cache[key] = f(*args, **kwargs) + return cache[key] + return _ diff --git a/plugins/generic/users.py b/plugins/generic/users.py index b6759baf3..b201355ec 100644 --- a/plugins/generic/users.py +++ b/plugins/generic/users.py @@ -294,7 +294,6 @@ class Users: else: for user in kb.data.cachedUsersPasswords: kb.data.cachedUsersPasswords[user] = list(set(kb.data.cachedUsersPasswords[user])) - message = "do you want to perform a dictionary-based attack " message += "against retrieved password hashes? [Y/n/q]"