def save_canarydrop(canarydrop=None): """Persist a Canarydrop into the Redis instance. Arguments: canarydrop -- Canarydrop object. """ if not canarydrop: raise ValueError canarytoken = canarydrop.canarytoken db.hmset(KEY_CANARYDROP+canarytoken.value(), canarydrop.serialize()) log.info('Saved canarydrop: {canarydrop}'.format( canarydrop=canarydrop.serialize())) #if the canarydrop is new, save to the timeline if db.zscore(KEY_CANARYDROPS_TIMELINE, canarytoken.value()) == None: current_time = datetime.datetime.utcnow().strftime("%s.%f") db.zadd(KEY_CANARYDROPS_TIMELINE, current_time, canarytoken.value()) if canarydrop['alert_email_recipient']: add_email_token_idx(canarydrop['alert_email_recipient'],canarytoken.value()) if canarydrop['alert_webhook_url']: add_webhook_token_idx(canarydrop['alert_webhook_url'],canarytoken.value())
def save_bitcoin_account(bitcoin_account=None): if not bitcoin_account.get('canarytoken'): raise Exception('Cannot save an Bitcoin account without a canarydrop') key = KEY_BITCOIN_ACCOUNT + bitcoin_account['address'] db.hmset(key, bitcoin_account) db.sadd(KEY_BITCOIN_ACCOUNTS, key) return key
def save_linkedin_account(linkedin_account=None): if not linkedin_account.get('canarytoken'): raise Exception('Cannot save an LinkedIn account without a canarydrop') key = KEY_LINKEDIN_ACCOUNT + linkedin_account['username'] db.hmset(key, linkedin_account) db.sadd(KEY_LINKEDIN_ACCOUNTS, key) return key
def save_bitcoin_account(bitcoin_account=None): if not bitcoin_account.get('canarytoken'): raise Exception('Cannot save an Bitcoin account without a canarydrop') key = KEY_BITCOIN_ACCOUNT+bitcoin_account['address'] db.hmset(key, bitcoin_account) db.sadd(KEY_BITCOIN_ACCOUNTS, key) return key
def save_linkedin_account(linkedin_account=None): if not linkedin_account.get('canarytoken'): raise Exception('Cannot save an LinkedIn account without a canarydrop') key = KEY_LINKEDIN_ACCOUNT+linkedin_account['username'] db.hmset(key, linkedin_account) db.sadd(KEY_LINKEDIN_ACCOUNTS, key) return key
def save_clonedsite_token(clonedsite_token): if not clonedsite_token.get('canarytoken'): raise Exception('Cannot save an imgur token without a canarydrop') key = KEY_CLONEDSITE_TOKEN+clonedsite_token['clonedsite']+':'+\ clonedsite_token['canarytoken'] db.hmset(key, clonedsite_token) db.sadd(KEY_CLONEDSITE_TOKENS, key) return key
def save_imgur_token(imgur_token): if not imgur_token.get('canarytoken'): raise Exception('Cannot save an imgur token without a canarydrop') if not imgur_token.get('count', None): imgur_token['count'] = get_imgur_count(imgur_id=imgur_token['id']) key = KEY_IMGUR_TOKEN + imgur_token['id'] db.hmset(key, imgur_token) db.sadd(KEY_IMGUR_TOKENS, key) return key
def save_imgur_token(imgur_token): if not imgur_token.get('canarytoken'): raise Exception('Cannot save an imgur token without a canarydrop') if not imgur_token.get('count', None): imgur_token['count'] = get_imgur_count(imgur_id=imgur_token['id']) key = KEY_IMGUR_TOKEN+imgur_token['id'] db.hmset(key, imgur_token) db.sadd(KEY_IMGUR_TOKENS, key) return key
def save_canarydrop(canarydrop=None): """Persist a Canarydrop into the Redis instance. Arguments: canarydrop -- Canarydrop object. """ if not canarydrop: raise ValueError canarytoken = canarydrop.canarytoken db.hmset(KEY_CANARYDROP+canarytoken.value(), canarydrop.serialize()) log.msg('Saved canarydrop: {canarydrop}'.format( canarydrop=canarydrop.serialize())) #if the canarydrop is new, save to the timeline if db.zscore(KEY_CANARYDROPS_TIMELINE, canarytoken.value()) == None: current_time = datetime.datetime.utcnow().strftime("%s.%f") db.zadd(KEY_CANARYDROPS_TIMELINE, current_time, canarytoken.value())
def save_certificate(key, cert_obj): db.hmset("{}{}".format(KEY_KUBECONFIG_CERTS, key), cert_obj)