Skip to content

Commit

Permalink
Supporte multiple company names
Browse files Browse the repository at this point in the history
  • Loading branch information
helviojunior committed Jan 17, 2023
1 parent 3c23685 commit dc522f1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion knowsmore/__meta__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.1.26'
__version__ = '0.1.27'
__title__ = "knowsmore"
__description__ = "KnowsMore is a swiss army knife tool for pentesting Microsoft Active Directory (NTLM Hashes, BloodHound, NTDS and DCSync)."
__url__ = "https://github.com/helviojunior/knowsmore"
Expand Down
20 changes: 13 additions & 7 deletions knowsmore/cmd/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ def run(self):

pdata = {}

if Configuration.company != '':
pdata['company_similarity'] = self.password.calc_ratio(Configuration.company)
if len(Configuration.company) > 0:
pdata['company_similarity'] = sorted(
[self.password.calc_ratio(n1) for n1 in Configuration.company]
)[-1]

self.db.insert_password_manually(self.password, **pdata)
Logger.pl('{+} {C}Password inserted/updated{W}')
Expand Down Expand Up @@ -328,8 +330,10 @@ def run(self):
clear_text=pre_computed[0]['password']
)

if Configuration.company != '':
pdata['company_similarity'] = password.calc_ratio(Configuration.company)
if len(Configuration.company) > 0:
pdata['company_similarity'] = sorted(
[password.calc_ratio(n1) for n1 in Configuration.company]
)[-1]

self.db.update_password(
password,
Expand All @@ -354,7 +358,7 @@ def run(self):
count = 0
ignored = 0

if Configuration.company == '':
if len(Configuration.company) == 0:
Logger.pl(
'{!} {W}It is recommended import cracked passwords using the parameter {O}--company{W} because '
'the KnowsMore will calculate the score of similarity of the passwords and Company Name.'
Expand Down Expand Up @@ -413,8 +417,10 @@ def run(self):

pdata = {}

if Configuration.company != '':
pdata['company_similarity'] = password.calc_ratio(Configuration.company)
if len(Configuration.company) > 0:
pdata['company_similarity'] = sorted(
[password.calc_ratio(n1) for n1 in Configuration.company]
)[-1]

self.db.update_password(
password,
Expand Down
6 changes: 4 additions & 2 deletions knowsmore/cmd/secretsdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,10 @@ def __secret_callback(self, secret_type, secret):
self.add_credential(secret.domain, secret.user_name, pwd.ntlm_hash)

pdata = {}
if Configuration.company != '':
pdata['company_similarity'] = pwd.calc_ratio(Configuration.company)
if len(Configuration.company) > 0:
pdata['company_similarity'] = sorted(
[pwd.calc_ratio(n1) for n1 in Configuration.company]
)[-1]

self.db.insert_password_manually(pwd, **pdata)

Expand Down
8 changes: 4 additions & 4 deletions knowsmore/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Configuration(object):
verbose = 0
module = None
cmd_line = ''
company = ''
company = []

@staticmethod
def initialize():
Expand Down Expand Up @@ -78,10 +78,10 @@ def load_from_arguments():
Logger.pl(' {C}module:{O} %s{W}' % module.name)

if args.args.company is not None and args.args.company.strip(' .,'):
Configuration.company = Tools.clear_string(args.args.company)
Configuration.company = [] + Tools.clear_string(args.args.company).split(',')

if Configuration.company != '':
Logger.pl(' {C}company name:{O} %s{W}' % Configuration.company)
if len(Configuration.company) > 0:
Logger.pl(' {C}company name:{O} %s{W}' % ', '.join(Configuration.company))

if not module.load_from_arguments(args.args):
Configuration.mandatory()
Expand Down
6 changes: 4 additions & 2 deletions knowsmore/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ def get_leets(self, word, index=0) -> list:
yield from self.get_leets(p, index + 1)

def calc_ratio(self, name: str, score_cutoff: float = 0.0) -> int:
if name == 0:
name = name.lower()
if len(name) == 0:
return 0

name = name.lower()

str_pass = self.bytes_password.decode("Latin-1")

Expand Down
2 changes: 2 additions & 0 deletions knowsmore/util/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def permited_char(s):
return True
elif s == ".":
return True
elif s == ",":
return True
else:
return False

Expand Down

0 comments on commit dc522f1

Please sign in to comment.