Fixed inverse logic bug in maskgen.

This commit is contained in:
Florian Engel 2016-11-07 23:37:55 +01:00
parent 5311d5cbb1
commit c4bfe00e75

View File

@ -73,13 +73,13 @@ class MaskGen:
# Apply filters based on occurrence, length, complexity and time # Apply filters based on occurrence, length, complexity and time
if (self.minoccurrence == None or mask_occurrence >= self.minoccurrence) and \ if (self.minoccurrence == None or mask_occurrence >= self.minoccurrence) and \
(self.maxoccurrence == None or mask_occurrence <= self.maxoccurrence) and \ (self.maxoccurrence == None or mask_occurrence <= self.maxoccurrence) and \
(self.mincomplexity == None or mask_complexity <= self.mincomplexity) and \ (self.mincomplexity == None or mask_complexity >= self.mincomplexity) and \
(self.maxcomplexity == None or mask_complexity <= self.maxcomplexity) and \ (self.maxcomplexity == None or mask_complexity <= self.maxcomplexity) and \
(self.mintime == None or mask_time <= self.mintime) and \ (self.mintime == None or mask_time >= self.mintime) and \
(self.maxtime == None or mask_time <= self.maxtime) and \ (self.maxtime == None or mask_time <= self.maxtime) and \
(self.maxlength == None or mask_length <= self.maxlength) and \ (self.maxlength == None or mask_length <= self.maxlength) and \
(self.minlength == None or mask_length >= self.minlength): (self.minlength == None or mask_length >= self.minlength):
self.masks[mask] = dict() self.masks[mask] = dict()
self.masks[mask]['length'] = mask_length self.masks[mask]['length'] = mask_length
self.masks[mask]['occurrence'] = mask_occurrence self.masks[mask]['occurrence'] = mask_occurrence
@ -128,7 +128,7 @@ class MaskGen:
total_complexity = 0 total_complexity = 0
if self.showmasks: print "[L:] Mask: [ Occ: ] [ Time: ]" if self.showmasks: print "[L:] Mask: [ Occ: ] [ Time: ]"
for mask in checkmasks: for mask in checkmasks:
mask = mask.strip() mask = mask.strip()
mask_complexity = self.getcomplexity(mask) mask_complexity = self.getcomplexity(mask)
@ -209,7 +209,7 @@ if __name__ == "__main__":
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
# Print program header # Print program header
if not options.quiet: if not options.quiet:
print header print header
if len(args) < 1: if len(args) < 1:
@ -241,7 +241,7 @@ if __name__ == "__main__":
if options.showmasks: maskgen.showmasks = options.showmasks if options.showmasks: maskgen.showmasks = options.showmasks
print "[*] Using {:,d} keys/sec for calculations.".format(maskgen.pps) print "[*] Using {:,d} keys/sec for calculations.".format(maskgen.pps)
# Load masks # Load masks
for arg in args: for arg in args:
maskgen.loadmasks(arg) maskgen.loadmasks(arg)
@ -261,12 +261,12 @@ if __name__ == "__main__":
# Printing masks in a file # Printing masks in a file
else: else:
# Process masks according to specified sorting algorithm # Process masks according to specified sorting algorithm
if options.occurrence: if options.occurrence:
sorting_mode = "occurrence" sorting_mode = "occurrence"
elif options.complexity: elif options.complexity:
sorting_mode = "complexity" sorting_mode = "complexity"
else: else:
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)