Example #1
0
def flush_hail():
    hail = Hail()
    try:
        hail.dump_now()
    except Exception as e:
        return str(e)
    return 'OK'
Example #2
0
def flush_hail():
    hail = Hail()
    try:
        hail.dump_now()
    except Exception as e:
        return str(e)
    return 'OK'
Example #3
0
def flush_hail():
    hail = Hail()
    try:
        hail.dump_now()
    except Exception as e:
        return e
    return "OK"
Example #4
0
def tracker():
    from periods import Period
    import random
    params = default_params()
    # LOLOL THIS SHOULD REALLY CHANGE
    key = hashlib.sha256('hailwhale_weak_key').digest()
    if 'pk' not in req.GET and 'pixel' in req.GET:
        from Crypto.Cipher import AES
        from base64 import b64encode, b64decode
        from urllib import quote_plus

        mode = AES.MODE_CBC
        encryptor = AES.new(key, mode)
        text = g('pixel')
        INTERRUPT = u'\u0001'
        PAD = u'\u0000'

        # Since you need to pad your data before encryption,
        # create a padding function as well
        # Similarly, create a function to strip off the padding after decryption
        def AddPadding(data, interrupt, pad, block_size):
            new_data = ''.join([data, interrupt])
            new_data_len = len(new_data)
            remaining_len = block_size - new_data_len
            to_pad_len = remaining_len % block_size
            pad_string = pad * to_pad_len
            return ''.join([new_data, pad_string])

        def StripPadding(data, interrupt, pad):
            return data.rstrip(pad).rstrip(interrupt)

        def hw_encoded(t):
            return quote_plus(
                b64encode(encryptor.encrypt(AddPadding(t, INTERRUPT, PAD,
                                                       32))))

        def hw_decoded(t):
            return StripPadding(encryptor.decrypt(b64decode(t)), INTERRUPT,
                                PAD)

        params['pk'] = hw_decoded(text)
    pk = params['pk']
    whale = Whale()
    hail = Hail()
    val = whale.count_now(at=times.now(), **params)
    #val = whale.count_now(**params)
    uid = g('uid')
    if not uid or uid == '_new':
        default = random.randrange(10**6, 10**9)
        uid = str(req.get_cookie('uid', str(default), key))
    hail.spy_log(uid, params)
    response.set_cookie('uid', uid, key)
    return str(uid)
Example #5
0
def tracker():
    from periods import Period
    import random
    params = default_params()
    # LOLOL THIS SHOULD REALLY CHANGE
    key = hashlib.sha256('hailwhale_weak_key').digest()
    if 'pk' not in req.GET and 'pixel' in req.GET:
        from Crypto.Cipher import AES
        from base64 import b64encode, b64decode
        from urllib import quote_plus

        mode = AES.MODE_CBC
        encryptor = AES.new(key, mode)
        text = g('pixel')
        INTERRUPT = u'\u0001'
        PAD = u'\u0000'

        # Since you need to pad your data before encryption,
        # create a padding function as well
        # Similarly, create a function to strip off the padding after decryption
        def AddPadding(data, interrupt, pad, block_size):
            new_data = ''.join([data, interrupt])
            new_data_len = len(new_data)
            remaining_len = block_size - new_data_len
            to_pad_len = remaining_len % block_size
            pad_string = pad * to_pad_len
            return ''.join([new_data, pad_string])
        def StripPadding(data, interrupt, pad):
            return data.rstrip(pad).rstrip(interrupt)
        def hw_encoded(t):
            return quote_plus(b64encode(encryptor.encrypt(AddPadding(t, INTERRUPT, PAD, 32))))
        def hw_decoded(t):
            return StripPadding(encryptor.decrypt(b64decode(t)), INTERRUPT, PAD)
        params['pk'] = hw_decoded(text)
    pk = params['pk']
    whale = Whale()
    hail = Hail()
    val = whale.count_now(at=times.now(), **params)
    #val = whale.count_now(**params)
    uid = g('uid')
    if not uid or uid == '_new':
        default = random.randrange(10**6,10**9)
        uid = str(req.get_cookie('uid', str(default), key))
    hail.spy_log(uid, params)
    response.set_cookie('uid', uid, key)
    return str(uid)
Example #6
0
def count():
    hail = Hail()
    val = hail.count(**default_params())
    return 'OK'
Example #7
0
def count():
    hail = Hail()
    try: val = hail.count(**default_params())
    except Exception as e: return str(e)
    return 'OK'
Example #8
0
def count():
    hail = Hail()
    val = hail.count(**default_params())
    return 'OK'
Example #9
0
 def setUp(self):
     from hail import Hail
     from whale import Whale
     self.hail = Hail()
     self.whale = Whale()