cli/streamingphish/streamingphish/predictor.py
def _certstream_mode(self, message, context):
        """
        Deploys loaded classifier against certstream feed.

        Args:
            message (dictionary): SSL certificate and contextual information (cert chain,
                log it came from, etc).
            context (?): I actually don't know, this is from the certstream callback docs.
        """
        if message['message_type'] == "heartbeat":
            return

        if message['message_type'] == "certificate_update":
            # Get all domains, and remove any duplicates of a wildcard domain.
            # A domain being a wildcard could factor into the scoring, but ignore for now.
            hosts = message['data']['leaf_cert']['all_domains']
            for host in hosts:
                if host.startswith('*.') and host[2:] in hosts:
                    hosts.remove(host[2:])

            try:
                scores = self._score(hosts)
            except Exception as error:
                # Write to system.log, assign prediction score of 0, continue.
                logging.error("{}: {}".format(error, message))
                scores = ([0] * len(hosts))

            # For each host, evaluate score, print to stdout, log, etc.
            for host, score in zip(hosts, scores):

                # Evaluate score from host against each threshold in the config.
                for tier in sorted(self._log_tiers, key=lambda x:
                                   self._log_tiers[x]['threshold'], reverse=True):

                    # If score is above threshold, print to screen, log if enabled,
                    # and break out of this loop to evaluate the next host.
                    if score > self._log_tiers[tier]['threshold']:
                        result = {}
                        result['message'] = message
                        result['color'] = self._log_tiers[tier]['color']
                        result['level'] = tier
                        result['host'] = host
                        result['score'] = score
                        self._print_result(result)
                        # Break, we don't need to iterate through any more thresholds.
                        break

        Deploys loaded classifier against certstream feed.

        Args:
            message (dictionary): SSL certificate and contextual information (cert chain,
                log it came from, etc).
            context (?): I actually don't know, this is from the certstream callback docs.
        
Deploys loaded classifier against certstream feed.
Deploys loaded classifier against certstream feed .
def _certstream_mode(self, message, context):
        if message['message_type'] == "heartbeat":
            return
        if message['message_type'] == "certificate_update":
            hosts = message['data']['leaf_cert']['all_domains']
            for host in hosts:
                if host.startswith('*.') and host[2:] in hosts:
                    hosts.remove(host[2:])
            try:
                scores = self._score(hosts)
            except Exception as error:
                logging.error("{}: {}".format(error, message))
                scores = ([0] * len(hosts))
            for host, score in zip(hosts, scores):
                for tier in sorted(self._log_tiers, key=lambda x:
                                   self._log_tiers[x]['threshold'], reverse=True):
                    if score > self._log_tiers[tier]['threshold']:
                        result = {}
                        result['message'] = message
                        result['color'] = self._log_tiers[tier]['color']
                        result['level'] = tier
                        result['host'] = host
                        result['score'] = score
                        self._print_result(result)
                        break
def _certstream_mode ( self , message , context ) : if message [ 'message_type' ] == "heartbeat" : return if message [ 'message_type' ] == "certificate_update" : hosts = message [ 'data' ] [ 'leaf_cert' ] [ 'all_domains' ] for host in hosts : if host . startswith ( '*.' ) and host [ 2 : ] in hosts : hosts . remove ( host [ 2 : ] ) try : scores = self . _score ( hosts ) except Exception as error : logging . error ( "{}: {}" . format ( error , message ) ) scores = ( [ 0 ] * len ( hosts ) ) for host , score in zip ( hosts , scores ) : for tier in sorted ( self . _log_tiers , key = lambda x : self . _log_tiers [ x ] [ 'threshold' ] , reverse = True ) : if score > self . _log_tiers [ tier ] [ 'threshold' ] : result = { } result [ 'message' ] = message result [ 'color' ] = self . _log_tiers [ tier ] [ 'color' ] result [ 'level' ] = tier result [ 'host' ] = host result [ 'score' ] = score self . _print_result ( result ) break
Deploys loaded classifier against certstream feed.
Deploys loaded classifier against certstream feed .
"""
        Deploys loaded classifier against certstream feed.

        Args:
            message (dictionary): SSL certificate and contextual information (cert chain,
                log it came from, etc).
            context (?): I actually don't know, this is from the certstream callback docs.
        """ # Get all domains, and remove any duplicates of a wildcard domain. # A domain being a wildcard could factor into the scoring, but ignore for now. # Write to system.log, assign prediction score of 0, continue. # For each host, evaluate score, print to stdout, log, etc. # Evaluate score from host against each threshold in the config. # If score is above threshold, print to screen, log if enabled, # and break out of this loop to evaluate the next host. # Break, we don't need to iterate through any more thresholds.
self
message
SSL certificate and contextual information (cert chain,
log it came from, etc).
SSL certificate and contextual information ( cert chain log it came from etc ) .
context
I actually don't know, this is from the certstream callback docs.
I actually don ' t know this is from the certstream callback docs .