コード例 #1
0
    def get_urls(self):
        """Extract all URLs embedded in this file through a simple regex."""
        if not os.path.getsize(self.file_path):
            return []

        # http://stackoverflow.com/a/454589
        urls, f = set(), open(self.file_path, "rb")
        for url in re.findall(URL_REGEX, self.mmap(f.fileno())):
            if not is_whitelisted_domain(url[1]):
                urls.add("".join(url))
        return list(urls)
コード例 #2
0
ファイル: objects.py プロジェクト: neveralso/cuckoo
    def get_urls(self):
        """Extract all URLs embedded in this file through a simple regex."""
        if not os.path.getsize(self.file_path):
            return []

        # http://stackoverflow.com/a/454589
        urls, f = set(), open(self.file_path, "rb")
        for url in re.findall(URL_REGEX, self.mmap(f.fileno())):
            if not is_whitelisted_domain(url[1]):
                urls.add("".join(url))
        return list(urls)
コード例 #3
0
ファイル: network.py プロジェクト: fbusta/cuckoo
    def _is_whitelisted(self, conn, hostname):
        """Checks if whitelisting conditions are met"""
        # Is whitelistng enabled?
        if not self.whitelist_enabled:
            return False

        # Is DNS recording coming from allowed NS server.
        if not self.known_dns:
            pass
        elif (conn.get("src") in self.known_dns or
              conn.get("dst") in self.known_dns):
            pass
        else:
            return False

        # Is hostname whitelisted.
        if not is_whitelisted_domain(hostname):
            return False

        return True
コード例 #4
0
ファイル: network.py プロジェクト: hatching/cuckoo-ekhunting
    def _is_whitelisted(self, conn, hostname):
        """Checks if whitelisting conditions are met"""
        # Is whitelistng enabled?
        if not self.whitelist_enabled:
            return False

        # Is DNS recording coming from allowed NS server.
        if not self.known_dns:
            pass
        elif (conn.get("src") in self.known_dns
              or conn.get("dst") in self.known_dns):
            pass
        else:
            return False

        # Is hostname whitelisted.
        if not is_whitelisted_domain(hostname):
            return False

        return True
コード例 #5
0
ファイル: test_utils.py プロジェクト: frank2411/cuckoo_dev
def test_is_whitelisted_domain():
    assert is_whitelisted_domain("java.com") is True
    assert is_whitelisted_domain("java2.com") is False
    assert is_whitelisted_domain("crl.microsoft.com") is True
コード例 #6
0
ファイル: test_utils.py プロジェクト: consen/cuckoo
def test_is_whitelisted_domain():
    assert is_whitelisted_domain("java.com") is True
    assert is_whitelisted_domain("java2.com") is False
    assert is_whitelisted_domain("crl.microsoft.com") is True