当前位置: 首页>>代码示例>>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;未经允许,请勿转载。