Example #1
0
def evp_decode(cipher_text, passphrase, salt=None):
    cipher_text = base64.b64decode(cipher_text)
    if not salt:
        salt = cipher_text[8:16]
        cipher_text = cipher_text[16:]
    data = evpKDF(passphrase, salt)
    decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(data['key'], data['iv']))
    plain_text = decrypter.feed(cipher_text)
    plain_text += decrypter.feed()
    return plain_text
 def _decrypt(self, url):
     import base64
     decrypter = pyaes.Decrypter(
         pyaes.AESModeOfOperationCBC(
             base64.urlsafe_b64decode(
                 'cXdlcnR5dWlvcGFzZGZnaGprbHp4YzEyMzQ1Njc4OTA='),
             '\0' * 16))
     url = base64.decodestring(url)
     url = decrypter.feed(url) + decrypter.feed()
     return url
Example #3
0
 def decrypt(self, js):
     js = json.loads(js)
     ciphertext = js["y"]
     iv = js["fast"]
     salt = js["bald"]
     key = I11I1IIII1II11111II1I1I1II11I1I.I11I1IIII1II11111II1I1I1II11III(
         salt)
     iv = iv.decode('hex')
     decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(key, iv))
     decrypted = decrypter.feed(
         base64.b64decode(ciphertext)) + decrypter.feed()
     return decrypted
Example #4
0
def get_post_data():
    _key = b"cLt3Gp39O3yvW7Gw"
    _iv = b"bRRhl2H2j7yXmuk4"
    cipher = pyaes.Encrypter(pyaes.AESModeOfOperationCBC(_key, _iv))
    ciphertext = ''
    _time = str(int(time.time()))
    _hash = md5("{0}e31Vga4MXIYss1I0jhtdKlkxxwv5N0CYSnCpQcRijIdSJYg".format(
        _time).encode("utf-8")).hexdigest()
    _plain = "{0}&{1}".format(_time, _hash).ljust(48).encode("utf-8")
    ciphertext += cipher.feed(_plain)
    ciphertext += cipher.feed()
    return b2a_hex(ciphertext[:-16]).decode("utf-8")
Example #5
0
 def __decrypt(self, encrypted):
     try:
         encrypted = base64.b64decode(encrypted)
         salt = encrypted[8:16]
         key_iv = self.__bytes_to_key(self.password, salt)
         key = key_iv[:32]
         iv = key_iv[32:]
         decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(key, iv = iv))
         plaintext = decrypter.feed(encrypted[16:])
         plaintext += decrypter.feed()
         return plaintext
     except Exception:
         return
def cryptoJS_AES_decrypt(encrypted, password, salt):
    def derive_key_and_iv(password, salt, key_length, iv_length):
        d = d_i = ''
        while len(d) < key_length + iv_length:
            d_i = md5(d_i + password + salt).digest()
            d += d_i
        return d[:key_length], d[key_length:key_length + iv_length]

    key, iv = derive_key_and_iv(password, salt, 32, 16)
    cipher = pyaes.AESModeOfOperationCBC(key=key, iv=iv)
    decrypted_data = ""
    for part in [encrypted[i:i + 16] for i in range(0, len(encrypted), 16)]:
        decrypted_data += cipher.decrypt(part)

    return decrypted_data[0:-ord(decrypted_data[-1])]
 def _getCryptor(self, secret_token):
     init_vector = secret_token[:len(secret_token) // 2]
     key = secret_token[len(secret_token) // 2:]
     return pyaes.AESModeOfOperationCBC(key, iv=init_vector)