Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6389adb
Fixed some encoding/decoding issues,
DefinetlyNotAI Dec 19, 2024
7588fea
Merge remote-tracking branch 'origin/main' into minor-fixes-bugs
DefinetlyNotAI Dec 19, 2024
8bdaf08
Removed redundant code
DefinetlyNotAI Dec 19, 2024
32622cd
Made all logs even better
DefinetlyNotAI Dec 19, 2024
3ec3172
Updated credits
DefinetlyNotAI Dec 23, 2024
774f694
Updated Flag.py
DefinetlyNotAI Dec 23, 2024
dfb7540
Updated Flag.py module
DefinetlyNotAI Dec 27, 2024
61c26ee
Updated Flag.py module
DefinetlyNotAI Dec 27, 2024
2355b9e
Getting most optimum weights for the logic
DefinetlyNotAI Dec 29, 2024
fc081e0
Stuck to a standstill...
DefinetlyNotAI Dec 29, 2024
51e0eed
Refactoring and reorganising files
DefinetlyNotAI Dec 31, 2024
fcd9c94
Made the flag suggester properly
DefinetlyNotAI Dec 31, 2024
275ff97
Improving the flag suggestor
DefinetlyNotAI Dec 31, 2024
901fced
Improving the flag suggestor
DefinetlyNotAI Jan 1, 2025
5c633d5
Finished implementing Flag.py suggestor
DefinetlyNotAI Jan 1, 2025
be5c50f
Minor changes
DefinetlyNotAI Jan 2, 2025
924a55c
Fixed Major Issue
DefinetlyNotAI Jan 2, 2025
8b70cf4
Fixed Major Issue
DefinetlyNotAI Jan 2, 2025
bbc6f7f
Merge remote-tracking branch 'origin/bug-fixes-and-v3.3.0' into bug-f…
DefinetlyNotAI Jan 2, 2025
b0bb706
Fixed Major Issue
DefinetlyNotAI Jan 2, 2025
a0902a5
Merge branch 'main' into bug-fixes-and-v3.3.0
DefinetlyNotAI Jan 2, 2025
a11ce93
Fixing coderabbit suggestions
DefinetlyNotAI Jan 3, 2025
990efc4
📝 Add docstrings to `bug-fixes-and-v3.3.0`
coderabbitai[bot] Jan 3, 2025
188af44
Uncommitted changes before Checkout at 03/01/2025 21:42 [Changes]
DefinetlyNotAI Jan 3, 2025
940c015
Fixed major issues
DefinetlyNotAI Jan 3, 2025
ccb9668
Merge branch 'bug-fixes-and-v3.3.0' into coderabbitai/docstrings/a11ce93
DefinetlyNotAI Jan 3, 2025
5f1a266
📝 Add docstrings to `bug-fixes-and-v3.3.0` (#178)
DefinetlyNotAI Jan 3, 2025
1f876aa
Fixed issues caused by coderabbit
DefinetlyNotAI Jan 3, 2025
d44ecd0
Fixed issues caused by coderabbit
DefinetlyNotAI Jan 3, 2025
77d7519
Merge remote-tracking branch 'origin/bug-fixes-and-v3.3.0' into bug-f…
DefinetlyNotAI Jan 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ body:
validations:
required: false
- type: dropdown
id: flags
id: flags_list
attributes:
label: What flags were you using to run Logicytics?
label: What flags_list were you using to run Logicytics?
multiple: false
options:
- Threading
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,5 @@ $RECYCLE.BIN/
/CODE/SysInternal_Suite/.sys.ignore
/ACCESS/
/CODE/VulnScan/tools/NN features/
/CODE/logicytics/User_History.json.gz
/CODE/logicytics/User_History.json
64 changes: 28 additions & 36 deletions CODE/Logicytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,16 @@ def update() -> tuple[str, str]:

def get_flags():
"""
Retrieves the command-line flags and sub-actions.

This function checks if the flags are provided as a tuple. If so, it attempts to unpack
the tuple into ACTION and SUB_ACTION. If an exception occurs, it sets SUB_ACTION to None.
If the flags are not a tuple, it prints the help message and exits the program.
Retrieves the action and sub-action flags_list from the Flag module and logs them.

This function sets the global variables ACTION and SUB_ACTION based on the data
retrieved from the Flag module. It also logs the retrieved values for debugging purposes.
"""
global ACTION, SUB_ACTION
if isinstance(Flag.data(), tuple):
try:
# Get flags
ACTION, SUB_ACTION = Flag.data()
except ValueError:
actions = Flag.data()
ACTION = actions[0]
SUB_ACTION = None
else:
parser = Flag.data()
parser.print_help()
input("Press Enter to exit...")
exit(1)
# Get flags_list
ACTION, SUB_ACTION = Flag.data()
log.debug(f"Action: {ACTION}")
log.debug(f"Sub-Action: {SUB_ACTION}")


def special_execute(file_path: str):
Expand Down Expand Up @@ -135,14 +124,6 @@ def handle_special_actions():
log.info("Opening developer menu...")
special_execute("_dev.py")

# Deprecated, remove in v3.3.0
if ACTION == "extra":
print("\033[91mDeprecationWarning: The `extra` feature has been removed! 🚫\n"
"Why? It didn't match our code quality standards.\n"
"What to use instead? Check out our new features with --help\033[0m")
input("Press Enter to exit...")
exit(0)

if ACTION == "update":
log.info("Updating...")
message, log_type = Health.update()
Expand Down Expand Up @@ -173,14 +154,6 @@ def handle_special_actions():
input("Press Enter to exit...")
exit(0)

# Deprecated, remove in v3.3.0
if ACTION == "unzip_extra":
print("\033[91mDeprecationWarning: The `unzip_extra` feature has been removed! 🚫\n"
"Why? It didn't match our code quality standards.\n"
"What to use instead? Check out our new features with --help\033[0m")
input("Press Enter to exit...")
exit(0)


def check_privileges():
"""
Expand Down Expand Up @@ -215,6 +188,7 @@ def generate_execution_list() -> list | list[str] | list[str | Any]:
execution_list.remove("dir_list.py")
execution_list.remove("tree.ps1")
execution_list.remove("vulnscan.py")
execution_list.remove("event_log.py")

if ACTION == "minimal":
execution_list = [
Expand Down Expand Up @@ -248,6 +222,7 @@ def generate_execution_list() -> list | list[str] | list[str | Any]:
execution_list.append("sensitive_data_miner.py")
execution_list.append("dir_list.py")
execution_list.append("tree.ps1")
execution_list.append("event_log.py")
log.warning("This flag will use threading!")

if ACTION == "vulnscan_ai":
Expand Down Expand Up @@ -367,8 +342,21 @@ def handle_sub_action():
# log.warning("This feature is not implemented yet! Sorry")


if __name__ == "__main__":
# Get flags and configs
@log.function
def Logicytics():
"""
Main function to run the Logicytics process.

This function performs the following steps:
1. Retrieves command-line flags_list and configurations.
2. Handles any special actions based on the provided action flag.
3. Checks for administrative privileges and potential errors.
4. Executes the scripts based on the action flag.
5. Zips the generated files.
6. Handles any sub-actions based on the provided sub-action flag.
7. Waits for user input to exit the program.
"""
# Get flags_list and configs
get_flags()
# Check for special actions
handle_special_actions()
Expand All @@ -382,6 +370,10 @@ def handle_sub_action():
handle_sub_action()
# Finish
input("Press Enter to exit...")


if __name__ == "__main__":
Logicytics()
else:
log.error("This script cannot be imported!")
exit(1)
9 changes: 9 additions & 0 deletions CODE/_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ def cpu_info() -> tuple[str, str, str]:


def python_version():
"""
Checks the current Python version and logs the result.

Logs:
- Info if the Python version is within the acceptable range.
- Warning if the Python version is below the minimum recommended version.
- Error if the Python version is above the maximum supported version or if there is a parsing error.
"""
version = sys.version.split()[0]
MIN_VERSION = (3, 11)
MAX_VERSION = (3, 13)
Expand Down Expand Up @@ -211,6 +219,7 @@ def get_online_config() -> dict | None:
return None


@log_debug.function
def debug():
"""
Executes system checks and logs results.
Expand Down
24 changes: 14 additions & 10 deletions CODE/_dev.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

import configobj
import subprocess

import configobj

from logicytics import Log, DEBUG, Get, FileManagement, CURRENT_FILES, VERSION

if __name__ == "__main__":
Expand Down Expand Up @@ -47,7 +48,7 @@
bool: True if the user's answer is 'yes', otherwise False.
"""
try:
answer = input(question + " (yes or no):- ")
answer = input(question + " (Y)es or (N)o:- ")
if not (answer.lower() == "yes" or answer.lower() == "y"):
if file_to_open:
subprocess.run(["start", file_to_open], shell=True)
Expand All @@ -61,72 +62,75 @@
log_dev.error(e)


@log_dev.function
def dev_checks() -> None:
"""
Performs a series of checks to ensure that the developer has followed the required guidelines and best practices.
Returns:
bool: True if all checks pass, otherwise False.
"""
# Create the necessary directories if they do not exist
FileManagement.mkdir()

# List of checks to be performed, each check is a tuple containing a question and a file to open if the answer is not 'yes'
checks = [
("Have you read the required contributing guidelines?", "../CONTRIBUTING.md"),
("Have you made files you don't want to be run start with '_'?", "."),
("Have you added the file to CODE dir?", "."),
("Have you added docstrings and comments?", "../CONTRIBUTING.md"),
("Is each file containing around 1 main feature?", "../CONTRIBUTING.md"),
]

try:
# Iterate through each check and prompt the user
for question, file_to_open in checks:
if not _prompt_user(question, file_to_open):
log_dev.warning("Fix the issues and try again with the checklist.")
return None

# Get the list of files in the current directory
files = Get.list_of_files(".", True)
EXCLUDE_FILES = ["logicytics\\User_History.json.gz", "logicytics\\User_History.json"]
files = Get.list_of_files(".", True, exclude_files=EXCLUDE_FILES)
added_files, removed_files, normal_files = [], [], []
clean_files_list = [file.replace('"', '') for file in CURRENT_FILES]

for f in files:
clean_f = f.replace('"', '')
if clean_f in clean_files_list:
if clean_f in clean_files_list and clean_f not in EXCLUDE_FILES:
normal_files.append(clean_f)
else:
elif clean_f not in EXCLUDE_FILES:
added_files.append(clean_f)

for f in clean_files_list:
clean_f = f.replace('"', '')
if clean_f not in files:
if clean_f not in files and clean_f not in EXCLUDE_FILES:
removed_files.append(clean_f)

# Print the list of added, removed, and normal files in color
print("\n".join([f"\033[92m+ {file}\033[0m" for file in added_files])) # Green +
print("\n".join([f"\033[91m- {file}\033[0m" for file in removed_files])) # Red -
print("\n".join([f"* {file}" for file in normal_files]))

# Prompt the user to confirm if the list includes their added files
if not _prompt_user("Does the list above include your added files?"):
log_dev.critical("Something went wrong! Please contact support.")
return None

# Update the JSON file with the current list of files
_update_ini_file("config.ini", files, "files")

# Prompt the user to enter the new version of the project and update the JSON file
_update_ini_file("config.ini", input(f"Enter the new version of the project (Old version is {VERSION}): "),
"version")

# Print a message indicating the completion of the steps
print("\nGreat Job! Please tick the box in the GitHub PR request for completing steps in --dev")
except Exception as e:
# Log any exceptions that occur during the process
log_dev.exception(str(e))
log_dev.error(f"An error occurred: {e}")

Check notice on line 130 in CODE/_dev.py

View check run for this annotation

codefactor.io / CodeFactor

CODE/_dev.py#L66-L130

Complex Method


dev_checks()
# Wait for the user to press Enter to exit the program
input("\nPress Enter to exit the program... ")
if __name__ == "__main__":
dev_checks()
# Wait for the user to press Enter to exit the program
input("\nPress Enter to exit the program... ")
35 changes: 18 additions & 17 deletions CODE/bluetooth_details.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import subprocess
from __future__ import annotations

import json
import subprocess

from logicytics import Log, DEBUG

if __name__ == "__main__":
log = Log({"log_level": DEBUG})


@log.function
def get_bluetooth_device_details():
"""
Retrieves and logs detailed information about Bluetooth devices on the system.
Expand All @@ -27,15 +31,12 @@ def get_bluetooth_device_details():
None
"""
log.info("Fetching detailed info for Bluetooth devices...")
try:
devices = _query_bluetooth_devices()
devices = _query_bluetooth_devices()
if devices:
_write_device_info_to_file(devices, "Bluetooth Info.txt")
except Exception as e:
log.error(f"Error: {e}")
exit(1)


def _query_bluetooth_devices():
def _query_bluetooth_devices() -> bool | list[dict[str, str]]:
"""
Queries the system for Bluetooth devices using PowerShell commands.

Expand All @@ -49,27 +50,28 @@ def _query_bluetooth_devices():
"Select-Object FriendlyName, DeviceID, Description, Manufacturer, Status, PnpDeviceID | "
"ConvertTo-Json -Depth 3"
)
result = subprocess.run(["powershell", "-Command", command], capture_output=True, text=True, check=True)
result = subprocess.run(["powershell", "-Command", command],
capture_output=True, text=True, check=True)
devices = json.loads(result.stdout)
except subprocess.CalledProcessError as e:
log.error(f"Failed to query Bluetooth devices: {e}")
exit(1)
return False
except json.JSONDecodeError as e:
log.error(f"Failed to parse device information: {e}")
exit(1)
return False

if isinstance(devices, dict):
devices = [devices] # Handle single result case

device_info_list = []
for device in devices:
device_info = {
'Name': device.get('FriendlyName', 'Unknown'),
'Device ID': device.get('DeviceID', 'Unknown'),
'Description': device.get('Description', 'Unknown'),
'Manufacturer': device.get('Manufacturer', 'Unknown'),
'Status': device.get('Status', 'Unknown'),
'PNP Device ID': device.get('PnpDeviceID', 'Unknown')
'Name': device.get('FriendlyName', 'Unknown (Fallback due to failed Get request)'),
'Device ID': device.get('DeviceID', 'Unknown (Fallback due to failed Get request)'),
'Description': device.get('Description', 'Unknown (Fallback due to failed Get request)'),
'Manufacturer': device.get('Manufacturer', 'Unknown (Fallback due to failed Get request)'),
'Status': device.get('Status', 'Unknown (Fallback due to failed Get request)'),
'PNP Device ID': device.get('PnpDeviceID', 'Unknown (Fallback due to failed Get request)')
}
log.debug(f"Retrieved device: {device_info['Name']}")
device_info_list.append(device_info)
Expand All @@ -94,7 +96,6 @@ def _write_device_info_to_file(devices, filename):
_write_single_device_info(file, device_info)
except Exception as e:
log.error(f"Failed to write device information to file: {e}")
exit(1)


def _write_single_device_info(file, device_info):
Expand Down
Loading
Loading