예제 #1
0
def aes_decrypt_with_iv(key, iv, data):
    assert_bytes(key, iv, data)
    if AES:
        cipher = AES.new(key, AES.MODE_CBC, iv)
        data = cipher.decrypt(data)
    else:
        aes_cbc = pyaes.AESModeOfOperationCBC(key, iv=iv)
        aes = pyaes.Decrypter(aes_cbc, padding=pyaes.PADDING_NONE)
        data = aes.feed(data) + aes.feed()  # empty aes.feed() flushes buffer
    try:
        return strip_PKCS7_padding(data)
    except InvalidPadding:
        raise InvalidPassword()
예제 #2
0
def decrypt_message(ciphertextb64, id):
    key = array_clients[int(id)].aes_key.encode()

    ciphertextb64 = base64.b64decode(ciphertextb64)

    decryptor = pyaes.Decrypter(pyaes.AESModeOfOperationECB(key))
    decryptedmessage = decryptor.feed(ciphertextb64)
    decryptedmessage = decryptor.feed(
        ciphertextb64[:int(len(ciphertextb64) / 2)])
    decryptedmessage += decryptor.feed(
        ciphertextb64[int(len(ciphertextb64) / 2):])

    return decryptedmessage.decode()
예제 #3
0
 def __init__(self, method=None, key=None, iv=None):
     self.aes = None
     self.key = key
     self.method = method
     self.iv = iv
     self.chunksize = 2**5
     self.skipdec = method not in ["AES-128"]
     if not self.hasopenssl and method == "AES-128":
         key = binascii.unhexlify(key)
         iv = binascii.unhexlify(iv)
         self.aes = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(key, iv=iv),
                                    padding=pyaes.PADDING_NONE)
         self.chunksize = 128
예제 #4
0
 def _decrypt(self, msg, key, iv):
     from binascii import unhexlify, hexlify
     import pyaes
     msg = unhexlify(msg)
     key = unhexlify(key)
     iv = unhexlify(iv)
     if len(iv) != 16:
         return False
     decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(key, iv))
     plain_text = decrypter.feed(msg)
     plain_text += decrypter.feed()
     f = hexlify(plain_text)
     return f
예제 #5
0
파일: bitcoin.py 프로젝트: omn14/electrum
def aes_decrypt_with_iv(key, iv, data):
    if AES:
        cipher = AES.new(key, AES.MODE_CBC, iv)
        data = cipher.decrypt(data)
        padlen = ord(data[-1])
        for i in data[-padlen:]:
            if ord(i) != padlen:
                raise InvalidPassword()
        return data[0:-padlen]
    else:
        aes_cbc = pyaes.AESModeOfOperationCBC(key, iv=iv)
        aes = pyaes.Decrypter(aes_cbc)
        s = aes.feed(data) + aes.feed()  # empty aes.feed() strips pkcs padding
        return s
예제 #6
0
def decrypt(encoded_ciphertext: str, key: str) -> str:
    """
    Decrypt the given ciphertext with the given key. The ciphertext must correspond to the format as generated by
        encrypt(data, key)
    """
    iv, ciphertext, hashed_key = load_ct(encoded_ciphertext)

    if hashed_key != hash_key(key):
        raise InvalidKeyException

    decrypter = pyaes.Decrypter(aes_mode_of_operation(key, iv))
    padded_plaintext = decrypter.feed(ciphertext) + decrypter.feed()

    return un_pad_and_decode(padded_plaintext)
예제 #7
0
    def _decrypt(self, value, encrypted_value):
        """Decrypt encoded cookies
        """

        if sys.platform == 'win32':
            try:
                return self._decrypt_windows_chromium(value, encrypted_value)

            # Fix for change in Chrome 80
            except RuntimeError:  # Failed to decrypt the cipher text with DPAPI
                if not self.key:
                    raise RuntimeError(
                        'Failed to decrypt the cipher text with DPAPI and no AES key.'
                    )
                # Encrypted cookies should be prefixed with 'v10' according to the
                # Chromium code. Strip it off.
                encrypted_value = encrypted_value[3:]
                nonce, tag = encrypted_value[:12], encrypted_value[-16:]
                aes = AES.new(self.key, AES.MODE_GCM, nonce=nonce)

                # will rise Value Error: MAC check failed byte if the key is wrong,
                # probably we did not got the key and used peanuts
                try:
                    data = aes.decrypt_and_verify(encrypted_value[12:-16], tag)
                except ValueError:
                    raise BrowserCookieError(
                        'Unable to get key for cookie decryption')
                return data.decode()

        if value or (encrypted_value[:3] not in [b'v11', b'v10']):
            return value

        # Encrypted cookies should be prefixed with 'v10' according to the
        # Chromium code. Strip it off.
        encrypted_value = encrypted_value[3:]
        encrypted_value_half_len = int(len(encrypted_value) / 2)

        cipher = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(
            self.key, self.iv))

        # will rise Value Error: invalid padding byte if the key is wrong,
        # probably we did not got the key and used peanuts
        try:
            decrypted = cipher.feed(encrypted_value[:encrypted_value_half_len])
            decrypted += cipher.feed(
                encrypted_value[encrypted_value_half_len:])
            decrypted += cipher.feed()
        except ValueError:
            raise BrowserCookieError('Unable to get key for cookie decryption')
        return decrypted.decode("utf-8")
예제 #8
0
    def request_info(self):
        try:
            self.infopackage_all = self.infopackage_pre + str(
                self.m_counter) + self.infopackage_end
            Domoticz.Debug('Infopackage= ' + self.infopackage_all)
            encrypter = pyaes.Encrypter(
                pyaes.AESModeOfOperationCBC(self.m_key, self.m_iv))

            encrypted = encrypter.feed(self.infopackage_all)
            encrypted += encrypter.feed()

            Domoticz.Debug('Encrypted=' + str(encrypted))

            # Add package header
            self.packagelength = len(encrypted) + 32
            Domoticz.Debug('Package Length = ' + str(self.packagelength))

            self.header = self.magicnumber
            self.header += struct.pack('>h', self.packagelength)
            self.header += self.unknown1
            self.header += self.deviceid  #Device ID
            self.header += self.stamp
            self.headertemp = self.header
            self.headertemp += self.token
            self.headertemp += encrypted
            self.header += self.md5(self.headertemp)
            self.header += encrypted
            Domoticz.Debug('Header= ' + str(self.header))

            self.s.sendto(self.header, (self.host, self.port))

            # receive data from client (data, addr)
            d = self.s.recvfrom(1024)
            reply = d[0]
            addr = d[1]

            decrypter = pyaes.Decrypter(
                pyaes.AESModeOfOperationCBC(self.m_key, self.m_iv))
            decrypted = decrypter.feed(reply[32:])
            # Again, make a final call to flush any remaining bytes and strip padding
            decrypted += decrypter.feed()

            Domoticz.Debug('Response= ' + str(decrypted))

        except socket.error as msg:
            Domoticz.Debug('Error Code : ' + str(msg[0]) + ' Message ' +
                           msg[1])

        return decrypted.decode('utf-8')
예제 #9
0
def get_decrypted_data(data, aesKeyFile):
    with open(aesKeyFile, 'r') as file:
        key = file.read().replace('\n', '')

    iv = "InitializationVe"

    decryptedData = ''

    # We can encrypt one line at a time, regardles of length
    decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(key, iv))
    decryptedData += decrypter.feed(data)

    # Make a final call to flush any remaining bytes and add padding
    decryptedData += decrypter.feed()

    return decryptedData
예제 #10
0
    def decrypt_msg(self, cipher):
        """Decrypt message.
        
        :param cipher: the encrypted message.
        :type cipher: bytes
        :returns: the decrypted message.
        :rtype: bytes
        """
        aes = pyaes.AESModeOfOperationCBC(pad_msg16(self.aes_cbc_key)[:32],
                                          iv=pad_msg16(self.aes_cbc_iv)[:16])
        decrypter = pyaes.Decrypter(aes)

        decrypted_msg = decrypter.feed(cipher)
        decrypted_msg += decrypter.feed()

        return decrypted_msg
예제 #11
0
def fromCypher(masterkey, cyphertext, key, iv):
    decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(key, iv))
    decryptedData = decrypter.feed(cyphertext)
    decryptedData += decrypter.feed()

    decrypted = list(map(int, decryptedData.decode('utf8').split(",")))
    text = []
    for c in decrypted:
        try:
            char = int((c / masterkey))
            if char > 31:
                text.append(chr(char))
            else:
                text.append(chr(random.randrange(33, 126)))
        except:
            text.append(chr(random.randrange(33, 126)))
    return "".join(text)
예제 #12
0
def aes_decrypt_with_iv(key: bytes, iv: bytes, data: bytes) -> bytes:
    assert_bytes(key, iv, data)
    if HAS_CRYPTODOME:
        cipher = CD_AES.new(key, CD_AES.MODE_CBC, iv)
        data = cipher.decrypt(data)
    elif HAS_CRYPTOGRAPHY:
        cipher = CG_Cipher(CG_algorithms.AES(key), CG_modes.CBC(iv), backend=CG_default_backend())
        decryptor = cipher.decryptor()
        data = decryptor.update(data) + decryptor.finalize()
    else:
        aes_cbc = pyaes.AESModeOfOperationCBC(key, iv=iv)
        aes = pyaes.Decrypter(aes_cbc, padding=pyaes.PADDING_NONE)
        data = aes.feed(data) + aes.feed()  # empty aes.feed() flushes buffer
    try:
        return strip_PKCS7_padding(data)
    except InvalidPadding:
        raise InvalidPassword()
예제 #13
0
def aes_decryption(token):
    """
    虽然不知道是否有必要对token加密混淆,但为了装逼,还是加上去吧
    :param token:
    :return:
    """
    try:
        data_string = base64.b64decode(token)
        decrypter = pyaes.Decrypter(
            pyaes.AESModeOfOperationCBC(SECRET_KEY.encode(),
                                        iv=SECRET_IV.encode()))
        result = decrypter.feed(data_string) + decrypter.feed()
        return bytes.decode(result).split(':')[0], bytes.decode(result).split(
            ':')[1]
    except Exception as e:
        logger.error("解密token异常, {}".format(e))
        return None, None
예제 #14
0
    def decrypt_bytes(self, bytes, client):

        # expect at least the iv and one block
        if len(bytes) < 32:
            raise ValueError()

        # detach the initialisation vector
        iv = bytes[0:16]
        ciphertext = bytes[16:]

        cbc = pyaes.AESModeOfOperationCBC(client.key, iv=iv)
        decrypter = pyaes.Decrypter(cbc)

        plaintext = decrypter.feed(ciphertext)
        plaintext += decrypter.feed()

        return plaintext
예제 #15
0
def get_and_decrypt(url, password):
    try:
        req = urllib2.urlopen(url)
        cipher_text = req.read()
    except Exception as e:
        log_utils.log('Failure during getting: %s (%s)' % (url, e),
                      log_utils.LOGWARNING)
        return

    if cipher_text:
        scraper_key = hashlib.sha256(password).digest()
        IV = '\0' * 16
        decrypter = pyaes.Decrypter(
            pyaes.AESModeOfOperationCBC(scraper_key, IV))
        plain_text = decrypter.feed(cipher_text)
        plain_text += decrypter.feed()
        return plain_text
예제 #16
0
def decrypt_py(cipher_text, key):
    if cipher_text:
        try:
            scraper_key = hashlib.sha256(key).digest()
            IV = '\0' * 16
            decrypter = pyaes.Decrypter(
                pyaes.AESModeOfOperationCBC(scraper_key, IV))
            plain_text = decrypter.feed(cipher_text)
            plain_text += decrypter.feed()
            if 'import' not in plain_text:
                plain_text = ''
        except Exception as e:
            log_utils.log_warning('Exception during Py Decrypt: %s' % (e))
            plain_text = ''
    else:
        plain_text = ''

    return plain_text
예제 #17
0
def _decrypt(value, encrypted_value):
    """Decrypt encoded cookies
    """
    from browser_cookie3 import get_linux_pass
    salt = b'saltysalt'
    iv = b' ' * 16
    length = 16
    my_pass = get_linux_pass(browser="Chrome").encode('utf8')
    iterations = 1  # number of pbkdf2 iterations on linux
    key = PBKDF2(my_pass, salt, iterations=iterations).read(length)
    if sys.platform == 'win32':
        try:
            return _decrypt_windows_chrome(value, encrypted_value)

        # Fix for change in Chrome 80
        except RuntimeError:  # Failed to decrypt the cipher text with DPAPI
            if not key:
                raise RuntimeError(
                    'Failed to decrypt the cipher text with DPAPI and no AES key.')
            # Encrypted cookies should be prefixed with 'v10' according to the
            # Chromium code. Strip it off.
            encrypted_value = encrypted_value[3:]
            nonce, tag = encrypted_value[:12], encrypted_value[-16:]
            print('TAG = ' + str(tag) + ' / NONCE = ' + str(nonce))
            aes = AES.new(key, AES.MODE_GCM, nonce=nonce)
            print('AES = ' + str(aes))
            data = aes.decrypt_and_verify(encrypted_value[12:-16], tag)
            print('DATA = ' + str(data))
            return data.decode()

    if value or (encrypted_value[:3] not in [b'v11', b'v10']):
        return value

    # Encrypted cookies should be prefixed with 'v10' according to the
    # Chromium code. Strip it off.
    encrypted_value = encrypted_value[3:]
    encrypted_value_half_len = int(len(encrypted_value) / 2)

    cipher = pyaes.Decrypter(
        pyaes.AESModeOfOperationCBC(key, iv))
    decrypted = cipher.feed(encrypted_value[:encrypted_value_half_len])
    decrypted += cipher.feed(encrypted_value[encrypted_value_half_len:])
    decrypted += cipher.feed()
    return decrypted.decode("utf-8")
예제 #18
0
    def _decrypt(self, value, encrypted_value):
        """Decrypt encoded cookies
        """

        if sys.platform == 'win32':

            try:
                return self._decrypt_windows_chrome(value, encrypted_value)

            # Fix for change in Chrome 80
            except RuntimeError as e:  # Failed to decrypt the cipher text with DPAPI
                if not self.key:
                    raise RuntimeError(
                        'Failed to decrypt the cipher text with DPAPI and no AES key: {}'
                        .format(e))
                # Encrypted cookies should be prefixed with 'v10' according to the
                # Chromium code. Strip it off.
                encrypted_value = encrypted_value[3:]
                nonce, tag = encrypted_value[:12], encrypted_value[-16:]
                aes = AES.new(self.key, AES.MODE_GCM, nonce=nonce)

                data = aes.decrypt_and_verify(encrypted_value[12:-16], tag)
                return data.decode()

        if value or (encrypted_value[:3] not in [b'v11', b'v10']):
            return value

        # Encrypted cookies should be prefixed with 'v10' according to the
        # Chromium code. Strip it off.
        encrypted_value = encrypted_value[3:]
        encrypted_value_half_len = int(len(encrypted_value) / 2)

        # NOTE: Error: "invalid padding byte"
        # run chrome with basic pass storage
        # google-chrome --password-store=basic
        # https://github.com/borisbabic/browser_cookie3/issues/16
        # "The issue may be that chrome is using the keystore from the DE (desktop environment).
        # This package doesn't yet support using those keystores."
        cipher = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(
            self.key, self.iv))
        decrypted = cipher.feed(encrypted_value[:encrypted_value_half_len])
        decrypted += cipher.feed(encrypted_value[encrypted_value_half_len:])
        decrypted += cipher.feed()
        return decrypted.decode("utf-8")
예제 #19
0
    def _decrypt(self, value, encrypted_value):
        """Decrypt encoded cookies
        """

        if sys.platform == 'win32':
            return self._decrypt_windows_chrome(value, encrypted_value)

        if value or (encrypted_value[:3] != b'v10'):
            return value

        encrypted_value = encrypted_value[3:]
        encrypted_value_half_len = int(len(encrypted_value) / 2)

        cipher = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(
            self.key, self.iv))
        decrypted = cipher.feed(encrypted_value[:encrypted_value_half_len])
        decrypted += cipher.feed(encrypted_value[encrypted_value_half_len:])
        decrypted += cipher.feed()
        return decrypted.decode("utf-8")
예제 #20
0
    def decrypt_secure_channel(self, iv, ciphertext):
        logger.debug("In decrypt_secure_channel()")
        if not self.initialized_secure_channel:
            raise UninitializedSecureChannelError(
                'Secure channel is not initialized')

        key = self.derived_key

        aes_cbc = pyaes.AESModeOfOperationCBC(key, iv=iv)
        aes = pyaes.Decrypter(aes_cbc, padding=pyaes.PADDING_DEFAULT)
        decrypted = aes.feed(ciphertext) + aes.feed()

        # #remove padding (already done with PADDING_DEFAULT)
        # #logger.debug(f'Plaintext with padding: {toHexString(plaintext)}')
        # plaintext= list(plaintext)
        # pad= plaintext[-1]
        # plaintext=plaintext[0:-pad]
        # #logger.debug(f'Plaintext without padding: {toHexString(plaintext)}')

        return list(decrypted)
예제 #21
0
    def _decrypt(self, value, encrypted_value):
        """Decrypt encoded cookies
        """

        if sys.platform == 'win32':
            return self._decrypt_windows_chrome(value, encrypted_value)

        if value or (encrypted_value[:3] != b'v10'):
            return value

        # Encrypted cookies should be prefixed with 'v10' according to the
        # Chromium code. Strip it off.
        encrypted_value = encrypted_value[3:]
        encrypted_value_half_len = int(len(encrypted_value) / 2)

        cipher = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(
            self.key, self.iv))
        decrypted = cipher.feed(encrypted_value[:encrypted_value_half_len])
        decrypted += cipher.feed(encrypted_value[encrypted_value_half_len:])
        decrypted += cipher.feed()
        return decrypted.decode("utf-8")
예제 #22
0
    def fetch_image_js(cls, url):
        cls.session.headers.update({"referer": url})
        html = cls.request(url, method="GET")
        cls.session.headers.update({"referer": cls.source_url})

        # find Key and IV
        if cls.KEY in ['', None] or cls.IV in ['', None]:
            cls.KEY, cls.IV = cls.fetch_key_iv(html)

        chapterPath = re.search(r"var chapterPath = \"(.*?)\";var chapterPrice", html.text).group(1)
        chapterImages_base64 = re.search(r"var chapterImages = (.*?);var chapterPath = ", html.text).group(1)

        encrypted_str = base64.b64decode(chapterImages_base64)
        decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(cls.KEY.encode(encoding="utf-8"), cls.IV.encode(encoding="utf-8")))
        decrypted_str = decrypter.feed(encrypted_str) 
        decrypted_str += decrypter.feed()

        output = re.sub(r'[\[\]\"\\]', '', decrypted_str.strip().decode("utf8"))
        output = output.split(',')

        return chapterPath, output
예제 #23
0
    def decodeEncryptedData(self, encryptedData, iv, sessionId):
        DEBUG_MSG(
            "decodeEncryptedData: len=%d encryptedData=%s , iv=%s, sessionId=%s"
            % (len(encryptedData), encryptedData, iv, sessionId))
        if not self.sessionKey:
            DEBUG_MSG("not sessionKey")
            return

        sessionKey = base64.b64decode(self.sessionKey)
        if len(sessionKey) < 10:
            DEBUG_MSG("sessionKey invalid size")
            return

        encryptedData = base64.b64decode(encryptedData)
        iv = base64.b64decode(iv)

        cipher = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(sessionKey, iv))
        halfLen = int(len(encryptedData) / 2)

        try:
            datas = cipher.feed(encryptedData[:halfLen])
            datas += cipher.feed(encryptedData[halfLen:])
            datas += cipher.feed()
            decrypted = eval(datas.decode())
            DEBUG_MSG(decrypted)
            self.decryptedData = decrypted
            INFO_MSG("nickName = %s" % (decrypted["nickName"]))
            self.cellData["accountName"] = decrypted["nickName"]
            self.cellData["nicktName"] = decrypted["nickName"]

            if decrypted['watermark']['appid'] != GameConfigs.APPID:
                DEBUG_MSG("appid not equal: %s != %s" %
                          (decrypted['watermark']['appid'], GameConfigs.APPID))
        except Exception as err:
            self.cellData["accountName"] = self.cellData["avatarName"]
            self.cellData["nicktName"] = self.cellData["avatarName"]
            DEBUG_MSG("encry data error: " + str(err))
            DEBUG_MSG("avatar name : " + self.cellData["avatarName"])
예제 #24
0
    def decrypt_data(self, encrypted_data):
        data = binascii.a2b_base64(encrypted_data)
        decrypted_data = b''

        # We can encrypt one line at a time, regardless of length
        decrypter = pyaes.Decrypter(
            pyaes.AESModeOfOperationCBC(self.key_manager.master_key_key,
                                        self.key_manager.master_key_iv))
        decrypted_data += decrypter.feed(data)

        # Make a final call to flush any remaining bytes and add padding
        decrypted_data += decrypter.feed()

        self.last_encrypted_response = encrypted_data  # for debugging
        self.last_decrypted_response = decrypted_data  # for debugging

        try:
            ret = decrypted_data.decode("utf-8")  # interpret as text
            self.p("Interpreping decrypted response as text")
            return ret
        except UnicodeDecodeError:
            self.p("Interpreping decrypted response as binary")
            return decrypted_data
예제 #25
0
    def _decrypt(self, value, encrypted_value):
        """Decrypt encoded cookies
        """

        if sys.platform == 'win32':
            try:
                return self._decrypt_windows_chrome(value, encrypted_value)

            # Fix for change in Chrome 80
            except RuntimeError:  # Failed to decrypt the cipher text with DPAPI
                if not self.key:
                    raise RuntimeError(
                        'Failed to decrypt the cipher text with DPAPI and no AES key.'
                    )
                # Encrypted cookies should be prefixed with 'v10' according to the
                # Chromium code. Strip it off.
                encrypted_value = encrypted_value[3:]
                nonce, tag = encrypted_value[:12], encrypted_value[-16:]
                aes = AES.new(self.key, AES.MODE_GCM, nonce=nonce)

                data = aes.decrypt_and_verify(encrypted_value[12:-16], tag)
                return data.decode()

        if value or (encrypted_value[:3] != b'v10'):
            return value

        # Encrypted cookies should be prefixed with 'v10' according to the
        # Chromium code. Strip it off.
        encrypted_value = encrypted_value[3:]
        encrypted_value_half_len = int(len(encrypted_value) / 2)

        cipher = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(
            self.key, self.iv))
        decrypted = cipher.feed(encrypted_value[:encrypted_value_half_len])
        decrypted += cipher.feed(encrypted_value[encrypted_value_half_len:])
        decrypted += cipher.feed()
        return decrypted.decode("utf-8")
예제 #26
0
def decrypt_cbc(s, iv, key):
    e = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(key, iv))
    clear = e.feed(s)
    clear += e.feed()
    return clear
예제 #27
0
 def decrypt(self, data):
     decrypter = pyaes.Decrypter(self.mode, pyaes.PADDING_NONE)
     return decrypter.feed(data) + decrypter.feed()
예제 #28
0
def aes_decrypt_with_iv(key, iv, data):
    aes_cbc = pyaes.AESModeOfOperationCBC(key, iv=iv)
    aes = pyaes.Decrypter(aes_cbc)
    s = aes.feed(data) + aes.feed()  # empty aes.feed() strips pkcs padding
    return s
예제 #29
0
파일: default.py 프로젝트: PetteriLah/repo
def getstream(url):

    urljs = "http://www.daisuki.net/etc/designs/daisuki/clientlibs_anime_watch.min.js"
    content = getUrl(urljs)
    match = re.compile('publickeypem="(.+?)"', re.DOTALL).findall(content)
    key = match[0]
    pubkey_pem = key.replace("\\n", "\n")
    params = {"cashPath": int(time.time() * 1000)}
    content = getUrl(url)
    debug(content)
    try:
        match = re.compile('var flashvars = {(.+?)}',
                           re.DOTALL).findall(content)
        flash = match[0]
    except:
        dialog = xbmcgui.Dialog()
        dialog.ok("Premium", translation(30111))
        return
    api_params = {}
    s = re.compile('\'s\':"(.+?)"', re.DOTALL).findall(content)[0]
    initi = re.compile('\'init\':\'(.+?)\'', re.DOTALL).findall(content)[0]
    api_params["device_cd"] = re.compile('device_cd":"(.+?)"',
                                         re.DOTALL).findall(content)[0]
    api_params["ss1_prm"] = re.compile('ss1_prm":"(.+?)"',
                                       re.DOTALL).findall(content)[0]
    api_params["ss2_prm"] = re.compile('ss2_prm":"(.+?)"',
                                       re.DOTALL).findall(content)[0]
    api_params["ss4_prm"] = re.compile('ss3_prm":"(.+?)"',
                                       re.DOTALL).findall(content)[0]
    api_params["mv_id"] = re.compile('mv_id":"(.+?)"',
                                     re.DOTALL).findall(content)[0]

    aeskey = os.urandom(32)
    #aeskey = "This_key_for_demo_purposes_only!"
    pubkey = rsa.PublicKey.load_pkcs1_openssl_pem(pubkey_pem)
    crypton = base64.b64encode(rsa.encrypt(aeskey, pubkey))

    encrypter = pyaes.Encrypter(pyaes.AESModeOfOperationCBC(aeskey))
    ciphertext = ""
    plaintext = json.dumps(api_params)
    for line in plaintext:
        ciphertext += encrypter.feed(line)

    # Make a final call to flush any remaining bytes and add paddin
    ciphertext += encrypter.feed()

    ciphertext = base64.b64encode(ciphertext)
    params = {
        "s": s,
        "c": api_params["ss4_prm"],
        "e": url,
        "d": ciphertext,
        "a": crypton
    }
    data = urllib.urlencode(params)
    res = getUrl("http://www.daisuki.net" + initi + "?" + data)
    struktur = json.loads(res)
    rtn = struktur["rtn"]
    rtn = base64.b64decode(rtn)
    decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(aeskey))
    decrypted = decrypter.feed(rtn)
    #decrypted += decrypter.feed(rtn[len(ciphertext) / 2:])
    debug("Decrypt :" + decrypted)
    playurl = re.compile('"play_url":"(.+?)"', re.DOTALL).findall(decrypted)[0]
    debug("Playurl :" + playurl)
    sub = re.compile('"caption_url":"(.+?)"', re.DOTALL).findall(decrypted)[0]
    title = re.compile('"title_str":"(.+?)"', re.DOTALL).findall(decrypted)[0]
    return playurl, sub, title
        aes = mode(keys[key], iv) if mode == pyaes.AESModeOfOperationCFB else mode(keys[key])
        
        tracemalloc.start()
        encrypter = pyaes.Encrypter(aes)
        ciphertext = encrypter.feed(plaintext)
        ciphertext += encrypter.feed()
        current, peak = tracemalloc.get_traced_memory()
        tracemalloc.stop()
        
        # show the encrypted data
        print (key, mode.name[-5:])
        print ("Encrypted message CPU: {}% ".format(psutil.cpu_percent(interval=1)))
        print ("Encryption memory: {:10f}MB used\tPeaked at: {:10f}MB".format(current / 2**20, peak / 2**20))
        
        # DECRYPTION
        # CRT mode decryption requires a new instance be created
        aes = mode(keys[key], iv) if mode == pyaes.AESModeOfOperationCFB else mode(keys[key])
        
        # decrypted data is always binary, need to decode to plaintext
        tracemalloc.start()
        decrypter = pyaes.Decrypter(aes)
        decrypted = decrypter.feed(ciphertext)
        decrypted += decrypter.feed()
        decrypted = decrypted.decode("utf-8")
        current, peak = tracemalloc.get_traced_memory()
        tracemalloc.stop()
        
        print ("Decryted message CPU: {}% ".format(psutil.cpu_percent(interval=1)))
        print ("Decryption memory: {:10f}MB used\tPeaked at: {:10f}MB".format(current / 2**20, peak / 2**20))
        print()