Skip to content

Commit

Permalink
fix modules, tools, utility
Browse files Browse the repository at this point in the history
  • Loading branch information
naaya17 committed Jun 20, 2021
1 parent 8616084 commit 0299834
Show file tree
Hide file tree
Showing 41 changed files with 425 additions and 333 deletions.
9 changes: 4 additions & 5 deletions engine/process_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def Process(self, configuration):
if module.NAME != 'macos_connector':
module.print_run_info(module.DESCRIPTION, start=True)
module.print_run_info(module.DESCRIPTION, start=False)
print()
continue

if isinstance(module, modules_interface.ModuleConnector):
Expand All @@ -112,7 +111,7 @@ def Process(self, configuration):
else: # for GUI
module.print_run_info(module.DESCRIPTION, start=True)
module.print_run_info(module.DESCRIPTION, start=False)
print()

# Skip these modules
elif module_name in ['andforensics_connector',
'fica_connector', 'extract_connector',
Expand All @@ -129,7 +128,7 @@ def Process(self, configuration):
else: # for GUI
module.print_run_info(module.DESCRIPTION, start=True)
module.print_run_info(module.DESCRIPTION, start=False)
print()

# Other modules
else:
module.print_run_info(module.DESCRIPTION, start=True)
Expand All @@ -138,7 +137,7 @@ def Process(self, configuration):
source_path_spec=source_path_spec,
knowledge_base=self.knowledge_base)
module.print_run_info(module.DESCRIPTION, start=False)
print() # for line feed


except RuntimeError as exception:
raise errors.BackEndError('The module cannot be connected: {0!s}'.format(exception))
Expand Down Expand Up @@ -315,7 +314,7 @@ def get_partition_id(self, source_path_spec, configuration):
par_id = ''
else:
par_id = configuration.partition_list[list(configuration.partition_list.keys())[0]]
print(f'\n\n[{self.print_now_time()}] Partition ID: {par_id}')
#print(f'[{self.print_now_time()}] Partition ID: {par_id}')
return par_id

def print_now_time(self):
Expand Down
2 changes: 1 addition & 1 deletion modules/DEFA/MS_Office/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def main(filePath):
return

object.parse()
fp = open(".\\result\\" + fname[:-4] + ".txt", 'w', encoding='UTF-8')
# fp = open(".\\result\\" + fname[:-4] + ".txt", 'w', encoding='UTF-8')
fp.write(object.content)
fp.write(str(object.metadata['author']))
fp.write(str(object.metadata['title']))
Expand Down
80 changes: 40 additions & 40 deletions modules/DEFA/OOXML/Carpe_OOXML.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,23 +625,23 @@ def parse_content(self, filename, filetype, isDamaged, tmp_path=None):
if content_saved == "":
temp_size = lastpart[30+data_name_length:]

f1 = open("./outputtest.zip", 'wb')
f1 = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'wb')
f1.write(b'\x78\x9C')
f1.write(temp_size)
f1.close()

fz = open("./outputtest.zip",'rb')
fz = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip",'rb')
d = fz.read()
fz.close()

zobj = zlib.decompressobj()
real_data = zobj.decompress(d)

f2 = open("./test.xml",'wb')
f2 = open(os.path.dirname(self.filename) + os.sep + "test.xml",'wb')
f2.write(real_data)
f2.close()

f3 = open("./test.xml",'r',encoding='utf-8')
f3 = open(os.path.dirname(self.filename) + os.sep + "test.xml",'r',encoding='utf-8')
a1 = f3.read()
f3.close()

Expand Down Expand Up @@ -673,23 +673,23 @@ def parse_content(self, filename, filetype, isDamaged, tmp_path=None):
#self.parse_media(filename, filetype, isDamaged, tmp_path)
return only_data
else:
f1 = open("./outputtest.zip", 'wb')
f1 = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'wb')
f1.write(b'\x78\x9C')
f1.write(content_saved)
f1.close()

fz = open("./outputtest.zip", 'rb')
fz = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'rb')
d = fz.read()
fz.close()

zobj = zlib.decompressobj()
real_data = zobj.decompress(d)

f2 = open("./test.xml", 'wb')
f2 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'wb')
f2.write(real_data)
f2.close()

f3 = open("./test.xml", 'r', encoding='utf-8')
f3 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'r', encoding='utf-8')
a1 = f3.read()
f3.close()

Expand Down Expand Up @@ -782,23 +782,23 @@ def parse_content(self, filename, filetype, isDamaged, tmp_path=None):
else:
if "xl/sharedStrings.xml" == data_name:
content_saved = f.read(data_length)
f1 = open("./outputtest.zip", 'wb')
f1 = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'wb')
f1.write(b'\x78\x9C')
f1.write(content_saved)
f1.close()

fz = open("./outputtest.zip", 'rb')
fz = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'rb')
d = fz.read()
fz.close()

zobj = zlib.decompressobj()
real_data = zobj.decompress(d)

f2 = open("./test.xml", 'wb')
f2 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'wb')
f2.write(real_data)
f2.close()

f3 = open("./test.xml", 'r', encoding='utf-8')
f3 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'r', encoding='utf-8')
a1 = f3.read()
f3.close()

Expand Down Expand Up @@ -874,23 +874,23 @@ def parse_content(self, filename, filetype, isDamaged, tmp_path=None):
else:
if "xl/worksheets/sheet1.xml" == data_name:
content_saved = f.read(data_length)
f1 = open("./outputtest.zip", 'wb')
f1 = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'wb')
f1.write(b'\x78\x9C')
f1.write(content_saved)
f1.close()

fz = open("./outputtest.zip", 'rb')
fz = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'rb')
d = fz.read()
fz.close()

zobj = zlib.decompressobj()
real_data = zobj.decompress(d)

f2 = open("./test.xml", 'wb')
f2 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'wb')
f2.write(real_data)
f2.close()

f3 = open("./test.xml", 'r', encoding='utf-8')
f3 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'r', encoding='utf-8')
a1 = f3.read()
f3.close()

Expand Down Expand Up @@ -1052,23 +1052,23 @@ def parse_content(self, filename, filetype, isDamaged, tmp_path=None):
if data_name == "docProps/app.xml":
content_saved = f.read(data_length)

f1 = open("./outputtest.zip", 'wb')
f1 = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'wb')
f1.write(b'\x78\x9C')
f1.write(content_saved)
f1.close()

fz = open("./outputtest.zip", 'rb')
fz = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'rb')
d = fz.read()
fz.close()

zobj = zlib.decompressobj()
real_data = zobj.decompress(d)

f2 = open("./test.xml", 'wb')
f2 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'wb')
f2.write(real_data)
f2.close()

f3 = open("./test.xml", 'r', encoding='utf-8')
f3 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'r', encoding='utf-8')
a1 = f3.read()
f3.close()

Expand Down Expand Up @@ -1127,23 +1127,23 @@ def parse_content(self, filename, filetype, isDamaged, tmp_path=None):

content_saved = f.read(data_length)
pptx_ordering_table.append(content_saved)
f1 = open("./outputtest.zip", 'wb')
f1 = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'wb')
f1.write(b'\x78\x9C')
f1.write(content_saved)
f1.close()

fz = open("./outputtest.zip", 'rb')
fz = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'rb')
d = fz.read()
fz.close()

zobj = zlib.decompressobj()
real_data = zobj.decompress(d)

f2 = open("./test.xml", 'wb')
f2 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'wb')
f2.write(real_data)
f2.close()

f3 = open("./test.xml", 'r', encoding='utf-8')
f3 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'r', encoding='utf-8')
a1 = f3.read()
f3.close()

Expand Down Expand Up @@ -1216,23 +1216,23 @@ def parse_content(self, filename, filetype, isDamaged, tmp_path=None):

content_saved = f.read(data_length)
pptx_ordering_table.append(content_saved)
f1 = open("./outputtest.zip", 'wb')
f1 = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'wb')
f1.write(b'\x78\x9C')
f1.write(content_saved)
f1.close()

fz = open("./outputtest.zip", 'rb')
fz = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'rb')
d = fz.read()
fz.close()

zobj = zlib.decompressobj()
real_data = zobj.decompress(d)

f2 = open("./test.xml", 'wb')
f2 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'wb')
f2.write(real_data)
f2.close()

f3 = open("./test.xml", 'r', encoding='utf-8')
f3 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'r', encoding='utf-8')
a1 = f3.read()
f3.close()

Expand Down Expand Up @@ -1274,23 +1274,23 @@ def parse_content(self, filename, filetype, isDamaged, tmp_path=None):
if "ppt/slideL" not in data_name:
temp_size = lastpart[30 + data_name_length:]

f1 = open("./outputtest.zip", 'wb')
f1 = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'wb')
f1.write(b'\x78\x9C')
f1.write(temp_size)
f1.close()

fz = open("./outputtest.zip", 'rb')
fz = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'rb')
d = fz.read()
fz.close()

zobj = zlib.decompressobj()
real_data = zobj.decompress(d)

f2 = open("./test.xml", 'wb')
f2 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'wb')
f2.write(real_data)
f2.close()

f3 = open("./test.xml", 'r', encoding='utf-8')
f3 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'r', encoding='utf-8')
a1 = f3.read()
f3.close()

Expand Down Expand Up @@ -1477,23 +1477,23 @@ def parse_metadata(self, filename, isDamaged):
if data_name == "docProps/core.xml":
content_saved = f.read(data_length)

f1 = open("./outputtest.zip", 'wb')
f1 = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'wb')
f1.write(b'\x78\x9C')
f1.write(content_saved)
f1.close()

fz = open("./outputtest.zip", 'rb')
fz = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'rb')
d = fz.read()
fz.close()

zobj = zlib.decompressobj()
real_data = zobj.decompress(d)

f2 = open("./test.xml", 'wb')
f2 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'wb')
f2.write(real_data)
f2.close()

f3 = open("./test.xml", 'r', encoding='utf-8')
f3 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'r', encoding='utf-8')
a1 = f3.read()
f3.close()

Expand Down Expand Up @@ -1728,23 +1728,23 @@ def parse_metadata(self, filename, isDamaged):
elif data_name == "docProps/app.xml":
content_saved = f.read(data_length)

f1 = open("./outputtest.zip", 'wb')
f1 = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'wb')
f1.write(b'\x78\x9C')
f1.write(content_saved)
f1.close()

fz = open("./outputtest.zip", 'rb')
fz = open(os.path.dirname(self.filename) + os.sep + "outputtest.zip", 'rb')
d = fz.read()
fz.close()

zobj = zlib.decompressobj()
real_data = zobj.decompress(d)

f2 = open("./test.xml", 'wb')
f2 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'wb')
f2.write(real_data)
f2.close()

f3 = open("./test.xml", 'r', encoding='utf-8')
f3 = open(os.path.dirname(self.filename) + os.sep + "test.xml", 'r', encoding='utf-8')
a1 = f3.read()
f3.close()

Expand Down
4 changes: 2 additions & 2 deletions modules/ESEDB_Parser/esedb_internet_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def _ParseContainerTable(self, table, container_name):
elif container_name == 'History':
self._history_schema = tuple(record_values.keys())
self._history_records.append(tuple(record_values.values()))
if record_values.get('EntryId') == 8 and record_values.get('ContainerId') == 18:
print(record_values)
# if record_values.get('EntryId') == 8 and record_values.get('ContainerId') == 18:
# print(record_values)

elif container_name == 'Cookies':
self._cookies_schema = tuple(record_values.keys())
Expand Down
9 changes: 5 additions & 4 deletions modules/Eventlog/lv1_os_win_event_logs_ms_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import datetime

from utility import database
from modules import logger
from xml.etree import ElementTree

class MS_Alerts_Information:
Expand Down Expand Up @@ -57,11 +58,11 @@ def EVENTLOGMSALERTS(configuration):
ms_alerts_list[ms_alerts_count].message = message
ms_alerts_list[ms_alerts_count].error_type = data[len(data)-2]
ms_alerts_list[ms_alerts_count].program_version = data[len(data)-1]
except Exception as e:
print("Eventlog_ms_alerts_parsing_error: {0:s}".format(e))
except Exception as exception:
logger.error('EVENTLOGS MS Alerts Parsing Error: {0!s}'.format(exception))
ms_alerts_count = ms_alerts_count + 1
except:
print("EVENT LOG MS ALERTS ERROR")
except Exception as exception:
logger.error('EVENTLOGS MS Alerts Error: {0!s}'.format(exception))

#db.close()

Expand Down
Loading

0 comments on commit 0299834

Please sign in to comment.