Пример #1
0
        print_results(args, None, priv_key, unciphers)
        exit(0)

    # If we have n and one of p and q, calculated the other
    if args.n and (args.p or args.q):
        args.p, args.q = generate_pq_from_n_and_p_or_q(args.n, args.p, args.q)

    # convert a idrsa.pub file to a pem format
    if args.convert_idrsa_pub:
        # for publickey in args.publickey:
        publickeys = glob(args.publickey)
        for publickey in publickeys:
            logger.info("Converting %s: to pem..." % publickey)
            with open(publickey, "r") as key_data_fd:
                for line in key_data_fd:
                    n, e = disect_idrsa_pub(line.rstrip())
                    if n != None and e != None:
                        pub_key, priv_key = generate_keys_from_p_q_e_n(None, None, e, n)
                        print(pub_key.decode("utf-8"))
        exit(0)

    if args.isroca:
        pubkeyfilelist = glob(args.publickey)
        for publickey in pubkeyfilelist:
            logger.info("[-] Details for %s:" % publickey)
            with open(publickey, "rb") as key_data_fd:
                try:
                    key = RSA.importKey(key_data_fd.read())
                except:
                    key = None
                    logger.error("[!] Error file format: %s" % publickey)
Пример #2
0
        for u in args.uncipher:
            unciphers.append(priv_key.decrypt(args.u))
        print_results(args, None, priv_key, unciphers)
        exit(0)

    # If we have n and one of p and q, calculated the other
    if args.n and (args.p or args.q):
        args.p, args.q = generate_pq_from_n_and_p_or_q(args.n, args.p, args.q)

    # convert a idrsa.pub file to a pem format
    if args.convert_idrsa_pub:
        #for publickey in args.publickey:
        publickey = args.publickey
        logger.info("Converting %s: to pem..." % publickey)
        with open(publickey, "rb") as key_data_fd:
            n, e = disect_idrsa_pub(key_data_fd.read().decode('utf8'))
            pub_key, priv_key = generate_keys_from_p_q_e_n(None, None, e, n)
            print(pub_key.decode("utf-8"))
        exit(0)

    # Create pubkey if requested
    if args.createpub:
        pub_key, priv_key = generate_keys_from_p_q_e_n(args.p, args.q, args.e,
                                                       args.n)
        print(pub_key.decode("utf-8"))
        exit(0)

    # Load keys
    tmpfile = None
    if args.publickey is None and args.e is not None and args.n is not None:
        tmpfile = tempfile.NamedTemporaryFile()