Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20a6656

Browse files
committed
Minor refactoring
1 parent 60ebb97 commit 20a6656

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

lib/core/common.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
from lib.core.convert import unicodeencode
5656
from lib.core.convert import urldecode
5757
from lib.core.convert import urlencode
58+
from lib.core.decorators import cachedmethod
5859
from lib.core.enums import CHARSET_TYPE
5960
from lib.core.enums import DBMS
6061
from lib.core.enums import EXPECTED
@@ -492,15 +493,6 @@ def isVersionGreaterOrEqualThan(version):
492493
def isOs(os):
493494
return Backend.getOs() is not None and Backend.getOs().lower() == os.lower()
494495

495-
# Reference: http://code.activestate.com/recipes/325205-cache-decorator-in-python-24/
496-
def cachedmethod(f, cache={}):
497-
def _(*args, **kwargs):
498-
key = (f, tuple(args), frozenset(kwargs.items()))
499-
if key not in cache:
500-
cache[key] = f(*args, **kwargs)
501-
return cache[key]
502-
return _
503-
504496
def paramToDict(place, parameters=None):
505497
"""
506498
Split the parameters into names and values, check if these parameters

lib/core/decorators.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Reference: http://code.activestate.com/recipes/325205-cache-decorator-in-python-24/
2+
def cachedmethod(f, cache={}):
3+
def _(*args, **kwargs):
4+
key = (f, tuple(args), frozenset(kwargs.items()))
5+
if key not in cache:
6+
cache[key] = f(*args, **kwargs)
7+
return cache[key]
8+
return _

plugins/generic/users.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ def getPasswordHashes(self):
294294
else:
295295
for user in kb.data.cachedUsersPasswords:
296296
kb.data.cachedUsersPasswords[user] = list(set(kb.data.cachedUsersPasswords[user]))
297-
298297

299298
message = "do you want to perform a dictionary-based attack "
300299
message += "against retrieved password hashes? [Y/n/q]"

0 commit comments

Comments
 (0)