Esempio n. 1
0
def server_config_flask(_config: confdict):
    global server_app
    server_app.secret_key = base64.b32encode(os_urandom(24)).decode("UTF-8")
    server_app.config['PS'] = _config
    server_app.config['SERVER_NAME'] = _config[
        'ORIGIN_DOMAIN_APP'] + ':' + _config['LISTEN_PORT']
    server_app.config['TESTING'] = _config['TESTING']
Esempio n. 2
0
 def _generateToken(self, url):
     url = url.replace('http://redir.atmcdn.pl/http/','')
     SecretKey = 'AB9843DSAIUDHW87Y3874Q903409QEWA'
     iv = 'ab5ef983454a21bd'
     KeyStr = '0f12f35aa0c542e45926c43a39ee2a7b38ec2f26975c00a30e1292f7e137e120e5ae9d1cfe10dd682834e3754efc1733'
     salt = sha1()
     salt.update(os_urandom(16))
     salt = salt.hexdigest()[:32]
     tvncrypt = aes_cbc.AES_CBC(SecretKey, base.noPadding(), keySize=32)
     key = tvncrypt.decrypt(binascii.unhexlify(KeyStr), iv=iv)[:32]
     expire = 3600000L + long(time.time()*1000) - 946684800000L
     unencryptedToken = "name=%s&expire=%s\0" % (url, expire)
     pkcs5_pad = lambda s: s + (16 - len(s) % 16) * chr(16 - len(s) % 16)
     pkcs5_unpad = lambda s : s[0:-ord(s[-1])]
     unencryptedToken = pkcs5_pad(unencryptedToken)
     tvncrypt = aes_cbc.AES_CBC(binascii.unhexlify(key), padding=base.noPadding(), keySize=16)
     encryptedToken = tvncrypt.encrypt(unencryptedToken, iv=binascii.unhexlify(salt))
     encryptedTokenHEX = binascii.hexlify(encryptedToken).upper()
     return "http://redir.atmcdn.pl/http/%s?salt=%s&token=%s" % (url, salt, encryptedTokenHEX)
 def _generateToken(self, url):
     url = url.replace('http://redir.atmcdn.pl/http/','')
     SecretKey = 'AB9843DSAIUDHW87Y3874Q903409QEWA'
     iv = 'ab5ef983454a21bd'
     KeyStr = '0f12f35aa0c542e45926c43a39ee2a7b38ec2f26975c00a30e1292f7e137e120e5ae9d1cfe10dd682834e3754efc1733'
     salt = sha1()
     salt.update(os_urandom(16))
     salt = salt.hexdigest()[:32]
     tvncrypt = aes_cbc.AES_CBC(SecretKey, base.noPadding(), keySize=32)
     key = tvncrypt.decrypt(binascii.unhexlify(KeyStr), iv=iv)[:32]
     expire = 3600000L + long(time.time()*1000) - 946684800000L
     unencryptedToken = "name=%s&expire=%s\0" % (url, expire)
     pkcs5_pad = lambda s: s + (16 - len(s) % 16) * chr(16 - len(s) % 16)
     pkcs5_unpad = lambda s : s[0:-ord(s[-1])]
     unencryptedToken = pkcs5_pad(unencryptedToken)
     tvncrypt = aes_cbc.AES_CBC(binascii.unhexlify(key), padding=base.noPadding(), keySize=16)
     encryptedToken = tvncrypt.encrypt(unencryptedToken, iv=binascii.unhexlify(salt))
     encryptedTokenHEX = binascii.hexlify(encryptedToken).upper()
     return "http://redir.atmcdn.pl/http/%s?salt=%s&token=%s" % (url, salt, encryptedTokenHEX)
Esempio n. 4
0
 def __call__(self, N):
     return os_urandom(N)