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

Skip to content

Commit 3cae766

Browse files
committed
code refactoring regarding dictionary attack
1 parent ba4ea32 commit 3cae766

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

lib/core/common.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from ConfigParser import RawConfigParser
2727
from StringIO import StringIO
2828
from difflib import SequenceMatcher
29+
from inspect import getmembers
2930
from subprocess import PIPE
3031
from subprocess import Popen as execute
3132
from tempfile import NamedTemporaryFile
@@ -1604,3 +1605,12 @@ def logHTTPTraffic(requestLogMsg, responseLogMsg):
16041605
dataToTrafficFile("\n%s\n\n" % (76 * '#'))
16051606

16061607
kb.locks.reqLock.release()
1608+
1609+
def getPublicTypeMembers(type_):
1610+
retVal = []
1611+
1612+
for name, value in getmembers(type_):
1613+
if not name.startswith('__'):
1614+
retVal.append((name, value))
1615+
1616+
return retVal

lib/core/enums.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,3 @@ class HASH:
5353
ORACLE_OLD = r'(?i)\A[0-9a-f]{16}\Z'
5454
MD5_GENERIC = r'(?i)\A[0-9a-f]{32}\Z'
5555
SHA1_GENERIC = r'(?i)\A[0-9a-f]{40}\Z'
56-
__all__ = (MYSQL, MYSQL_OLD, POSTGRES, MSSQL, MSSQL_OLD, ORACLE, ORACLE_OLD, MD5_GENERIC, SHA1_GENERIC)

lib/utils/hash.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212

1313
from hashlib import md5
1414
from hashlib import sha1
15-
from zipfile import ZipFile
15+
from zipfile import ZipFile
1616

1717
from extra.pydes.pyDes import des
1818
from extra.pydes.pyDes import CBC
1919
from lib.core.common import conf
2020
from lib.core.common import dataToStdout
2121
from lib.core.common import getFileItems
22+
from lib.core.common import getPublicTypeMembers
2223
from lib.core.common import paths
2324
from lib.core.common import readInput
2425
from lib.core.convert import hexdecode
@@ -190,7 +191,7 @@ def dictionaryAttack():
190191

191192
hash_ = hash_.split()[0]
192193

193-
for regex in HASH.__all__:
194+
for _, regex in getPublicTypeMembers(HASH):
194195
if re.match(regex, hash_):
195196
rehash = regex
196197
break

0 commit comments

Comments
 (0)