コード例 #1
0
ファイル: RsaCtfTool.py プロジェクト: wantedbhai/RsaCtfTool
                pub_key, priv_key = generate_keys_from_p_q_e_n(
                    args.p, args.q, args.e, args.n
                )
            except ValueError:
                logger.error(
                    "Looks like the values for generating key are not ok... (no invmod)"
                )
                exit(1)
            if priv_key.is_conspicuous() == True:
                exit(-1)
            else:
                exit(0)

    # Run attacks
    found = False
    attackobj = RSAAttack(args)

    # Run tests
    if args.publickey is None and args.tests:
        tmpfile = tempfile.NamedTemporaryFile()
        with open(tmpfile.name, "wb") as tmpfd:
            tmpfd.write(RSA.construct((35, 3)).publickey().exportKey())
            attackobj.attack_single_key(tmpfile.name, attacks_list, test=True)

    # Attack multiple keys
    if len(args.publickey) > 1:
        found = attackobj.attack_multiple_keys(args.publickey, attacks_list)

    # Attack key
    for publickey in args.publickey:
        attackobj.implemented_attacks = []
コード例 #2
0
                print("dq: " + str(dq))
                print("pinv: " + str(pinv))
                print("qinv: " + str(qinv))

        exit(0)

    if args.key is not None and args.isconspicuous:
        with open(args.key, "rb") as key_fp:
            key_data = key_fp.read()
            key = RSA.importKey(key_data)
            pub_key, priv_key = generate_keys_from_p_q_e_n(
                key.p, key.q, key.e, key.n)
            if priv_key.is_conspicuous() == True:
                exit(-1)
            else:
                exit(0)

    # Run attacks
    found = False
    attackobj = RSAAttack(args)

    if len(args.publickey) > 1:
        found = attackobj.attack_multiple_keys(args.publickey, attacks_list)

    if not found:
        for publickey in args.publickey:
            attackobj.implemented_attacks = []
            logger.info("\n[*] Testing key %s." % publickey)
            attackobj.attack_single_key(publickey, attacks_list)
            attackobj.unciphered = []