Skip to content

Commit c1c09c9

Browse files
committed
🚀 (code): 2.0.0!
1 parent 986c23b commit c1c09c9

21 files changed

Lines changed: 794 additions & 225 deletions

examples/keyauth.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
1212
from pyprotector.keyauth import Keyauth
1313
from pyprotector.keyauth.utils import getchecksum
1414

15-
auth = Keyauth(name="", ownerid="", secret="", version="", file_hash=getchecksum())
15+
auth = Keyauth(
16+
name="",
17+
ownerid="",
18+
secret="",
19+
version="",
20+
file_hash=getchecksum())
1621

1722
app = auth.initialize()
18-
print(
19-
app
20-
) # "Keyauth App ({self.version}) with {self.users} users, {self.keys} keys and {self.onlineUsers} online users"
23+
# "Keyauth App ({self.version}) with {self.users} users, {self.keys} keys and {self.onlineUsers} online users"
24+
print(app)
2125

2226
license = auth.license("LICENSE")
2327
print(license.current_subscription)
2428
print(license.last_login)
2529
print(license.expiry)
2630

27-
### All Other Functions are documented.
31+
# All Other Functions are documented.

pyproject.toml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1-
[tool.ruff]
2-
extend-select = ["C4", "SIM"]
3-
ignore = []
1+
[project]
2+
name = "pythonprotector"
3+
version = "2.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.13"
7+
dependencies = [
8+
"command_runner>=1.5.0",
9+
"cryptography>=44.0.0",
10+
"discord_webhook>=1.1.0",
11+
"httpx>=0.28.1",
12+
"humanize>=4.6.0",
13+
"loguru>=0.7.3",
14+
"observable>=1.0.3",
15+
"psutil>=6.1.0",
16+
"py_cpuinfo>=9.0.0",
17+
"pywin32>=308",
18+
"requests>=2.31.0",
19+
"setuptools>=75.6.0",
20+
"WMI>=1.5.1",
21+
"Pillow>=11.0.0",
22+
]
23+
24+
[build-system]
25+
requires = ["hatchling"]
26+
build-backend = "hatchling.build"
27+
28+
[tool.hatch.build.targets.wheel]
29+
packages = ["pythonprotector"]
30+
31+
[dependency-groups]
32+
dev = ["black", "autopep8", "autoflake"]

pyprotector/abc.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
Made With ❤️ By Ghoul & Marci
1010
"""
1111

12-
1312
from abc import ABCMeta, abstractmethod
1413

1514

pyprotector/constants.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@ class UserInfo:
2828
USERNAME: Final[str] = os.getlogin()
2929
PC_NAME: Final[str] = os.getenv("COMPUTERNAME")
3030
IP: Final[str] = getIPAddress()
31-
HWID: Final[str] = (
32-
subprocess.check_output("wmic csproduct get uuid")
33-
.decode()
34-
.split("\n")[1]
35-
.strip()
36-
)
3731
COMPUTER: Any = wmi.WMI()
32+
HWID: Final[str] = COMPUTER.Win32_ComputerSystemProduct()[0].UUID
3833
MAC: Final[str] = ":".join(re.findall("..", "%012x" % uuid.getnode()))
3934
GPU: Final[str] = COMPUTER.Win32_VideoController()[0].Name
4035

@@ -45,14 +40,15 @@ class LoggingInfo:
4540
CIPHER: Fernet = Fernet(KEY)
4641

4742
def encrypted_formatter(record) -> str:
48-
encrypted: bytes = LoggingInfo.CIPHER.encrypt(record["message"].encode("utf8"))
43+
encrypted: bytes = LoggingInfo.CIPHER.encrypt(
44+
record["message"].encode("utf8"))
4945
record["extra"]["encrypted"] = b64encode(encrypted).decode("latin1")
5046
return "[{time:YYYY-MM-DD HH:mm:ss}] {module}::{function}({line}) - {extra[encrypted]}\n{exception}"
5147

5248

5349
@final
5450
class ProtectorInfo:
55-
VERSION: Final[str] = "1.8"
51+
VERSION: Final[str] = "2.0"
5652
ROOT_PATH: str = os.path.abspath(os.curdir)
5753

5854

@@ -61,9 +57,9 @@ class EmbedConfig:
6157
COLOR: Final[str] = "5865F2"
6258
TITLE: Final[str] = f"PythonProtector - {ProtectorInfo.VERSION}"
6359
VERSION: Final[str] = ProtectorInfo.VERSION
64-
ICON: Final[
65-
str
66-
] = "https://thereisabotforthat-storage.s3.amazonaws.com/1548526271231_security%20bot%20logo.png"
60+
ICON: Final[str] = (
61+
"https://thereisabotforthat-storage.s3.amazonaws.com/1548526271231_security%20bot%20logo.png"
62+
)
6763

6864

6965
@final

pyprotector/keyauth/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"""
1111

1212
from .utils import *
13-
from .keyauth import Keyauth
13+
from .keyauth import Keyauth

pyprotector/keyauth/keyauth.py

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424

2525
class Keyauth:
2626
def __init__(
27-
self, name: str, ownerid: str, secret: str, version: str, file_hash: Optional[str] = ""
27+
self,
28+
name: str,
29+
ownerid: str,
30+
secret: str,
31+
version: str,
32+
file_hash: Optional[str] = "",
2833
) -> None:
2934
self.name: str = name
3035
self.ownerid: str = ownerid
@@ -78,7 +83,8 @@ def initialize(self) -> Union[bool, KeyauthAppData]:
7883
if self.__session_id is not None:
7984
raise RuntimeError("This session has already been initialized!")
8085

81-
self._enc_key: str = SHA256.new(str(uuid.uuid4())[:8].encode()).hexdigest()
86+
self._enc_key: str = SHA256.new(
87+
str(uuid.uuid4())[:8].encode()).hexdigest()
8288

8389
response: Response = self.__request(
8490
self._post_data(
@@ -105,8 +111,11 @@ def initialize(self) -> Union[bool, KeyauthAppData]:
105111
return (self.initialized, KeyauthAppData(response["appinfo"]))
106112

107113
def register(
108-
self, username: str, password: str, license: str, hwid: Optional[str] = None
109-
) -> KeyauthUser:
114+
self,
115+
username: str,
116+
password: str,
117+
license: str,
118+
hwid: Optional[str] = None) -> KeyauthUser:
110119
"""Creates user with license key
111120
Args:
112121
username (str): user's input for username
@@ -154,8 +163,11 @@ def upgrade(self, username: str, key: str) -> KeyauthUser:
154163
KeyauthUser: Upgraded User
155164
"""
156165
response: Response = self.__request(
157-
self._post_data(type="upgrade", data={"username": username, "key": key})
158-
)
166+
self._post_data(
167+
type="upgrade",
168+
data={
169+
"username": username,
170+
"key": key}))
159171

160172
if not response["success"]:
161173
raise RequestError(response["message"])
@@ -184,9 +196,11 @@ def login(
184196
response: Response = self.__request(
185197
self._post_data(
186198
type="login",
187-
data={"username": username, "password": password, "hwid": hwid},
188-
)
189-
)
199+
data={
200+
"username": username,
201+
"password": password,
202+
"hwid": hwid},
203+
))
190204

191205
if not response["success"]:
192206
raise RequestError(response["message"])
@@ -227,7 +241,8 @@ def getOnlineUsers(self) -> Dict:
227241
Returns:
228242
Dict: Dictionary of Online Users
229243
"""
230-
response: Response = self.__request(self._post_data(type="fetchOnline"))
244+
response: Response = self.__request(
245+
self._post_data(type="fetchOnline"))
231246

232247
if not response["success"]:
233248
raise RequestError(response["message"])
@@ -248,8 +263,11 @@ def setvar(self, variable: str, data: str) -> None:
248263
None
249264
"""
250265
response: Response = self.__request(
251-
self._post_data(type="setvar", data={"var": variable, "data": data})
252-
)
266+
self._post_data(
267+
type="setvar",
268+
data={
269+
"var": variable,
270+
"data": data}))
253271

254272
if not response["success"]:
255273
raise RequestError(response["message"])
@@ -417,8 +435,9 @@ def changeUsername(self, username: str) -> bool:
417435
bool: If the username has changed or not
418436
"""
419437
response: Response = self.__request(
420-
self._post_data(type="changeUsername", data={"newUsername": username})
421-
)
438+
self._post_data(
439+
type="changeUsername", data={
440+
"newUsername": username}))
422441

423442
if not response["success"]:
424443
raise RequestError(response["message"])
@@ -433,8 +452,11 @@ def log(self, user: str, message: str) -> None:
433452
message (str): Message
434453
"""
435454
self.__request(
436-
self._post_data(type="log", data={"user": user, "message": message})
437-
)
455+
self._post_data(
456+
type="log",
457+
data={
458+
"user": user,
459+
"message": message}))
438460

439461
def webhook(self, webhook_id: str, params: str) -> None:
440462
"""Send Webhook

pyprotector/keyauth/models.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
99
Made With ❤️ By Ghoul & Marci
1010
"""
11+
1112
from dataclasses import dataclass
1213

1314
from datetime import datetime
@@ -27,7 +28,11 @@ def __init__(self, data: dict) -> None:
2728
self.onlineUsers: int = data["numOnlineUsers"]
2829

2930
def __repr__(self) -> str:
30-
return f"Keyauth App ({self.version}) with {self.users} users, {self.keys} keys and {self.onlineUsers} online users"
31+
return f"Keyauth App ({
32+
self.version}) with {
33+
self.users} users, {
34+
self.keys} keys and {
35+
self.onlineUsers} online users"
3136

3237

3338
class KeyauthUser:
@@ -52,9 +57,8 @@ def __init__(self, data: dict) -> None:
5257
self.current_subscription: Subscription = Subscription(
5358
**data["subscriptions"][0]
5459
)
55-
self.subscriptions: list[Subscription] = [
56-
Subscription(**subscription) for subscription in data["subscriptions"]
57-
]
60+
self.subscriptions: list[Subscription] = [Subscription(
61+
**subscription) for subscription in data["subscriptions"]]
5862

5963
def __repr__(self) -> str:
6064
return self.username
@@ -67,9 +71,8 @@ class KeyauthChat:
6771
timestamp: str
6872

6973
def __post_init__(self) -> None:
70-
self.timestamp = datetime.utcfromtimestamp(int(self.timestamp)).strftime(
71-
"%Y-%m-%d %H:%M:%S"
72-
)
74+
self.timestamp = datetime.utcfromtimestamp(
75+
int(self.timestamp)).strftime("%Y-%m-%d %H:%M:%S")
7376

7477

7578
@dataclass

pyprotector/modules/analysis.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121

2222
class AntiAnalysis(Module):
2323
def __init__(
24-
self, webhook: Webhook, logger: Logger, exit: bool, report: bool, event: Event
25-
) -> None:
24+
self,
25+
webhook: Webhook,
26+
logger: Logger,
27+
exit: bool,
28+
report: bool,
29+
event: Event) -> None:
2630
self.webhook: Webhook = webhook
2731
self.logger: Logger = logger
2832
self.exit: bool = exit
@@ -66,16 +70,18 @@ def CheckDebugPrivilege(self) -> None:
6670
self.ntdll.NtClose(hToken)
6771
return
6872

69-
debug_privilege = (ctypes.c_int * (return_length.value // 8)).from_buffer(
70-
privileges
71-
)
73+
debug_privilege = (ctypes.c_int *
74+
(return_length.value //
75+
8)).from_buffer(privileges)
7276
for priv in debug_privilege:
7377
if priv.s_luid.LowPart == 21 and priv.s_attributes & 0x00000002:
7478
self.ntdll.NtClose(hToken)
7579
if self.report:
7680
self.webhook.send("Debug Privilege Enabled", self.name)
7781
self.event.dispatch(
78-
["debug_privilege_found", "pyprotector_detect"], "Debug Privilege Enabled", self.name
82+
["debug_privilege_found", "pyprotector_detect"],
83+
"Debug Privilege Enabled",
84+
self.name,
7985
)
8086
if self.exit:
8187
os._exit(1)
@@ -96,8 +102,9 @@ def HideThreads(self) -> None:
96102
return
97103

98104
self.ntdll.NtSetInformationThread(
99-
hThread, 0x11, ctypes.byref((ctypes.c_int(1)), ctypes.sizeof(ctypes.c_int))
100-
)
105+
hThread, 0x11, ctypes.byref(
106+
(ctypes.c_int(1)), ctypes.sizeof(
107+
ctypes.c_int)))
101108

102109
self.kernel32.CloseHandle(hThread)
103110
self.kernel32.CloseHandle(hProcess)
@@ -156,7 +163,9 @@ def CheckSEDebugName(self) -> None:
156163
if self.report:
157164
self.webhook.send("Debug Object Handle Detected", self.name)
158165
self.event.dispatch(
159-
["se_debug_name", "pyprotector_detect"], "Debug Object Handle Detected", self.name
166+
["se_debug_name", "pyprotector_detect"],
167+
"Debug Object Handle Detected",
168+
self.name,
160169
)
161170
if self.exit:
162171
os._exit((1))
@@ -184,9 +193,7 @@ def CheckNtGlobalFlag(self) -> None:
184193
)
185194
if self.report:
186195
self.webhook.send(
187-
"NT_GLOBAL_FLAG_DEBUGGED Found in the Process Environment Block",
188-
self.name,
189-
)
196+
"NT_GLOBAL_FLAG_DEBUGGED Found in the Process Environment Block", self.name, )
190197
self.event.dispatch(
191198
["nt_global_flag_debugged", "pyprotector_detect"],
192199
"NT_GLOBAL_FLAG_DEBUGGED Found in the Process Environment Block",
@@ -203,7 +210,8 @@ def CheckHardwareBreakpoints(self) -> None:
203210
if hThread is None:
204211
return
205212

206-
if not self.kernel32.GetThreadContext(hThread, ctypes.byref(ThreadContext)):
213+
if not self.kernel32.GetThreadContext(
214+
hThread, ctypes.byref(ThreadContext)):
207215
self.kernel32.CloseHandle(hThread)
208216
return
209217

0 commit comments

Comments
 (0)