-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f46f15
commit decd7d8
Showing
4 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .submodule_metadata import MetadataSubmodule | ||
from .submodule_gzip import GZIPSubmodule | ||
from .submodule_gzip import GZIPSubmodule | ||
from .submodule_pe import PESubmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import magic | ||
import hashlib | ||
import io | ||
import pyexifinfo | ||
import pefile | ||
|
||
from .submodule_base import SubmoduleBaseclass | ||
from ssdeep import Hash | ||
|
||
|
||
class PESubmodule(SubmoduleBaseclass): | ||
def __init__(self): | ||
SubmoduleBaseclass.__init__(self) | ||
self.name = 'PE' | ||
|
||
def check_file(self, **kwargs): | ||
""" | ||
PE submodule will analyze every PE like EXE, DLL or DRIVER, therefore it will always return true. | ||
:return: True | ||
""" | ||
if kwargs.get('filetype') in ['Win32 EXE']: | ||
return True | ||
|
||
def PE_info(self, pe): | ||
table = [] | ||
try: | ||
for fileinfo in pe.FileInfo: | ||
if fileinfo.Key.decode() == 'StringFileInfo': | ||
for stringtable in fileinfo.StringTable: | ||
for entry in stringtable.entries.items(): | ||
table.append({'Info': entry[0].decode(), 'Value': entry[1].decode()}) | ||
return table | ||
except Exception as excp: | ||
return 'None' | ||
|
||
def analyze_file(self, path): | ||
try: | ||
pe = pefile.PE(path) | ||
pedict = pe.dump_dict() | ||
except Exception as excp: | ||
print("Failed processing {}".format(path)) | ||
|
||
self.add_result_subsection('PE Info', { | ||
"Info": self.PE_info(pe) | ||
}) | ||
|
||
return self.results |