Example #1
0
def main():
    global PARAMETERS
    try:
        PARAMETERS = parse_parameters()

        ciphertext = get_ciphertext()

        update_key_length(ciphertext)

        if PARAMETERS["brute_chars"] != None:
            try_chars = range(0, 256)
        elif PARAMETERS["brute_printable"] != None:
            try_chars = map(lambda x: ord(x), string.printable)
        elif PARAMETERS["most_frequent_char"] != None:
            try_chars = [PARAMETERS["most_frequent_char"]]
        else:
            die(C_WARN + "Most possible char is needed to guess the key!" + C_RESET)

        (probable_keys, key_char_used) = guess_probable_keys_for_chars(ciphertext, try_chars)

        print_keys(probable_keys)
        produce_plaintexts(ciphertext, probable_keys, key_char_used)

    except IOError as err:
        print C_FATAL + "[ERROR] Can't load file:\n\t", err, C_RESET
    except ArgError as err:
        print C_FATAL + "[ERROR] Bad argument:\n\t", err, C_RESET
    except MkdirError as err:
        print C_FATAL + "[ERROR] Can't create directory:\n\t", err, C_RESET
    else:
        return
    cleanup()
Example #2
0
def main():
    global PARAMETERS
    try:
        PARAMETERS = parse_parameters(__doc__, __version__)
        ciphertext = get_ciphertext()
        update_key_length(ciphertext)

        if PARAMETERS["brute_chars"]:
            try_chars = range(256)
        elif PARAMETERS["brute_printable"]:
            try_chars = map(ord, string.printable)
        elif PARAMETERS["most_frequent_char"] != None:
            try_chars = [PARAMETERS["most_frequent_char"]]
        else:
            die(C_WARN + "Most possible char is needed to guess the key!" +
                C_RESET)

        (probable_keys,
         key_char_used) = guess_probable_keys_for_chars(ciphertext, try_chars)

        print_keys(probable_keys)
        produce_plaintexts(ciphertext, probable_keys, key_char_used)

    except IOError as err:
        print(C_FATAL + "[ERROR] Can't load file:\n\t", err, C_RESET)
    except ArgError as err:
        print(C_FATAL + "[ERROR] Bad argument:\n\t", err, C_RESET)
    except MkdirError as err:
        print(C_FATAL + "[ERROR] Can't create directory:\n\t", err, C_RESET)
    except AnalysisError as err:
        print(C_FATAL + "[ERROR] Analysis error:\n\t", err, C_RESET)
    else:
        return
    cleanup()
Example #3
0
def main():
    global PARAMETERS
    PARAMETERS = parse_parameters()
    
    ciphertext = get_ciphertext()
    
    update_key_length(ciphertext)

    probable_keys = guess_probable_keys(ciphertext)
    print_keys(probable_keys)
    
    produce_plaintexts(ciphertext, probable_keys)
    return
Example #4
0
def main():
    global PARAMETERS
    try:
        PARAMETERS = parse_parameters()

        ciphertext = get_ciphertext()

        update_key_length(ciphertext)

        probable_keys = guess_probable_keys(ciphertext)
        print_keys(probable_keys)

        produce_plaintexts(ciphertext, probable_keys)
    except IOError as err:
        print C_FATAL + "[ERROR] Can't load file:\n\t", err, C_RESET
    except ArgError as err:
        print C_FATAL + "[ERROR] Bad argument:\n\t", err, C_RESET
    except MkdirError as err:
        print C_FATAL + "[ERROR] Can't create directory:\n\t", err, C_RESET
    else:
        return
    cleanup()
Example #5
0
def main():
    global PARAMETERS
    try:
        PARAMETERS = parse_parameters()

        ciphertext = get_ciphertext()

        update_key_length(ciphertext)

        probable_keys = guess_probable_keys(ciphertext)
        print_keys(probable_keys)

        produce_plaintexts(ciphertext, probable_keys)
    except IOError as err:
        print C_FATAL + "[ERROR] Can't load file:\n\t", err, C_RESET
    except ArgError as err:
        print C_FATAL + "[ERROR] Bad argument:\n\t", err, C_RESET
    except MkdirError as err:
        print C_FATAL + "[ERROR] Can't create directory:\n\t", err, C_RESET
    else:
        return
    cleanup()