示例#1
0
def encrypter():
    plaintext = crypty.convert_b64_to_hex(plaintexts[randint(
        0, len(plaintexts))])
    #print plaintext.decode("hex")
    iv = crypty.generate_key()
    ciphertext = aes_cbc.infra.encrypt_manual(plaintext, key, iv)
    return (iv, ciphertext)
示例#2
0
def encryption_oracle(plaintext):
    global KEY
    global prefix
    if KEY is None:
        KEY = crypty.generate_key()
    if prefix is None:
        # I am getting integer between 0 to 100
        prefix = crypty.generate_key(key_size=randint(0, 100))
        print "[*] Using Prefix of size : %d" % (len(prefix) / 2)
    plaintext = crypty.pad_pkcs_7(prefix + plaintext +
                                  crypty.convert_b64_to_hex(suffix))
    return aes_ecb.infra.encrypt(plaintext, KEY)
示例#3
0
def solve():
    ciphertext = crypty.convert_b64_to_hex(get_ciphertext())

    ## Test to check hamming distance
    assert crypty.hamming_distance(crypty.a2h("this is a test"),
                                   crypty.a2h("wokka wokka!!!")) == 37

    key_size = xor_cipher.attacks.keysize_estimator(ciphertext, 2, 40)[0][1]
    print "Trying for key size: %d" % (key_size)
    key = xor_cipher.attacks.brute_force(ciphertext, key_len=key_size)
    print "Found Key : %d : %s" % (len(crypty.h2a(key)), crypty.h2a(key))
    plaintext = xor_cipher.infra.decrypt(ciphertext, key)
    print "Plaintext : %s" % (crypty.h2a(plaintext))
示例#4
0
def solve():
    ciphertexts = []
    for plaintext in plaintexts:
        plaintext = crypty.convert_b64_to_hex(plaintext)
        ciphertexts.append(aes_ctr.infra.encrypt(plaintext, key, 0))
    return ciphertexts
示例#5
0
def solve():
    ciphertext = crypty.convert_b64_to_hex(get_ciphertexts())
    key = crypty.a2h("YELLOW SUBMARINE")
    iv = crypty.a2h("\x00" * 16)
    print crypty.h2a(aes_cbc.infra.decrypt_manual(ciphertext, key, iv))
示例#6
0
def get_plaintext():
    fp = open("25.txt", "r")
    ciphertext = crypty.convert_b64_to_hex("".join(
        [l.strip() for l in fp.readlines()]))
    return aes_ecb.infra.decrypt(ciphertext, crypty.a2h("YELLOW SUBMARINE"))
示例#7
0
def solve():
  ciphertext = crypty.convert_b64_to_hex("L77na/nrFsKvynd6HzOoG7GHTLXsTVu9qvY/2syLXzhPweyyMTJULu/6/kXX0KSvoOLSFQ==")
  KEY = crypty.a2h("YELLOW SUBMARINE")
  nounce = 0
  print aes_ctr.infra.decrypt(ciphertext, KEY, nounce).decode("hex")
示例#8
0
def solve():
  ciphertext = crypty.convert_b64_to_hex(get_ciphertext())
  key = crypty.a2h("YELLOW SUBMARINE")
  plaintext = crypty.h2a(aes_ecb.infra.decrypt(ciphertext, key))
  print plaintext
示例#9
0
def encryption_oracle(plaintext):
  global KEY
  if KEY is None:
    KEY = crypty.generate_key()
  plaintext = crypty.pad_pkcs_7(plaintext+crypty.convert_b64_to_hex(suffix))
  return aes_ecb.infra.encrypt(plaintext, KEY)