Ejemplo n.º 1
0
                right = mid - 1
        else:
            return None

        self._match = match
        # on bin match, recursively call to check host ids
        if (not recursion):
            return self._bin_search((rh_id, 0), recursion=True)

        return DNS_CAT(match)

    # grabbing the request category and determining whether the request should be blocked. if so, returns general
    # information for further processing
    def _block_query(self, category, whitelisted):
        # signature match, but blocking disabled for the category | ALLOW
        if (category not in self._Proxy.signatures.en_dns):
            return False

        # signature match, not whitelisted, or whitelisted and cat is bad | BLOCK
        if (not whitelisted or category in ['malicious', 'cryptominer']):
            return True

        # default action | ALLOW
        return False


if __name__ == '__main__':
    Log.run(name=LOG_NAME, verbose=VERBOSE, root=ROOT)
    DNSProxy.run(Log, threaded=True)
    DNSServer.run(Log, threaded=True)
Ejemplo n.º 2
0
        return DNS_REQUEST_RESULTS(False, None, None)

    # # grabbing the request category and determining whether the request should be blocked. if so, returns general
    # # information for further processing
    def _block_query(self, category, whitelisted):
        # signature match, but blocking disabled for the category | ALLOW
        if (category not in self._Proxy.signatures.en_dns):
            return False

        # signature match, not whitelisted, or whitelisted and cat is bad | BLOCK
        if (not whitelisted
                or category in [DNS_CAT.malicious, DNS_CAT.cryptominer]):
            return True

        # default action | ALLOW
        return False


if __name__ == '__main__':
    dns_cat_signatures = Configuration.load_dns_signature_bitmap()

    # using cython function factory to create binary search function with module specific signatures
    signature_bounds = (0, len(dns_cat_signatures) - 1)

    _recursive_binary_search = generate_recursive_binary_search(
        dns_cat_signatures, signature_bounds)

    Log.run(name=LOG_NAME)
    DNSProxy.run(Log, threaded=True)
    DNSServer.run(Log, threaded=False)