From d9f29b525bc7e44464a356a49131fccf00705e73 Mon Sep 17 00:00:00 2001 From: Rob Date: Fri, 24 Jul 2009 11:15:30 +0200 Subject: [PATCH] In code comments for --all-salts-pattern --- signduterre.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/signduterre.py b/signduterre.py index d2ac0c6..b20b472 100755 --- a/signduterre.py +++ b/signduterre.py @@ -505,7 +505,7 @@ input_file = options.input; total_only = True; total_only = not options.detail; if options.total: total_only = options.total; -if my_allsalts: total_only = my_allsalts; +if my_allsalts: total_only = my_allsalts; # All alts pattern only sensible with total-only if my_check: total_only = False; my_user = options.user; @@ -575,7 +575,7 @@ if my_check: if match != None: salt_list.append(match.group(1)); total_hash_list.append(match.group(2)); - my_allsalts = True; + my_allsalts = True; # Salt+TOTAL HASH imples all-salts-pattern continue; match = re.search("Salt\:\s+\'([\w]*)\'", line); @@ -669,6 +669,7 @@ elif len(salt_list) == 0: if not new_salt: new_salt = str(binascii.hexlify(salt), 'ascii'); salt_list.append(new_salt); +# If not combining salts with TOTAL HASH, print salts now if not my_allsalts: for my_salt in salt_list: print("Salt: \'"+my_salt+"\'"); @@ -709,7 +710,7 @@ if not my_check: passphrase_list = [passphrase_list[j]]; print("# Selected passphrase:", j+1, file=sys.stderr); j = int(random.random()*len(salt_list)); - # Make sure at least 1 salt will match + # Make sure at least 1 salt will match and print the selection if only one is used selected_salt = j+1; if not my_allsalts: salt_list = [salt_list[selected_salt-1]]; @@ -736,6 +737,7 @@ salt_pattern_number = -1; for my_passphrase in passphrase_list: snum = 1; + # Initialize salt pattern if my_allsalts: salt_pattern_number = 0; current_salt_power = 1; @@ -864,6 +866,7 @@ for my_passphrase in passphrase_list: # Handle total hash current_total_digest = totalhash.hexdigest(); + # Write (in)correct salts with the TOTAL HASH if my_allsalts: output_salt = my_salt; j = int(random.random()*2); @@ -875,18 +878,18 @@ for my_passphrase in passphrase_list: else: salt_pattern_number += current_salt_power; current_total_digest_line = "Salt+TOTAL HASH: '"+output_salt+"' '"+current_total_digest+"'"; - else: + else: # Standard TOTAL HASH line current_total_digest_line = current_total_digest+" *"+"TOTAL HASH"; end_time = time.time(); print("# \n# Total hash - Time to completion:", end_time - start_time, "seconds"); total_hash_num = 0; - if my_allsalts: total_hash_num = snum-1; + if my_allsalts: total_hash_num = snum-1; # Current TOTAL HASH number of more are used if not my_check: print(current_total_digest_line+"\n"); elif current_total_digest != total_hash_list[total_hash_num]: if not my_allsalts: print("DIFFERENT: "+current_total_digest_line+"\n"); else: - if my_allsalts: salt_pattern_number += current_salt_power; + if my_allsalts: salt_pattern_number += current_salt_power; # Update salt bit pattern match_number = ""; if len(passphrase_list) > 1 or len(salt_list): match_number = " #" if len(passphrase_list) > 1: match_number += " passphrase no: "+str(pnum); @@ -895,7 +898,7 @@ for my_passphrase in passphrase_list: corrsnum = snum; corrpnum = pnum; snum += 1; - if my_allsalts: current_salt_power *= 2; + if my_allsalts: current_salt_power *= 2; # Update current bit position in salt pattern if my_check and corrpnum == pnum: matched_salt_pattern = salt_pattern_number; pnum += 1; @@ -912,6 +915,7 @@ if my_check and (not my_allsalts) and len(salt_list) > 1: print("No salt entry matched!"); else: print("No entry matched"); +# Print salt bit patterns elif my_check and my_allsalts: print("Salt pattern number:", matched_salt_pattern); elif not my_check and my_allsalts: -- 2.11.4.GIT