diff --git a/CODE/Logicytics.py b/CODE/Logicytics.py index f813726..9bffe8a 100644 --- a/CODE/Logicytics.py +++ b/CODE/Logicytics.py @@ -166,13 +166,18 @@ def special_run(file_path: str): log.debug(execution_list) -# Check weather to use threading or not +# Check weather to use threading or not, as well as execute code if action == "threaded": def threaded_execution(execution_list_thread, index_thread): - thread_log = Execute(log_variable=log).file(execution_list_thread, index_thread) - if thread_log[0]: - log.info(thread_log[0]) - log.info(thread_log[1]) + try: + thread_log = Execute().file(execution_list_thread, index_thread) + if thread_log[0]: + log.info(thread_log[0]) + log.info(thread_log[1]) + except UnicodeDecodeError as err: + log.error(f"Error in thread: {err}") + except Exception as err: + log.error(f"Error in thread: {err}") threads = [] for index, file in enumerate(execution_list): thread = threading.Thread( @@ -188,9 +193,14 @@ def threaded_execution(execution_list_thread, index_thread): for thread in threads: thread.join() else: - for file in range(len(execution_list)): # Loop through List - log.info(Execute(log_variable=log).execute_script(execution_list[file])) - log.info(f"{execution_list[file]} executed") + try: + for file in range(len(execution_list)): # Loop through List + log.info(Execute().execute_script(execution_list[file])) + log.info(f"{execution_list[file]} executed") + except UnicodeDecodeError as e: + log.error(f"Error in thread: {e}") + except Exception as e: + log.error(f"Error in thread: {e}") # Zip generated files if action == "modded": @@ -230,5 +240,4 @@ def threaded_execution(execution_list_thread, index_thread): log.info("Exiting...") input("Press Enter to exit...") -# Special feature that allows to create a `-` line only log.debug("*-*") diff --git a/CODE/__lib_class.py b/CODE/__lib_class.py index 18333b1..006919d 100644 --- a/CODE/__lib_class.py +++ b/CODE/__lib_class.py @@ -350,7 +350,7 @@ def uac(self) -> bool: return int(value.strip("\n")) == 1 @staticmethod - def sys_internal_zip() -> str: + def sys_internal_zip(): """ Extracts the SysInternal_Suite zip file if it exists and is not ignored. @@ -371,26 +371,18 @@ def sys_internal_zip() -> str: "SysInternal_Suite/SysInternal_Suite.zip" ) as zip_ref: zip_ref.extractall("SysInternal_Suite") - return "SysInternal_Suite zip extracted" + if __name__ == "__main__": + Log(debug=DEBUG).debug("SysInternal_Suite zip extracted") elif ignore_file: - return ( - "Found .sys.ignore file, skipping SysInternal_Suite zip extraction" - ) + if __name__ == "__main__": + Log(debug=DEBUG).debug("Found .sys.ignore file, skipping SysInternal_Suite zip extraction") except Exception as err: exit(f"Failed to unzip SysInternal_Suite: {err}") class Execute: - def __init__(self, log_variable=None): - """ - Initializes an instance of the class. - - Sets the Actions attribute to an instance of the Actions class. - """ - self.log_variable = log_variable - @staticmethod def get_files(directory: str, file_list: list) -> list: """ @@ -410,7 +402,7 @@ def get_files(directory: str, file_list: list) -> list: file_list.append(filename) return file_list - def file(self, execution_list: list, Index: int) -> tuple[str, str]: + def file(self, execution_list: list, Index: int): # IT IS USED, DO NOT REMOVE """ Executes a file from the execution list at the specified index. @@ -420,31 +412,26 @@ def file(self, execution_list: list, Index: int) -> tuple[str, str]: Returns: None """ - log_message = self.execute_script(execution_list[Index]) - return log_message, f"{execution_list[Index]} executed" + self.execute_script(execution_list[Index]) + if __name__ == "__main__": + Log().info(f"{execution_list[Index]} executed") - def execute_script(self, script: str, logvar=None) -> str: + def execute_script(self, script: str): """ Executes a script file and handles its output based on the file extension. Parameters: script (str): The path of the script file to be executed. - logvar (Log): The log variable to use for logging. - Returns: - None """ - if logvar is None: - logvar = self.log_variable if script.endswith(".ps1"): - log_message = self.__unblock_ps1_script(script) - self.__run_other_script(script, logvar) + self.__unblock_ps1_script(script) + self.__run_other_script(script) elif script.endswith(".py"): self.__run_python_script(script) else: - self.__run_other_script(script, logvar) - return log_message + self.__run_other_script(script) @staticmethod - def __unblock_ps1_script(script: str) -> str: + def __unblock_ps1_script(script: str): """ Unblocks and runs a PowerShell (.ps1) script. Parameters: @@ -455,7 +442,8 @@ def __unblock_ps1_script(script: str) -> str: try: unblock_command = f'powershell.exe -Command "Unblock-File -Path {script}"' subprocess.run(unblock_command, shell=False, check=True) - return "PS1 Script unblocked." + if __name__ == "__main__": + Log().info("PS1 Script unblocked.") except Exception as err: exit(f"Failed to unblock script: {err}") @@ -475,7 +463,7 @@ def __run_python_script(script: str): print(result.decode()) @staticmethod - def __run_other_script(script: str, logvar=None): + def __run_other_script(script: str): """ Runs a script with other extensions and logs output based on its content. Parameters: @@ -489,8 +477,8 @@ def __run_other_script(script: str, logvar=None): ) lines = result.stdout.splitlines() ID = next((line.split(":")[0].strip() for line in lines if ":" in line), None) - if ID and logvar: - logvar.string(str(lines), ID) + if ID and __name__ == "__main__": + Log().string(str(lines), ID) WEBHOOK, DEBUG, VERSION, API_KEY, CURRENT_FILES = Actions.read_config() diff --git a/CODE/driverquery+sysinfo.py b/CODE/driverquery+sysinfo.py index 8606a41..b1c3a8b 100644 --- a/CODE/driverquery+sysinfo.py +++ b/CODE/driverquery+sysinfo.py @@ -27,4 +27,5 @@ def command(file: str, com: str, message: str): command("Drivers.txt", "driverquery /v", "Driver Query") command("SysInfo.txt", "systeminfo", "System Info") -command("Dir_S.txt", "dir/s", "Directory Listing") +# WIP +# command("Dir_S.txt", "dir/s", "Directory Listing") diff --git a/CODE/registry.py b/CODE/registry.py index 3d32ed2..79306db 100644 --- a/CODE/registry.py +++ b/CODE/registry.py @@ -17,9 +17,9 @@ def backup_registry(): try: subprocess.run(cmd, check=True) - print(f"Registry backed up successfully to {export_path}") + log.info(f"Registry backed up successfully to {export_path}") except subprocess.CalledProcessError as e: - print(f"Failed to back up the registry: {e}") + log.error(f"Failed to back up the registry: {e}") backup_registry() diff --git a/CODE/wifi_stealer.py b/CODE/wifi_stealer.py index f80b1a4..10689a4 100644 --- a/CODE/wifi_stealer.py +++ b/CODE/wifi_stealer.py @@ -63,12 +63,25 @@ def get_wifi_names() -> list: log.error(err) -with open("WiFi.txt", "w") as file: - for name in get_wifi_names(): - try: - log.info(f"Retrieving password for {name.removeprefix(': ')}") - file.write( - f"Name: {name.removeprefix(': ')}, Password: {get_password(name.removeprefix(': '))}\n" - ) - except Exception as e: - log.error(e) +def get_wifi_passwords(): + """ + Retrieves the passwords for all Wi-Fi profiles on the system. + + This function retrieves the names of all Wi-Fi profiles on the system using the get_wifi_names() function. + It then iterates over each Wi-Fi profile name and retrieves the password associated with the profile using the get_password() function. + The Wi-Fi profile names and passwords are stored in a dictionary where the key is the Wi-Fi profile name and the value is the password. + """ + with open("WiFi.txt", "w") as file: + for name in get_wifi_names(): + try: + log.info(f"Retrieving password for {name.removeprefix(': ')}") + file.write( + f"Name: {name.removeprefix(': ')}, Password: {get_password(name.removeprefix(': '))}\n" + ) + except UnicodeDecodeError as e: + log.error(e) + except Exception as e: + log.error(e) + + +get_wifi_passwords()