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


Python pefile.get_sublang_name_for_lang方法代碼示例

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


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

示例1: check_rsrc

# 需要導入模塊: import pefile [as 別名]
# 或者: from pefile import get_sublang_name_for_lang [as 別名]
def check_rsrc(self, pe):
        ret = {}
        if hasattr(pe, 'DIRECTORY_ENTRY_RESOURCE'):
            i = 0
            for resource_type in pe.DIRECTORY_ENTRY_RESOURCE.entries:
                if resource_type.name is not None:
                    name = "%s" % resource_type.name
                else:
                    name = "%s" % pefile.RESOURCE_TYPE.get(resource_type.struct.Id)
                if name == None:
                    name = "%d" % resource_type.struct.Id
                if hasattr(resource_type, 'directory'):
                    for resource_id in resource_type.directory.entries:
                        if hasattr(resource_id, 'directory'):
                            for resource_lang in resource_id.directory.entries:
                                data = pe.get_data(resource_lang.data.struct.OffsetToData, resource_lang.data.struct.Size)
                                filetype = get_filetype(data)
                                lang = pefile.LANG.get(resource_lang.data.lang, '*unknown*')
                                sublang = pefile.get_sublang_name_for_lang( resource_lang.data.lang, resource_lang.data.sublang )
                                ret[i] = (name, resource_lang.data.struct.OffsetToData, resource_lang.data.struct.Size, filetype, lang, sublang)
                                i += 1
        return ret 
開發者ID:omriher,項目名稱:CapTipper,代碼行數:24,代碼來源:pescanner.py

示例2: _parse_resource

# 需要導入模塊: import pefile [as 別名]
# 或者: from pefile import get_sublang_name_for_lang [as 別名]
def _parse_resource(self, type: str, entry, pe) -> Tuple[Dict, bytes]:
        sublang = pefile.get_sublang_name_for_lang(entry.data.lang, entry.data.sublang)
        rva = entry.data.struct.OffsetToData
        size = entry.data.struct.Size
        raw_data = pe.get_data(rva, size)
        metadata = {
            'type': type,
            'resource_id': entry.id,
            'resource_type': entry.data.struct.name,
            'address': rva,
            'offset': pe.get_offset_from_rva(rva),
            'sha256': hashlib.sha256(raw_data).hexdigest(),
            'sha1': hashlib.sha1(raw_data).hexdigest(),
            'md5': hashlib.md5(raw_data).hexdigest(),
            'language': pefile.LANG.get(entry.data.lang, 'unknown'),
            'sub_language': sublang,
            'size': size,
            'name': f'resource_{type}_{entry.id}',
        }
        return (metadata, raw_data) 
開發者ID:PUNCH-Cyber,項目名稱:stoq-plugins-public,代碼行數:22,代碼來源:peinfo.py

示例3: _get_resources

# 需要導入模塊: import pefile [as 別名]
# 或者: from pefile import get_sublang_name_for_lang [as 別名]
def _get_resources(self):
        """Get resources.
        @return: resources dict or None.
        """
        resources = []

        if hasattr(self.pe, "DIRECTORY_ENTRY_RESOURCE"):
            for resource_type in self.pe.DIRECTORY_ENTRY_RESOURCE.entries:
                try:
                    resource = {}

                    if resource_type.name is not None:
                        name = str(resource_type.name)
                    else:
                        name = str(pefile.RESOURCE_TYPE.get(resource_type.struct.Id))

                    if hasattr(resource_type, "directory"):
                        for resource_id in resource_type.directory.entries:
                            if hasattr(resource_id, "directory"):
                                for resource_lang in resource_id.directory.entries:
                                    data = self.pe.get_data(resource_lang.data.struct.OffsetToData, resource_lang.data.struct.Size)
                                    filetype = self._get_filetype(data)
                                    language = pefile.LANG.get(resource_lang.data.lang, None)
                                    sublanguage = pefile.get_sublang_name_for_lang(resource_lang.data.lang, resource_lang.data.sublang)

                                    resource["name"] = name
                                    resource["offset"] = "0x{0:08x}".format(resource_lang.data.struct.OffsetToData)
                                    resource["size"] = "0x{0:08x}".format(resource_lang.data.struct.Size)
                                    resource["filetype"] = filetype
                                    resource["language"] = language
                                    resource["sublanguage"] = sublanguage
                                    resources.append(resource)
                except:
                    continue

        return resources 
開發者ID:phdphuc,項目名稱:mac-a-mal-cuckoo,代碼行數:38,代碼來源:static.py

示例4: _get_resources

# 需要導入模塊: import pefile [as 別名]
# 或者: from pefile import get_sublang_name_for_lang [as 別名]
def _get_resources(self):
        """Get resources.
        @return: resources dict or None.
        """
        if not self.pe:
            return None

        resources = []

        if hasattr(self.pe, "DIRECTORY_ENTRY_RESOURCE"):
            for resource_type in self.pe.DIRECTORY_ENTRY_RESOURCE.entries:
                try:
                    resource = {}

                    if resource_type.name is not None:
                        name = str(resource_type.name)
                    else:
                        name = str(pefile.RESOURCE_TYPE.get(resource_type.struct.Id))

                    if hasattr(resource_type, "directory"):
                        for resource_id in resource_type.directory.entries:
                            if hasattr(resource_id, "directory"):
                                for resource_lang in resource_id.directory.entries:
                                    data = self.pe.get_data(resource_lang.data.struct.OffsetToData, resource_lang.data.struct.Size)
                                    filetype = self._get_filetype(data)
                                    language = pefile.LANG.get(resource_lang.data.lang, None)
                                    sublanguage = pefile.get_sublang_name_for_lang(resource_lang.data.lang, resource_lang.data.sublang)

                                    resource["name"] = name
                                    resource["offset"] = "0x{0:08x}".format(resource_lang.data.struct.OffsetToData)
                                    resource["size"] = "0x{0:08x}".format(resource_lang.data.struct.Size)
                                    resource["filetype"] = filetype
                                    resource["language"] = language
                                    resource["sublanguage"] = sublanguage
                                    resources.append(resource)
                except:
                    continue

        return resources 
開發者ID:davidoren,項目名稱:CuckooSploit,代碼行數:41,代碼來源:static.py

示例5: process

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

        ret = []
        if hasattr(pelib, 'DIRECTORY_ENTRY_RESOURCE'):
            i = 0
            for resource_type in pelib.DIRECTORY_ENTRY_RESOURCE.entries:
                if resource_type.name is not None:
                    name = "%s" % resource_type.name
                else:
                    name = "%s" % pefile.RESOURCE_TYPE.get(
                        resource_type.struct.Id)
                if name is None:
                    name = "%d" % resource_type.struct.Id
                if hasattr(resource_type, 'directory'):
                    for resource_id in resource_type.directory.entries:
                        if hasattr(resource_id, 'directory'):
                            for resource_lang in resource_id.directory.entries:
                                try:
                                    data = pelib.get_data(
                                        resource_lang.data.struct.OffsetToData, resource_lang.data.struct.Size)
                                    # fd=open(name,'wb')
                                    # fd.write(data)
                                    # (data)
                                except pefile.PEFormatError:
                                    return "corrupt"
                                filetype = MIME_TYPE(data, False)
                                lang = pefile.LANG.get(
                                    resource_lang.data.lang, 'unknown')
                                sublang = pefile.get_sublang_name_for_lang(
                                    resource_lang.data.lang, resource_lang.data.sublang)
                                entry = {}
                                entry["name"] = self._normalize(name)
                                entry["rva"] = self._normalize(
                                    hex(resource_lang.data.struct.OffsetToData))
                                entry["size"] = self._normalize(
                                    hex(resource_lang.data.struct.Size))
                                entry["type"] = self._normalize(filetype)
                                entry["lang"] = self._normalize(lang)
                                entry["sublang"] = self._normalize(sublang)
                                entry["sha1"] = SHA1(data)
                                ret.append(entry)

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


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