예제 #1
0
def ciphertext_oracle():
    ecb_ciphertext = base64.b64decode(open('25.txt', 'r').read())
    ecb_key = b'YELLOW SUBMARINE'
    ecb_cipher = AES.new(ecb_key, AES.MODE_ECB)
    plaintext = ecb_cipher.decrypt(ecb_ciphertext)
    cipher = challenge18.CTR(AES.new(key, AES.MODE_ECB), nonce)
    return cipher.encrypt(plaintext)
예제 #2
0
def encryptParams(userdata):
    userdata = userdata.replace(';', '%3B').replace('=', '%3D')
    x1 = b'comment1=cooking%20MCs;userdata='
    x2 = b';comment2=%20like%20a%20pound%20of%20bacon'
    params = x1 + userdata.encode('ascii') + x2
    cipher = challenge18.CTR(AES.new(key, AES.MODE_ECB), nonce)
    return cipher.encrypt(util.padPKCS7(params, 16))
예제 #3
0
def edit(ciphertext, offset, newtext):
    cipher = challenge18.CTR(AES.new(key, AES.MODE_ECB), nonce)
    cipher.encrypt(b'\x00' * offset)
    return ciphertext[0:offset] + cipher.encrypt(newtext)
예제 #4
0
def decryptParamsAndCheckAdmin(encryptedParams):
    cipher = challenge18.CTR(AES.new(key, AES.MODE_ECB), nonce)
    paddedParams = cipher.decrypt(encryptedParams)
    params = challenge15.unpadPKCS7(paddedParams)
    return params.find(b';admin=true;') != -1
예제 #5
0
def encryptString(s):
    cipher = challenge18.CTR(AES.new(key, AES.MODE_ECB), 0)
    return cipher.encrypt(s)