Skip to content

Commit 4776121

Browse files
feat(core): major improvements across debugger, vulnscan, and logging
- Added explicit variable type annotations across most files - Rewrote `dump_memory` to include TODO logic and improve robustness - Enhanced debugger version check: - Now supports custom Git repo URLs for update checks - Improved forced exit handling in `Logicytics.py` with basic cleanup - vulnscan module upgrades: - Implemented batch file reading - Switched to asynchronous file scanning - Optimized model loading with caching - Improved feature extraction pipeline - Introduced `MAX_FILE_SIZE` global (default 50MB; None to ignore) - Added `max_workers` and `UNREADABLE_EXTENSIONS` to `config.ini` - Replaced `print` statements with structured logging across logicytics lib Signed-off-by: Shahm Najeeb <Nirt_12023@outlook.com>
1 parent 179647c commit 4776121

18 files changed

Lines changed: 289 additions & 375 deletions

CODE/Logicytics.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,10 @@ def Logicytics():
530530
try:
531531
Logicytics()
532532
except KeyboardInterrupt:
533-
log.warning("⚠️ Force shutdown detected! Some temporary files might be left behind.")
534-
log.warning("💡 Pro tip: Next time, let the program finish naturally.")
535-
# TODO v3.4.2 -> Cleanup function
533+
log.warning("Force shutdown detected! Some temporary files might be left behind.")
534+
log.warning("Pro tip: Next time, let the program finish naturally.")
535+
# Attempt cleanup -> Zip generated files
536+
ZIP.files()
536537
exit(0)
537538
else:
538539
log.error("This script cannot be imported!")

CODE/_debug.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
import psutil
1010
import requests
1111

12-
from logicytics import Log, DEBUG, VERSION, Check
12+
from logicytics import Log, DEBUG, VERSION, Check, config
1313

1414
log_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "ACCESS\\LOGS\\DEBUG\\DEBUG.log")
1515
log = Log({"log_level": DEBUG, "filename": log_path, "truncate_message": False, "delete_log": True})
16+
url = config.get("System Settings", "config_url")
1617

1718

1819
class VersionManager:
@@ -149,10 +150,9 @@ def get_online_config() -> dict | None:
149150
Retrieves configuration data from a remote repository.
150151
"""
151152
try:
152-
url = "https://raw.githubusercontent.com/DefinetlyNotAI/Logicytics/main/CODE/config.ini"
153-
config = configparser.ConfigParser()
154-
config.read_string(requests.get(url, timeout=15).text)
155-
return config
153+
_config = configparser.ConfigParser()
154+
_config.read_string(requests.get(url, timeout=15).text)
155+
return _config
156156
except requests.exceptions.RequestException as e:
157157
log.error(f"Connection error: {e}")
158158
return None
@@ -194,12 +194,12 @@ def debug():
194194
Executes a comprehensive system debug routine, performing various checks and logging system information.
195195
"""
196196
# Online Configuration Check
197-
config = ConfigManager.get_online_config()
198-
if config:
199-
HealthCheck.check_versions(VERSION, config["System Settings"]["version"])
197+
_config = ConfigManager.get_online_config()
198+
if _config:
199+
HealthCheck.check_versions(VERSION, _config["System Settings"]["version"])
200200

201201
# File Integrity Check
202-
required_files = config["System Settings"].get("files", "").split(",")
202+
required_files = _config["System Settings"].get("files", "").split(",")
203203
FileManager.check_required_files(".", required_files)
204204

205205
# SysInternal Binaries Check

CODE/_dev.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def color_print(text, color="reset", is_input=False) -> None | str:
2323
return input(f"{color_code}{text}{colors['reset']}")
2424
else:
2525
print(f"{color_code}{text}{colors['reset']}")
26+
return None
2627

2728

2829
def _update_ini_file(filename: str, new_data: list | str, key: str) -> None:
@@ -88,6 +89,7 @@ def _prompt_user(question: str, file_to_open: str = None, special: bool = False)
8889
return True
8990
except Exception as e:
9091
color_print(f"[x] {e}", "red")
92+
return None
9193

9294

9395
def _perform_checks() -> bool:

CODE/bluetooth_details.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import json
44
import subprocess
5+
from typing import TextIO
56

67
from logicytics import log
78

@@ -84,7 +85,7 @@ def _query_bluetooth_devices() -> bool | list[dict[str, str]]:
8485
return device_info_list
8586

8687

87-
def _write_device_info_to_file(devices, filename):
88+
def _write_device_info_to_file(devices: list[dict[str, str]], filename: str):
8889
"""
8990
Writes the details of Bluetooth devices to a specified file.
9091
@@ -109,7 +110,7 @@ def _write_device_info_to_file(devices, filename):
109110
log.error(f"Failed to write device information to file: {e}")
110111

111112

112-
def _write_single_device_info(file, device_info):
113+
def _write_single_device_info(file: TextIO, device_info: dict[str, str]):
113114
"""
114115
Writes detailed information for a single Bluetooth device to the specified file.
115116

CODE/bluetooth_logger.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import datetime
22
import re
33
import subprocess
4+
from typing import LiteralString
45

56
from logicytics import log
67

78

89
# Utility function to log data to a file
9-
def save_to_file(filename, section_title, data):
10+
def save_to_file(filename: str, section_title: str, data: str):
1011
"""
1112
Appends data to a file with a section title.
1213
@@ -35,7 +36,7 @@ def save_to_file(filename, section_title, data):
3536

3637

3738
# Utility function to run PowerShell commands
38-
def run_powershell_command(command):
39+
def run_powershell_command(command: str) -> None | list[LiteralString]:
3940
"""
4041
Runs a PowerShell command and returns the output as a list of lines.
4142
@@ -67,7 +68,7 @@ def run_powershell_command(command):
6768

6869

6970
# Unified parsing function for PowerShell output
70-
def parse_output(lines, regex, group_names):
71+
def parse_output(lines: list[LiteralString], regex: str, group_names: list[str]):
7172
"""
7273
Parses the output lines using the provided regex and group names.
7374
@@ -101,7 +102,7 @@ def parse_output(lines, regex, group_names):
101102

102103

103104
# Function to get paired Bluetooth devices
104-
def get_paired_bluetooth_devices():
105+
def get_paired_bluetooth_devices() -> list[str]:
105106
"""
106107
Retrieves a list of paired Bluetooth devices with their names and MAC addresses.
107108

CODE/config.ini

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[Settings]
66
# Would you like to enable debug mode?
77
# This will print out more information to the console, with prefix DEBUG
8-
# This will not be logged however
8+
# This will not be logged however, and is useful for developers - This is different than the DEBUGGER itself
99
log_using_debug = false
1010

1111
# Would you like for new logs to be created every execution?
@@ -28,6 +28,7 @@ save_preferences = true
2828
# Dev Mode allows a safe way to modify these settings!!
2929
version = 3.4.1
3030
files = "bluetooth_details.py, bluetooth_logger.py, browser_miner.ps1, cmd_commands.py, config.ini, dir_list.py, dump_memory.py, event_log.py, Logicytics.py, log_miner.py, media_backup.py, netadapter.ps1, network_psutil.py, packet_sniffer.py, property_scraper.ps1, registry.py, sensitive_data_miner.py, ssh_miner.py, sys_internal.py, tasklist.py, tree.ps1, vulnscan.py, wifi_stealer.py, window_feature_miner.ps1, wmic.py, logicytics\Checks.py, logicytics\Config.py, logicytics\Execute.py, logicytics\FileManagement.py, logicytics\Flag.py, logicytics\Get.py, logicytics\Logger.py, logicytics\User_History.json.gz, VulnScan\Model SenseMini .3n3.pth, VulnScan\README.md, VulnScan\Vectorizer .3n3.pkl"
31+
config_url = https://raw.githubusercontent.com/DefinetlyNotAI/Logicytics/main/CODE/config.ini
3132

3233
########################################################
3334
# The following settings are for specific modules #
@@ -97,10 +98,17 @@ timeout = 10
9798
max_retry_time = 30
9899

99100
###################################################
101+
[VulnScan Settings]
102+
# Following extensions to be skipped by the model
103+
unreadable_extensions = .exe,.dll,.so,.zip,.tar,.gz,.7z,.rar,.jpg,.jpeg,.png,.gif,.bmp,.tiff,.webp,.mp3,.wav,.flac,.aac,.ogg,.mp4,.mkv,.avi,.mov,.wmv,.flv,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.odt,.ods,.odp,.bin,.dat,.iso,.class,.pyc,.o,.obj,.sqlite,.db,.ttf,.otf,.woff,.woff2,.lnk,.url
104+
# In MB, max file size that the model is allowed to scan, if commented out disables the limit, you can also just say None
105+
max_file_size_mb = None
106+
# Max workers to be used, either integer or use auto to make it decide the best value
107+
max_workers = auto
100108

101109
[VulnScan.generate Settings]
102110
# The following settings are for the Generate module for fake training data
103-
extensions = .txt, .log, .md, .csv, .json, .xml, .html, .yaml, .ini, .pdf, .docx, .xlsx, .pptx
111+
extensions = .txt,.log,.md,.csv,.json,.xml,.html,.yaml,.ini,.pdf,.docx,.xlsx,.pptx
104112
save_path = PATH
105113

106114
# Options include:

0 commit comments

Comments
 (0)