Skip to content

Commit

Permalink
#212 WIP - add pefile raw output
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromeleonard committed May 31, 2018
1 parent 650856b commit e99a05d
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions analyzers/FileInfo/submodules/submodule_pe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def check_file(self, **kwargs):
:return: True
"""
try:
if kwargs.get('filetype') in ['Win32 EXE']:
if kwargs.get('filetype') in ['Win32 EXE', 'Win64 EXE']:
return True
except KeyError:
return False
Expand All @@ -32,6 +32,22 @@ def pe_machine(pedict):
else:
return str(machinetype) + ' => Not x86/64 or Itanium'

@staticmethod
def pe_type(pe):
if pe.is_exe():
return "EXE"
elif pe.is_dll():
return "DLL"
elif pe.is_driver():
return "DRIVER"
else:
return "UNKNOWN"

@staticmethod
def pe_dump(pe):
return pe.dump_info()


@staticmethod
def compilation_timestamp(pedict):
if pedict:
Expand Down Expand Up @@ -67,16 +83,22 @@ def pe_info(self, pe):
@staticmethod
def pe_iat(pe):
table = []

if pe:
for entry in pe.DIRECTORY_ENTRY_IMPORT:
imp = {
'entryname': entry.dll.decode(),
'symbols': []
}
for symbol in entry.imports:
if symbol.name is not None:
imp['symbols'].append(symbol.name.decode())
table.append(imp)
try:
for entry in pe.DIRECTORY_ENTRY_IMPORT:
# try:
imp = {
'entryname': entry.dll.decode(),
'symbols': []
}
# try:
for symbol in entry.imports:
if symbol.name is not None:
imp['symbols'].append(symbol.name.decode())
table.append(imp)
except AttributeError:
pass
return table

# PE:Sections list of {Name, Size, Entropy, MD5, SHA1, SHA256, SHA512} #
Expand Down Expand Up @@ -107,4 +129,5 @@ def analyze_file(self, path):
})
self.add_result_subsection('Import Adress Tables', self.pe_iat(pe))
self.add_result_subsection('Sections', self.pe_sections(pe))
self.add_result_subsection('pefile raw output', self.pe_dump(pe))
return self.results

0 comments on commit e99a05d

Please sign in to comment.