def fermat_factor_attack(ciphertexts):
   options = dict(feathermodules.current_options)
   options = prepare_options(options, ciphertexts)
   if options == False:
      print '[*] Could not process options.'
      return False
   answers = []
   for ciphertext in ciphertexts:
      try:
         key = RSA.importKey(ciphertext)
         if key.has_private():
            continue
         else:
            modulus = key.n
            exponent = key.e
      except:
         continue

      factors = ca.fermat_factor(modulus, minutes=options['minutes_to_wait'], verbose=True)
      if factors[0] != 1:
         answers.append( (modulus, exponent, ca.derive_d_from_pqe(factors[0],factors[1],exponent)) )
   
   for answer in answers:
      key = RSA.construct(answer)
      print "Found private key:\n%s" % key.exportKey()
   
   return ''
Beispiel #2
0
def fermat_factor_attack(ciphertexts):
    arguments = get_arguments(ciphertexts)
    answers = []
    for ciphertext in ciphertexts:
        try:
            key = RSA.importKey(ciphertext)
            if key.has_private():
                continue
            else:
                modulus = key.n
                exponent = key.e
        except:
            continue

        factors = ca.fermat_factor(modulus,
                                   minutes=arguments['minutes'],
                                   verbose=True)
        if factors[0] != 1:
            answers.append((modulus, exponent,
                            ca.derive_d_from_pqe(factors[0], factors[1],
                                                 exponent)))

    for answer in answers:
        key = RSA.construct(answer)
        print "Found private key:\n%s" % key.exportKey()

    return ''
Beispiel #3
0
def rsa_wiener_attack(ciphertexts):
   options = dict(feathermodules.current_options)
   options = prepare_options(options, ciphertexts)
   if options == False:
      print '[*] Could not process options.'
      return False
   answers = []
   for ciphertext in ciphertexts:
      try:
         key = RSA.importKey(ciphertext)
         if key.has_private():
            continue
         else:
            modulus = key.n
            exponent = key.e
      except:
         continue

      p = ca.wiener(modulus, exponent, minutes=options['minutes_to_wait'], verbose=True)
      if p != 1:
         answers.append( (modulus, exponent, ca.derive_d_from_pqe(p,modulus/p,exponent)) )
   
   for answer in answers:
      key = RSA.construct(answer)
      print "Found private key:\n%s" % key.exportKey()
   
   if len(answers) == 0:
      return False
   else:
      return ['N:{},e:{},d:{}'.format(answer) for answer in answers]
Beispiel #4
0
def wiener_attack(ciphertexts):
   arguments = get_arguments(ciphertexts)
   answers = []
   for ciphertext in ciphertexts:
      try:
         key = RSA.importKey(ciphertext)
         if key.has_private():
            continue
         else:
            modulus = key.n
            exponent = key.e
      except:
         continue

      p = ca.wiener(modulus, exponent, minutes=arguments['minutes'], verbose=True)
      answers.append((modulus, exponent, p))
   
   for n, e, p in answers:
      try:
         d = ca.derive_d_from_pqe(p, n/p, e)
         key = RSA.construct((n, e, d))
         print "Found private key:\n%s" % key.exportKey()
      except:
         print "\nAttack failed, key is too strong."
   
   return ''
Beispiel #5
0
def fermat_factor_attack(ciphertexts):
    options = dict(feathermodules.current_options)
    options = prepare_options(options, ciphertexts)
    if options == False:
        print '[*] Could not process options.'
        return False
    answers = []
    for ciphertext in ciphertexts:
        try:
            key = RSA.importKey(ciphertext)
            if key.has_private():
                continue
            else:
                modulus = key.n
                exponent = key.e
        except:
            continue

        factors = ca.fermat_factor(modulus,
                                   minutes=options['minutes_to_wait'],
                                   verbose=True)
        if factors[0] != 1:
            answers.append((modulus, exponent,
                            ca.derive_d_from_pqe(factors[0], factors[1],
                                                 exponent)))

    for answer in answers:
        key = RSA.construct(answer)
        print "Found private key:\n%s" % key.exportKey()

    return ''
Beispiel #6
0
def wiener_attack(ciphertexts):
    arguments = get_arguments(ciphertexts)
    answers = []
    for ciphertext in ciphertexts:
        try:
            key = RSA.importKey(ciphertext)
            if key.has_private():
                continue
            else:
                modulus = key.n
                exponent = key.e
        except:
            continue

        p = ca.wiener(modulus,
                      exponent,
                      minutes=arguments['minutes'],
                      verbose=True)
        answers.append((modulus, exponent, p))

    for n, e, p in answers:
        try:
            d = ca.derive_d_from_pqe(p, n / p, e)
            key = RSA.construct((n, e, d))
            print "Found private key:\n%s" % key.exportKey()
        except:
            print "\nAttack failed, key is too strong."

    return ''
Beispiel #7
0
def fermat_factor_attack(ciphertexts):
   arguments = get_arguments(ciphertexts)
   answers = []
   for ciphertext in ciphertexts:
      try:
         key = RSA.importKey(ciphertext)
         if key.has_private():
            continue
         else:
            modulus = key.n
            exponent = key.e
      except:
         continue

      factors = ca.fermat_factor(modulus, minutes=arguments['minutes'], verbose=True)
      if factors[0] != 1:
         answers.append( (modulus, exponent, ca.derive_d_from_pqe(factors[0],factors[1],exponent)) )
   
   for answer in answers:
      key = RSA.construct(answer)
      print "Found private key:\n%s" % key.exportKey()
   
   return ''