Fixed bugs in policygen.py (--max options are now working properly)
This commit is contained in:
parent
a55be30bc5
commit
e041e7906d
@ -65,6 +65,7 @@ class MaskGen:
|
|||||||
elif char == "u": count *= 26
|
elif char == "u": count *= 26
|
||||||
elif char == "d": count *= 10
|
elif char == "d": count *= 10
|
||||||
elif char == "s": count *= 33
|
elif char == "s": count *= 33
|
||||||
|
elif char == "a": count *= 95
|
||||||
else: print "[!] Error, unknown mask ?%s in a mask %s" % (char,mask)
|
else: print "[!] Error, unknown mask ?%s in a mask %s" % (char,mask)
|
||||||
|
|
||||||
return count
|
return count
|
||||||
@ -264,7 +265,4 @@ if __name__ == "__main__":
|
|||||||
sorting_mode = "optindex"
|
sorting_mode = "optindex"
|
||||||
|
|
||||||
print "[*] Sorting masks by their [%s]." % sorting_mode
|
print "[*] Sorting masks by their [%s]." % sorting_mode
|
||||||
maskgen.generate_masks(sorting_mode)
|
maskgen.generate_masks(sorting_mode)
|
||||||
|
|
||||||
|
|
||||||
|
|
45
policygen.py
45
policygen.py
@ -70,6 +70,7 @@ class PolicyGen:
|
|||||||
elif char == "u": count *= 26
|
elif char == "u": count *= 26
|
||||||
elif char == "d": count *= 10
|
elif char == "d": count *= 10
|
||||||
elif char == "s": count *= 33
|
elif char == "s": count *= 33
|
||||||
|
elif char == "a": count *= 95
|
||||||
else: print "[!] Error, unknown mask ?%s in a mask %s" % (char,mask)
|
else: print "[!] Error, unknown mask ?%s in a mask %s" % (char,mask)
|
||||||
|
|
||||||
return count
|
return count
|
||||||
@ -118,14 +119,14 @@ class PolicyGen:
|
|||||||
# Filter according to password policy
|
# Filter according to password policy
|
||||||
# NOTE: Perform exact opposite (XOR) operation if noncompliant
|
# NOTE: Perform exact opposite (XOR) operation if noncompliant
|
||||||
# flag was set when calling the function.
|
# flag was set when calling the function.
|
||||||
if ((not self.minlower or lowercount >= self.minlower) and \
|
if ((self.minlower == None or lowercount >= self.minlower) and \
|
||||||
(not self.maxlower or lowercount <= self.maxlower) and \
|
(self.maxlower == None or lowercount <= self.maxlower) and \
|
||||||
(not self.minupper or uppercount >= self.minupper) and \
|
(self.minupper == None or uppercount >= self.minupper) and \
|
||||||
(not self.maxupper or uppercount <= self.maxupper) and \
|
(self.maxupper == None or uppercount <= self.maxupper) and \
|
||||||
(not self.mindigit or digitcount >= self.mindigit) and \
|
(self.mindigit == None or digitcount >= self.mindigit) and \
|
||||||
(not self.maxdigit or digitcount <= self.maxdigit) and \
|
(self.maxdigit == None or digitcount <= self.maxdigit) and \
|
||||||
(not self.minspecial or specialcount >= self.minspecial) and \
|
(self.minspecial == None or specialcount >= self.minspecial) and \
|
||||||
(not self.maxspecial or specialcount <= self.maxspecial)) ^ noncompliant :
|
(self.maxspecial == None or specialcount <= self.maxspecial)) ^ noncompliant :
|
||||||
|
|
||||||
sample_length_count += 1
|
sample_length_count += 1
|
||||||
sample_length_complexity += mask_complexity
|
sample_length_complexity += mask_complexity
|
||||||
@ -138,8 +139,6 @@ class PolicyGen:
|
|||||||
if self.output_file:
|
if self.output_file:
|
||||||
self.output_file.write("%s\n" % mask)
|
self.output_file.write("%s\n" % mask)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
total_count += total_length_count
|
total_count += total_length_count
|
||||||
sample_count += sample_length_count
|
sample_count += sample_length_count
|
||||||
|
|
||||||
@ -204,16 +203,16 @@ if __name__ == "__main__":
|
|||||||
policygen.output_file = open(options.output_masks, 'w')
|
policygen.output_file = open(options.output_masks, 'w')
|
||||||
|
|
||||||
# Password policy
|
# Password policy
|
||||||
if options.minlength: policygen.minlength = options.minlength
|
if options.minlength != None: policygen.minlength = options.minlength
|
||||||
if options.maxlength: policygen.maxlength = options.maxlength
|
if options.maxlength != None: policygen.maxlength = options.maxlength
|
||||||
if options.mindigit: policygen.mindigit = options.mindigit
|
if options.mindigit != None: policygen.mindigit = options.mindigit
|
||||||
if options.minlower: policygen.minlower = options.minlower
|
if options.minlower != None: policygen.minlower = options.minlower
|
||||||
if options.minupper: policygen.minupper = options.minupper
|
if options.minupper != None: policygen.minupper = options.minupper
|
||||||
if options.minspecial: policygen.minspecial = options.minspecial
|
if options.minspecial != None: policygen.minspecial = options.minspecial
|
||||||
if options.maxdigit: policygen.maxdigits = options.maxdigit
|
if options.maxdigit != None: policygen.maxdigits = options.maxdigit
|
||||||
if options.maxlower: policygen.maxlower = options.maxlower
|
if options.maxlower != None: policygen.maxlower = options.maxlower
|
||||||
if options.maxupper: policygen.maxupper = options.maxupper
|
if options.maxupper != None: policygen.maxupper = options.maxupper
|
||||||
if options.maxspecial: policygen.maxspecial = options.maxspecial
|
if options.maxspecial != None: policygen.maxspecial = options.maxspecial
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
if options.pps: policygen.pps = options.pps
|
if options.pps: policygen.pps = options.pps
|
||||||
@ -221,9 +220,9 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# Print current password policy
|
# Print current password policy
|
||||||
print "[*] Password policy:"
|
print "[*] Password policy:"
|
||||||
print " Pass Lengths: min:%d max:%d" % (options.minlength,options.maxlength)
|
print " Pass Lengths: min:%d max:%d" % (policygen.minlength, policygen.maxlength)
|
||||||
print " Min strength: l:%s u:%s d:%s s:%s" % (options.minlower, options.minupper, options.mindigit, options.minspecial)
|
print " Min strength: l:%s u:%s d:%s s:%s" % (policygen.minlower, policygen.minupper, policygen.mindigit, policygen.minspecial)
|
||||||
print " Max strength: l:%s u:%s d:%s s:%s" % (options.maxlower, options.maxupper, options.maxdigit, options.maxspecial)
|
print " Max strength: l:%s u:%s d:%s s:%s" % (policygen.maxlower, policygen.maxupper, policygen.maxdigit, policygen.maxspecial)
|
||||||
|
|
||||||
print "[*] Generating [%s] masks." % ("compliant" if not options.noncompliant else "non-compliant")
|
print "[*] Generating [%s] masks." % ("compliant" if not options.noncompliant else "non-compliant")
|
||||||
policygen.generate_masks(options.noncompliant)
|
policygen.generate_masks(options.noncompliant)
|
@ -167,14 +167,14 @@ def main():
|
|||||||
if count*100/filter_counter > 0:
|
if count*100/filter_counter > 0:
|
||||||
print "[+] %25d: %02d%% (%d)" % (length, count*100/filter_counter, count)
|
print "[+] %25d: %02d%% (%d)" % (length, count*100/filter_counter, count)
|
||||||
|
|
||||||
print "\n[*] Mask statistics..."
|
|
||||||
for (mask,count) in sorted(masks.iteritems(), key=operator.itemgetter(1), reverse=True):
|
|
||||||
print "[+] %25s: %02d%% (%d)" % (mask, count*100/filter_counter, count)
|
|
||||||
|
|
||||||
print "\n[*] Charset statistics..."
|
print "\n[*] Charset statistics..."
|
||||||
for (char,count) in sorted(chars.iteritems(), key=operator.itemgetter(1), reverse=True):
|
for (char,count) in sorted(chars.iteritems(), key=operator.itemgetter(1), reverse=True):
|
||||||
print "[+] %25s: %02d%% (%d)" % (char, count*100/filter_counter, count)
|
print "[+] %25s: %02d%% (%d)" % (char, count*100/filter_counter, count)
|
||||||
|
|
||||||
|
print "\n[*] Mask statistics..."
|
||||||
|
for (mask,count) in sorted(masks.iteritems(), key=operator.itemgetter(1), reverse=True):
|
||||||
|
print "[+] %25s: %02d%% (%d)" % (mask, count*100/filter_counter, count)
|
||||||
|
|
||||||
print "\n[*] Advanced Mask statistics..."
|
print "\n[*] Advanced Mask statistics..."
|
||||||
for (advmask,count) in sorted(advmasks.iteritems(), key=operator.itemgetter(1), reverse=True):
|
for (advmask,count) in sorted(advmasks.iteritems(), key=operator.itemgetter(1), reverse=True):
|
||||||
if count*100/filter_counter > 0:
|
if count*100/filter_counter > 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user