當前位置: 首頁>>代碼示例>>Python>>正文


Python entropy.shannon_entropy方法代碼示例

本文整理匯總了Python中entropy.shannon_entropy方法的典型用法代碼示例。如果您正苦於以下問題:Python entropy.shannon_entropy方法的具體用法?Python entropy.shannon_entropy怎麽用?Python entropy.shannon_entropy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在entropy的用法示例。


在下文中一共展示了entropy.shannon_entropy方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: max_entropy

# 需要導入模塊: import entropy [as 別名]
# 或者: from entropy import shannon_entropy [as 別名]
def max_entropy(inList):
        """returns the maximum shannon entropy of URIs in the list"""
        try:
            maxEntropy = en.shannon_entropy(inList[0])
        except(IndexError,TypeError,KeyError):
            try:
                maxEntropy = en.shannon_entropy(inList)
            except(TypeError):
                maxEntropy = 0.0

        for uri in inList:
            try:
                if maxEntropy <  en.shannon_entropy(uri):
                    maxEntropy = en.shannon_entropy(uri)
            except(IndexError, TypeError, KeyError):
                print()

        return(maxEntropy) 
開發者ID:jzadeh,項目名稱:aktaion2,代碼行數:20,代碼來源:microbehavior_core_logic.py

示例2: min_entropy

# 需要導入模塊: import entropy [as 別名]
# 或者: from entropy import shannon_entropy [as 別名]
def min_entropy(inList):
        """Returns the minimum shannon entropy of URIs in the list"""
        try:
            minEntropy = en.shannon_entropy(inList[0])
        except(IndexError,TypeError,KeyError):
            try:
                minEntropy = en.shannon_entropy(inList)
            except(TypeError):
                minEntropy = 0.0

        for uri in inList:
            try:
                if minEntropy > en.shannon_entropy(uri):
                    minEntropy = en.shannon_entropy(uri)
            except(IndexError, TypeError, KeyError):
                print()

        return(minEntropy) 
開發者ID:jzadeh,項目名稱:aktaion2,代碼行數:20,代碼來源:microbehavior_core_logic.py

示例3: score_domain

# 需要導入模塊: import entropy [as 別名]
# 或者: from entropy import shannon_entropy [as 別名]
def score_domain(config, domain, args):
    """ """
    score = 0

    for t in config["tlds"]:
        if domain.endswith(t):
            score += 20

    try:
        res = get_tld(domain, as_object=True, fail_silently=True, fix_protocol=True)

        if res is not None:
            domain = '.'.join([res.subdomain, res.domain])
    except Exception as err:
        message_failed(args, err, domain)
        pass

    score += int(round(entropy.shannon_entropy(domain)*50))

    domain          = unconfuse(domain)
    words_in_domain = re.split(r"\W+", domain)

    if words_in_domain[0] in ["com", "net", "org"]:
        score += 10

    for word in config["keywords"]:
        if word in domain:
            score += config["keywords"][word]

    for key in [k for (k,s) in config["keywords"].items() if s >= 70]:
        for word in [w for w in words_in_domain if w not in ["email", "mail", "cloud"]]:
            if distance(str(word), str(key)) == 1:
                score += 70

    if "xn--" not in domain and domain.count("-") >= 4:
        score += domain.count("-") * 3

    if domain.count(".") >= 3:
        score += domain.count(".") * 3
    return score 
開發者ID:ecstatic-nobel,項目名稱:Analyst-Arsenal,代碼行數:42,代碼來源:commons.py

示例4: process

# 需要導入模塊: import entropy [as 別名]
# 或者: from entropy import shannon_entropy [as 別名]
def process(self):
        # print("SECTIONS")
        # logging.debug("loading pefile")
        pelib = self._getLibrary(PEFileModule().getName())
        if(pelib is None):
            return ""

        # logging.debug("iterating sections")
        ret = []
        number = 0

        for section in pelib.sections:
            # print(section)
            dic_sec = {}
            dic_sec["name"] = repr(section.Name)

            dic_sec["size_raw_data"] = int(hex(section.SizeOfRawData), 16)
            dic_sec["virtual_size"] = int(hex(section.Misc_VirtualSize), 16)
            dic_sec["characteristics"] = hex(section.Characteristics)

            if (section.__dict__.get('IMAGE_SCN_MEM_WRITE', False) and
                    section.__dict__.get('IMAGE_SCN_MEM_EXECUTE', False)):
                dic_sec["write_executable"] = "True"
            else:
                dic_sec["write_executable"] = "False"

            data = section.get_data()
            # logging.debug("calculating hashes")
            dic_sec["sha1"] = SHA1(data)
            dic_sec["sha2"] = SHA256(data)
            dic_sec["md5"] = MD5(data)
            # logging.debug("calculating fuzzy")
            dic_sec["fuzzy_hash"] = getSsdeep(data)
            dic_sec["entropy"] = entropy.shannon_entropy(data) * 8
            # logging.debug("finished calculating")

            ret.append(dic_sec)

        return ret 
開發者ID:codexgigassys,項目名稱:codex-backend,代碼行數:41,代碼來源:SectionsPlug.py

示例5: process

# 需要導入模塊: import entropy [as 別名]
# 或者: from entropy import shannon_entropy [as 別名]
def process(self):
        res = entropy.shannon_entropy(self.sample.getBinary()) * 8
        return res 
開發者ID:codexgigassys,項目名稱:codex-backend,代碼行數:5,代碼來源:EntropyPlug.py

示例6: entropy

# 需要導入模塊: import entropy [as 別名]
# 或者: from entropy import shannon_entropy [as 別名]
def entropy(s):
    return shannon_entropy(s) 
開發者ID:tbarabosch,項目名稱:quincy,代碼行數:4,代碼來源:memory_high_entropy_areas.py

示例7: score_domain

# 需要導入模塊: import entropy [as 別名]
# 或者: from entropy import shannon_entropy [as 別名]
def score_domain(provided_ioc):
    """Return the scores of the provided domain."""
    score = 0

    for suspicious_tld in suspicious["tlds"]:
        if provided_ioc.endswith(suspicious_tld):
            score += 20

    try:
        res    = tld.get_tld(provided_ioc, as_object=True, fail_silently=True,
                             fix_protocol=True)
        domain = ".".join([res.subdomain, res.domain])
    except Exception:
        domain = provided_ioc

    score += int(round(entropy.shannon_entropy(domain)*50))
    domain = confusables.unconfuse(domain)
    words_in_domain = re.split("\W+", domain)


    if domain.startswith("*."):
        domain = domain[2:]

        if words_in_domain[0] in ["com", "net", "org"]:
            score += 10

    for word in suspicious["keywords"]:
        if word in domain:
            score += suspicious["keywords"][word]

    for key in [k for k, v in suspicious["keywords"].items() if v >= 70]:
        for word in [w for w in words_in_domain if w not in ["email", "mail", "cloud"]]:
            if pylev.levenshtein(str(word), str(key)) == 1:
                score += 70

    if "xn--" not in domain and domain.count("-") >= 4:
        score += domain.count("-") * 3

    if domain.count(".") >= 3:
        score += domain.count(".") * 3
    return score 
開發者ID:ecstatic-nobel,項目名稱:OSweep,代碼行數:43,代碼來源:phishing_catcher.py


注:本文中的entropy.shannon_entropy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。