77
88Usage:
99 xortool [-x] [-m MAX-LEN] [-f] [-t CHARSET] [FILE]
10- xortool [-x] [-l LEN] [-c CHAR | -b | -o] [-f] [-t CHARSET] [FILE]
11- xortool [-x] [-m MAX-LEN| -l LEN] [-c CHAR | -b | -o] [-f] [-t CHARSET] [FILE]
10+ xortool [-x] [-l LEN] [-c CHAR | -b | -o] [-f] [-t CHARSET] [-p PLAIN] [ FILE]
11+ xortool [-x] [-m MAX-LEN| -l LEN] [-c CHAR | -b | -o] [-f] [-t CHARSET] [-p PLAIN] [ FILE]
1212 xortool [-h | --help]
1313 xortool --version
1414
@@ -21,6 +21,7 @@ Options:
2121 -o --brute-printable same as -b but will only check printable chars
2222 -f --filter-output filter outputs based on the charset
2323 -t CHARSET --text-charset=CHARSET target text character set [default: printable]
24+ -p PLAIN --known-plaintext=PLAIN use known plaintext for decoding
2425 -h --help show this help
2526
2627Notes:
@@ -372,6 +373,9 @@ def produce_plaintexts(ciphertext, keys, key_char_used):
372373 file_name = os .path .join (DIRNAME , key_index + ".out" )
373374
374375 dexored = dexor (ciphertext , key )
376+ # ignore saving file when known plain is provided and output doesn't contain it
377+ if PARAMETERS ["known_plain" ] and PARAMETERS ["known_plain" ] not in dexored :
378+ continue
375379 perc = round (100 * percentage_valid (dexored ))
376380 if perc > threshold_valid :
377381 count_valid += 1
@@ -388,6 +392,8 @@ def produce_plaintexts(ciphertext, keys, key_char_used):
388392 perc_mapping .close ()
389393
390394 fmt = "Found {C_COUNT}{:d}{C_RESET} plaintexts with {C_COUNT}{:d}{C_RESET}%+ valid characters"
395+ if PARAMETERS ["known_plain" ]:
396+ fmt += " which contained '{}'" .format (PARAMETERS ["known_plain" ].decode ('ascii' ))
391397 print (fmt .format (count_valid , round (threshold_valid ), ** COLORS ))
392398 print ("See files {}, {}" .format (fn_key_mapping , fn_perc_mapping ))
393399
0 commit comments