Skip to content

Commit 8f59424

Browse files
2.4.0 update codefactor (#130)
## Pull Request Template ### Prerequisites <!-- Take a couple of minutes to help our maintainers work faster by checking of the pre-requisites. --> <!-- To tick the checkboxes replace the space with an 'x', so [ ] becomes [x] . --> - [x] I have [searched](https://github.com/DefinetlyNotAI/Logicytics/pulls) for duplicate or closed issues. - [x] I have read the [contributing guidelines](https://github.com/DefinetlyNotAI/Logicytics/blob/main/CONTRIBUTING.md). - [x] I have followed the instructions in the [wiki](https://github.com/DefinetlyNotAI/Logicytics/wiki) about contributions. - [ ] I have updated the documentation accordingly, if required. - [ ] I have added tests to cover my changes, and they have passed, if required. - [ ] I have tested my code with the `--dev` flag, if required. ### PR Type <!-- Take a couple of minutes to help our maintainers work faster by telling us what is the PR guided on. --> <!-- To tick the checkboxes replace the space with an 'x', so [ ] becomes [x] . --> - [x] Bug fix <!-- Non-Breaking Bug Fix - Usually relates to fixing an issue --> - [ ] New feature <!-- Non-Breaking Change that adds a new feature --> - [ ] Refactoring <!-- Non-Breaking Change that modifies existing code to refactor it to become more organised --> - [ ] Documentation update <!-- Non-Breaking Change that modifies existing documentation to refactor it or add extra comments - either wiki, md files or code is included here --> - [ ] ⚠️ Breaking change ⚠️ <!-- Breaking Bug Fix / New Addition that changes how Logicytics works --> ### Description Fixed some issues, deprecated website, made minor changes ### Motivation and Context Bug issues, and security vulnerabilities ### Binaries <!-- If you have any binaries built from the AIP, Upload them here --> <!-- OPTIONAL for patch updates - To leave empty just type _N/A_ --> _N/A_ ### Credit <!-- If this PR is a contribution, please mention the contributors here using the appropriate syntax. --> _N/A_ <!-- ### File-Created/CONTRIBUTION by MAIN-Username What you did, created, removed, refactored, fixed, or discovered. - [Your GitHub Username](https://github.com/YourGitHubLink) - [Your GitHub Username](https://github.com/YourGitHubLink) etc... --> ### Issues Fixed <!-- REQUIRED: What issues will be fixed? (Format: "#50, #23" etc.) if none exist type _N/A_ --> [Security Advisory GHSA-5wvr-vvqf-668m](GHSA-5wvr-vvqf-668m)
2 parents 0e826bf + dd248b0 commit 8f59424

14 files changed

+154
-222
lines changed

.bandit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# FILE: .bandit
22
[bandit]
3-
skips: ['B607', 'B605']
3+
skips: ['B607', 'B605']

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,4 @@ $RECYCLE.BIN/
312312
*.pyc
313313
/CODE/SysInternal_Suite/.sys.ignore
314314
/ACCESS/
315+
/todo.txt

CODE/__lib_class.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,4 +490,6 @@ def __run_other_script(script: str):
490490

491491
DEBUG, VERSION, API_KEY, CURRENT_FILES = Actions.read_config()
492492
if __name__ == "__main__":
493-
Log().exception("This is a library file and should not be executed directly.", Exception)
493+
Log().exception(
494+
"This is a library file and should not be executed directly.", Exception
495+
)

CODE/__lib_log.py

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ def __init__(self, config: dict = None):
3939
self.filename = config.get("filename", "../ACCESS/LOGS/Logicytics.log")
4040
if self.color:
4141
logger = colorlog.getLogger()
42-
logger.setLevel(
43-
getattr(logging, config["log_level"].upper(), logging.INFO)
44-
)
42+
logger.setLevel(getattr(logging, config["log_level"].upper(), logging.INFO))
4543
handler = colorlog.StreamHandler()
4644
log_colors = {
4745
"INTERNAL": "cyan",
@@ -54,7 +52,10 @@ def __init__(self, config: dict = None):
5452
}
5553

5654
formatter = colorlog.ColoredFormatter(
57-
config.get("colorlog_fmt_parameters", "%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s"),
55+
config.get(
56+
"colorlog_fmt_parameters",
57+
"%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s",
58+
),
5859
log_colors=log_colors,
5960
)
6061

@@ -63,11 +64,19 @@ def __init__(self, config: dict = None):
6364
try:
6465
getattr(logging, config["log_level"].upper())
6566
except AttributeError as AE:
66-
self.__internal(f"Log Level {config['log_level']} not found, setting default level to INFO -> {AE}")
67+
self.__internal(
68+
f"Log Level {config['log_level']} not found, setting default level to INFO -> {AE}"
69+
)
6770

6871
if not os.path.exists(self.filename):
6972
self.newline()
70-
self.raw("| Timestamp | LOG Level |" + " " * 71 + "LOG Messages" + " " * 71 + "|")
73+
self.raw(
74+
"| Timestamp | LOG Level |"
75+
+ " " * 71
76+
+ "LOG Messages"
77+
+ " " * 71
78+
+ "|"
79+
)
7180
self.newline()
7281

7382
@staticmethod
@@ -77,7 +86,7 @@ def __timestamp() -> str:
7786
7887
:return: Current timestamp in 'YYYY-MM-DD HH:MM:SS' format.
7988
"""
80-
return datetime.now().strftime('%Y-%m-%d %H:%M:%S')
89+
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
8190

8291
@staticmethod
8392
def __pad_message(message: str) -> str:
@@ -87,7 +96,11 @@ def __pad_message(message: str) -> str:
8796
:param message: The log message to be padded or truncated.
8897
:return: The padded or truncated message.
8998
"""
90-
return (message + " " * (153 - len(message)) if len(message) < 153 else message[:150] + "...") + "|"
99+
return (
100+
message + " " * (153 - len(message))
101+
if len(message) < 153
102+
else message[:150] + "..."
103+
) + "|"
91104

92105
def raw(self, message):
93106
"""
@@ -97,9 +110,12 @@ def raw(self, message):
97110
"""
98111
frame = inspect.stack()[1]
99112
if frame.function == "<module>":
100-
self.__internal(f"Raw message called from a non-function - This is not recommended")
101-
with open(self.filename, "a") as f:
102-
f.write(f"{str(message)}\n")
113+
self.__internal(
114+
f"Raw message called from a non-function - This is not recommended"
115+
)
116+
if message != "None" and message is not None:
117+
with open(self.filename, "a") as f:
118+
f.write(f"{str(message)}\n")
103119

104120
def newline(self):
105121
"""
@@ -114,39 +130,47 @@ def info(self, message):
114130
115131
:param message: The info message to be logged.
116132
"""
117-
if self.color:
133+
if self.color and message != "None" and message is not None:
118134
colorlog.info(str(message))
119-
self.raw(f"[{self.__timestamp()}] > INFO: | {self.__pad_message(str(message))}")
135+
self.raw(
136+
f"[{self.__timestamp()}] > INFO: | {self.__pad_message(str(message))}"
137+
)
120138

121139
def warning(self, message):
122140
"""
123141
Logs a warning message.
124142
125143
:param message: The warning message to be logged.
126144
"""
127-
if self.color:
145+
if self.color and message != "None" and message is not None:
128146
colorlog.warning(str(message))
129-
self.raw(f"[{self.__timestamp()}] > WARNING: | {self.__pad_message(str(message))}")
147+
self.raw(
148+
f"[{self.__timestamp()}] > WARNING: | {self.__pad_message(str(message))}"
149+
)
130150

131151
def error(self, message):
132152
"""
133153
Logs an error message.
134154
135155
:param message: The error message to be logged.
136156
"""
137-
if self.color:
157+
if self.color and message != "None" and message is not None:
138158
colorlog.error(str(message))
139-
self.raw(f"[{self.__timestamp()}] > ERROR: | {self.__pad_message(str(message))}")
159+
self.raw(
160+
f"[{self.__timestamp()}] > ERROR: | {self.__pad_message(str(message))}"
161+
)
140162

141163
def critical(self, message):
142164
"""
143165
Logs a critical message.
144166
145167
:param message: The critical message to be logged.
146168
"""
147-
if self.color:
169+
if self.color and message != "None" and message is not None:
148170
colorlog.critical(str(message))
149-
self.raw(f"[{self.__timestamp()}] > CRITICAL: | {self.__pad_message(str(message))}")
171+
self.raw(
172+
f"[{self.__timestamp()}] > CRITICAL: | {self.__pad_message(str(message))}"
173+
)
150174

151175
@staticmethod
152176
def debug(message):
@@ -155,7 +179,8 @@ def debug(message):
155179
156180
:param message: The debug message to be logged.
157181
"""
158-
colorlog.debug(str(message))
182+
if message != "None" and message is not None:
183+
colorlog.debug(str(message))
159184

160185
def string(self, message, type: str):
161186
"""
@@ -165,13 +190,14 @@ def string(self, message, type: str):
165190
:param message: The message to be logged.
166191
:param type: The type of the log message.
167192
"""
168-
type_map = {"err": "error", "warn": "warning", "crit": "critical"}
169-
type = type_map.get(type.lower(), type)
170-
try:
171-
getattr(self, type.lower())(str(message))
172-
except AttributeError as AE:
173-
self.__internal(f"A wrong Log Type was called: {type} not found. -> {AE}")
174-
getattr(self, "Debug".lower())(str(message))
193+
if self.color and message != "None" and message is not None:
194+
type_map = {"err": "error", "warn": "warning", "crit": "critical"}
195+
type = type_map.get(type.lower(), type)
196+
try:
197+
getattr(self, type.lower())(str(message))
198+
except AttributeError as AE:
199+
self.__internal(f"A wrong Log Type was called: {type} not found. -> {AE}")
200+
getattr(self, "Debug".lower())(str(message))
175201

176202
def exception(self, message, exception_type: Type = Exception):
177203
"""
@@ -180,7 +206,10 @@ def exception(self, message, exception_type: Type = Exception):
180206
:param message: The exception message to be logged.
181207
:param exception_type: The type of exception to raise.
182208
"""
183-
self.raw(f"[{self.__timestamp()}] > EXCEPTION:| {self.__pad_message(f'{message} -> Exception provoked: {str(exception_type)}')}")
209+
if self.color and message != "None" and message is not None:
210+
self.raw(
211+
f"[{self.__timestamp()}] > EXCEPTION:| {self.__pad_message(f'{message} -> Exception provoked: {str(exception_type)}')}"
212+
)
184213
raise exception_type(message)
185214

186215
def __internal(self, message):
@@ -189,9 +218,11 @@ def __internal(self, message):
189218
190219
:param message: The internal message to be logged.
191220
"""
192-
if self.color:
221+
if self.color and message != "None" and message is not None:
193222
colorlog.log(self.INTERNAL_LOG_LEVEL, str(message))
194223

195224

196225
if __name__ == "__main__":
197-
Log().exception("This is a library file and should not be executed directly.", Exception)
226+
Log().exception(
227+
"This is a library file and should not be executed directly.", Exception
228+
)

CODE/wifi_stealer.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
from __future__ import annotations
2+
13
from __lib_class import *
24

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

68

7-
def get_password(ssid: str) -> str:
9+
def get_password(ssid: str) -> str | None:
810
"""
911
Retrieves the password associated with a given Wi-Fi SSID.
1012
@@ -21,19 +23,25 @@ def get_password(ssid: str) -> str:
2123
command_output = Actions.run_command(
2224
f'netsh wlan show profile name="{ssid}" key=clear'
2325
)
24-
if command_output is None:
25-
return "None"
26-
key_content = command_output.splitlines()
27-
for line in key_content:
28-
if "Key Content" in line:
29-
return line.split(":")[1].strip()
30-
return "None"
31-
except UnicodeDecodeError as err:
32-
log.error(err)
33-
return "None"
26+
if command_output:
27+
key_content = command_output.splitlines()
28+
for line in key_content:
29+
if "Key Content" in line:
30+
return line.split(":")[1].strip()
3431
except Exception as err:
3532
log.error(err)
36-
return "None"
33+
34+
35+
def parse_wifi_names(command_output: str) -> list:
36+
wifi_names = []
37+
38+
for line in command_output.split("\n"):
39+
if "All User Profile" in line:
40+
start_index = line.find("All User Profile") + len("All User Profile")
41+
wifi_name = line[start_index:].strip()
42+
wifi_names.append(wifi_name)
43+
44+
return wifi_names
3745

3846

3947
def get_wifi_names() -> list:
@@ -49,14 +57,7 @@ def get_wifi_names() -> list:
4957
"""
5058
try:
5159
log.info("Retrieving Wi-Fi names...")
52-
command_output = Actions.run_command("netsh wlan show profile")
53-
wifi_names = []
54-
55-
for line in command_output.split("\n"):
56-
if "All User Profile" in line:
57-
start_index = line.find("All User Profile") + len("All User Profile")
58-
wifi_name = line[start_index:].strip()
59-
wifi_names.append(wifi_name)
60+
wifi_names = parse_wifi_names(Actions.run_command("netsh wlan show profile"))
6061
log.info(f"Retrieved {len(wifi_names)} Wi-Fi names.")
6162
return wifi_names
6263
except Exception as err:

WEB/footer-styles.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.footer-content {
2+
background-color: #333;
3+
color: #fff;
4+
text-align: center;
5+
padding: 20px 0;
6+
}
7+
8+
.footer-content p {
9+
margin: 5px 0;
10+
font-size: 14px;
11+
}

0 commit comments

Comments
 (0)