Skip to content

Commit

Permalink
BugFix
Browse files Browse the repository at this point in the history
  • Loading branch information
helviojunior committed Jul 30, 2024
1 parent 8716ac0 commit a4db62a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion knowsmore/cmd/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def run(self):
continue

password = Password(
ntlm_hash=c1[0].lower(),
ntlm_hash=None, # c1[0].lower(), # not use this
clear_text=c1[1]
)

Expand Down
2 changes: 1 addition & 1 deletion knowsmore/cmd/memberof.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def load_from_arguments(self, args: Namespace) -> bool:
def run(self):

sql = (
'select row_number() OVER (ORDER BY g2.name, c.name) AS __line, g2.name group_name, '
'select row_number() OVER (ORDER BY g2.name, c.enabled DESC, c.name) AS __line, g2.name group_name, '
'c.name, p.password, be.edge_type as "right", '
'case when c.enabled == 1 then "Yes" ELSE "No" end user_enabled '
'from credentials as c '
Expand Down
5 changes: 3 additions & 2 deletions knowsmore/cmd/precomputed.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ def run(self):
)
except Exception as e:
Tools.clear_line()
Logger.pl('{!} {R}error: could not parse/import line {O}%d{R} => {G}%s {W}: %s\r\n' % (count, line, str(e)))
raise e
if Configuration.verbose >= 3:
Logger.pl('{!} {R}error: could not parse/import line {O}%d{R} => {G}%s {W}: %s\r\n' % (count, line, str(e)))
#raise e

#read next line
finally:
Expand Down
14 changes: 10 additions & 4 deletions knowsmore/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

LEETS = {"a": "aA@49\u00e1\u00c1\u00e0\u00c0\u00c2\u00c3\u00c4\u00c5\u00e2\u00e3\u00e4\u00e5", "b": "bB8", "c": "cC\u00e7\u00c7", "d": "dD", "e": "eE32\u00c8\u00c9\u00ca\u00cb\u00e8\u00e9\u00ea\u00eb", "f": "fF", "g": "gG96", "h": "hH#", "i": "iI!1\u00cc\u00cd\u00ce\u00cf\u00ec\u00ed\u00ee\u00ef", "j": "jJ", "k": "kK", "l": "lL!1", "m": "mM", "n": "nN\u00f1\u00d1", "o": "oO04\u00d2\u00d3\u00d4\u00d5\u00d6\u00f2\u00f3\u00f4\u00f5\u00f6", "p": "pP", "q": "qQ", "r": "rR", "s": "sS5$", "t": "tT7+", "u": "uU\u00d9\u00da\u00db\u00dc\u00f9\u00fa\u00fb\u00fc", "v": "vV", "w": "wW", "x": "xX", "y": "yY\u00dd\u00fd", "z": "zZ2", "0": "0", "1": "1", "2": "2", "3": "3", "4": "4", "5": "5", "6": "6", "7": "7", "8": "8", "9": "9"}


class Password(object):
weak_bits = 30
ntlm_hash = ''
Expand All @@ -23,7 +24,7 @@ class Password(object):

def __init__(self, ntlm_hash: str, clear_text: str):

if ntlm_hash == '' and clear_text is not None and clear_text != '':
if (ntlm_hash is None or ntlm_hash == '') and clear_text is not None and clear_text != '':
import hashlib, binascii
hash = hashlib.new('md4', clear_text.encode('utf-16le')).digest()
ntlm_hash = binascii.hexlify(hash)
Expand Down Expand Up @@ -188,9 +189,14 @@ def calc_ratio(self, name: str, score_cutoff: float = 0.0) -> int:
if name not in Password.leets_cache.keys():
Password.leets_cache[name] = [l1 for l1 in self.get_leets(name)]

self.similarity = sorted(
[round(ratio(l1, str_pass, score_cutoff=score_cutoff) * float(100)) for l1 in Password.leets_cache[name]]
)[-1]
l1 = sorted(
[
round(ratio(l1, str_pass, score_cutoff=score_cutoff) * float(100))
for l1 in Password.leets_cache[name]
]
)
if l1 is not None and len(l1) > 1:
self.similarity = l1[-1]

if self.similarity < int(score_cutoff * float(100)):
self.similarity = 0
Expand Down

0 comments on commit a4db62a

Please sign in to comment.