authlyx-api 2.1.0__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {authlyx_api-2.1.0/src/authlyx_api.egg-info → authlyx_api-2.2.0}/PKG-INFO +1 -1
- {authlyx_api-2.1.0 → authlyx_api-2.2.0}/pyproject.toml +1 -1
- {authlyx_api-2.1.0 → authlyx_api-2.2.0}/src/authlyx_api/sdk.py +152 -10
- {authlyx_api-2.1.0 → authlyx_api-2.2.0/src/authlyx_api.egg-info}/PKG-INFO +1 -1
- {authlyx_api-2.1.0 → authlyx_api-2.2.0}/LICENSE +0 -0
- {authlyx_api-2.1.0 → authlyx_api-2.2.0}/README.md +0 -0
- {authlyx_api-2.1.0 → authlyx_api-2.2.0}/setup.cfg +0 -0
- {authlyx_api-2.1.0 → authlyx_api-2.2.0}/src/authlyx_api/__init__.py +0 -0
- {authlyx_api-2.1.0 → authlyx_api-2.2.0}/src/authlyx_api.egg-info/SOURCES.txt +0 -0
- {authlyx_api-2.1.0 → authlyx_api-2.2.0}/src/authlyx_api.egg-info/dependency_links.txt +0 -0
- {authlyx_api-2.1.0 → authlyx_api-2.2.0}/src/authlyx_api.egg-info/requires.txt +0 -0
- {authlyx_api-2.1.0 → authlyx_api-2.2.0}/src/authlyx_api.egg-info/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# AuthlyX SDK Version 2.
|
|
1
|
+
# AuthlyX SDK Version 2.2
|
|
2
2
|
import requests
|
|
3
3
|
import json
|
|
4
4
|
import uuid
|
|
@@ -8,6 +8,9 @@ import sys
|
|
|
8
8
|
import re
|
|
9
9
|
import time
|
|
10
10
|
import subprocess
|
|
11
|
+
import socket
|
|
12
|
+
import threading
|
|
13
|
+
import ssl
|
|
11
14
|
from datetime import datetime, timezone
|
|
12
15
|
import ctypes
|
|
13
16
|
import webbrowser
|
|
@@ -65,6 +68,11 @@ class AuthlyXLogger:
|
|
|
65
68
|
root = os.path.join(program_data, "AuthlyX", app)
|
|
66
69
|
os.makedirs(root, exist_ok=True)
|
|
67
70
|
log_path = os.path.join(root, f"{datetime.now(timezone.utc):%Y_%m_%d}.log")
|
|
71
|
+
if os.path.exists(log_path) and os.path.getsize(log_path) > 5 * 1024 * 1024:
|
|
72
|
+
old_path = os.path.join(root, f"{datetime.now(timezone.utc):%Y_%m_%d}_old.log")
|
|
73
|
+
if os.path.exists(old_path):
|
|
74
|
+
os.remove(old_path)
|
|
75
|
+
os.rename(log_path, old_path)
|
|
68
76
|
line = f"[{datetime.now(timezone.utc):%H:%M:%S}] {AuthlyXLogger._mask_sensitive(s)}\n"
|
|
69
77
|
with open(log_path, "a", encoding="utf-8") as f:
|
|
70
78
|
f.write(line)
|
|
@@ -77,7 +85,10 @@ class Auth:
|
|
|
77
85
|
IpLookupUrl = "https://api.ipify.org"
|
|
78
86
|
DefaultServerPublicKeyPem = "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAgX5lXPhkadeQozyudzTxDXopdJxYexD5qZ0yEq9UOMU=\n-----END PUBLIC KEY-----"
|
|
79
87
|
|
|
80
|
-
def __init__(self, ownerId, appName, version, secret, debug=True, api=None, serverPublicKeyPem=None, requireSignedResponses=
|
|
88
|
+
def __init__(self, ownerId, appName, version, secret, debug=True, api=None, serverPublicKeyPem=None, requireSignedResponses=True, anti_debug=True):
|
|
89
|
+
self.antiDebug = anti_debug
|
|
90
|
+
if self.antiDebug:
|
|
91
|
+
self._check_debugger()
|
|
81
92
|
self.ownerId = ownerId or ""
|
|
82
93
|
self.appName = appName or ""
|
|
83
94
|
self.version = version or ""
|
|
@@ -236,7 +247,7 @@ class Auth:
|
|
|
236
247
|
if self.cachedPublicIp and now < self.cachedPublicIpExpiresAt:
|
|
237
248
|
return self.cachedPublicIp
|
|
238
249
|
try:
|
|
239
|
-
r = requests.get(Auth.IpLookupUrl, timeout=10)
|
|
250
|
+
r = requests.get(Auth.IpLookupUrl, timeout=10, proxies={})
|
|
240
251
|
ip = (r.text or "").strip()
|
|
241
252
|
if ip:
|
|
242
253
|
self.cachedPublicIp = ip
|
|
@@ -317,6 +328,10 @@ class Auth:
|
|
|
317
328
|
|
|
318
329
|
if isinstance(lic, dict) and lic:
|
|
319
330
|
self.userData["LicenseKey"] = str(lic.get("license_key") or self.userData["LicenseKey"] or "")
|
|
331
|
+
if not self.userData["Username"]:
|
|
332
|
+
self.userData["Username"] = str(lic.get("license_key") or "")
|
|
333
|
+
if not self.userData["Email"]:
|
|
334
|
+
self.userData["Email"] = str(lic.get("email") or "")
|
|
320
335
|
if not self.userData["Subscription"]:
|
|
321
336
|
self.userData["Subscription"] = str(lic.get("subscription") or "")
|
|
322
337
|
lvl = lic.get("subscription_level")
|
|
@@ -324,6 +339,12 @@ class Auth:
|
|
|
324
339
|
self.userData["SubscriptionLevel"] = str(lvl)
|
|
325
340
|
if not self.userData["ExpiryDate"]:
|
|
326
341
|
self.userData["ExpiryDate"] = str(lic.get("expiry_date") or "")
|
|
342
|
+
if not self.userData["LastLogin"]:
|
|
343
|
+
self.userData["LastLogin"] = str(lic.get("last_login") or "")
|
|
344
|
+
if not self.userData["Hwid"]:
|
|
345
|
+
self.userData["Hwid"] = str(lic.get("hwid") or lic.get("sid") or "")
|
|
346
|
+
if not self.userData["IpAddress"]:
|
|
347
|
+
self.userData["IpAddress"] = str(lic.get("ip_address") or "")
|
|
327
348
|
|
|
328
349
|
if isinstance(dev, dict) and dev:
|
|
329
350
|
if not self.userData["Subscription"]:
|
|
@@ -525,7 +546,94 @@ class Auth:
|
|
|
525
546
|
self.chatMessages["NextCursor"] = str(data.get("next_cursor") or "")
|
|
526
547
|
self.chatMessages["HasMore"] = bool(data.get("has_more") or False)
|
|
527
548
|
|
|
549
|
+
def _check_debugger(self):
|
|
550
|
+
if self.antiDebug and sys.gettrace() is not None:
|
|
551
|
+
os._exit(1)
|
|
552
|
+
|
|
553
|
+
def _is_private_ip(self, ip_str):
|
|
554
|
+
try:
|
|
555
|
+
parts = list(map(int, ip_str.split(".")))
|
|
556
|
+
if len(parts) != 4:
|
|
557
|
+
return False
|
|
558
|
+
if parts[0] == 127:
|
|
559
|
+
return True
|
|
560
|
+
if parts[0] == 10:
|
|
561
|
+
return True
|
|
562
|
+
if parts[0] == 172 and 16 <= parts[1] <= 31:
|
|
563
|
+
return True
|
|
564
|
+
if parts[0] == 192 and parts[1] == 168:
|
|
565
|
+
return True
|
|
566
|
+
except Exception:
|
|
567
|
+
pass
|
|
568
|
+
return False
|
|
569
|
+
|
|
570
|
+
def _is_domain_hijacked(self, domain):
|
|
571
|
+
try:
|
|
572
|
+
results = socket.getaddrinfo(domain, None)
|
|
573
|
+
for res in results:
|
|
574
|
+
ip = res[4][0]
|
|
575
|
+
if self._is_private_ip(ip):
|
|
576
|
+
return True
|
|
577
|
+
except Exception:
|
|
578
|
+
pass
|
|
579
|
+
return False
|
|
580
|
+
|
|
581
|
+
def _assert_ssl_issuer(self, response):
|
|
582
|
+
try:
|
|
583
|
+
sock = getattr(response.raw, "connection", None)
|
|
584
|
+
if sock is None:
|
|
585
|
+
return
|
|
586
|
+
sock = getattr(sock, "sock", None)
|
|
587
|
+
if sock is None:
|
|
588
|
+
return
|
|
589
|
+
cert = sock.getpeercert()
|
|
590
|
+
if not cert:
|
|
591
|
+
return
|
|
592
|
+
issuer = dict(x[0] for x in cert.get("issuer", []))
|
|
593
|
+
org = issuer.get("organizationName", "")
|
|
594
|
+
if "Let's Encrypt" not in org and "Google Trust Services" not in org:
|
|
595
|
+
os._exit(1)
|
|
596
|
+
except Exception:
|
|
597
|
+
pass
|
|
598
|
+
|
|
599
|
+
def _start_integrity_heartbeat(self):
|
|
600
|
+
def _tick():
|
|
601
|
+
self._check_debugger()
|
|
602
|
+
t = threading.Timer(60.0, _tick)
|
|
603
|
+
t.daemon = True
|
|
604
|
+
t.start()
|
|
605
|
+
t = threading.Timer(60.0, _tick)
|
|
606
|
+
t.daemon = True
|
|
607
|
+
t.start()
|
|
608
|
+
|
|
609
|
+
def _start_exe_integrity_check(self):
|
|
610
|
+
def _tick():
|
|
611
|
+
try:
|
|
612
|
+
path = sys.executable
|
|
613
|
+
if not path or not os.path.exists(path):
|
|
614
|
+
path = os.path.abspath(sys.argv[0]) if sys.argv and sys.argv[0] else ""
|
|
615
|
+
if path and os.path.exists(path):
|
|
616
|
+
h = hashlib.sha256()
|
|
617
|
+
with open(path, "rb") as f:
|
|
618
|
+
while True:
|
|
619
|
+
b = f.read(1024 * 1024)
|
|
620
|
+
if not b:
|
|
621
|
+
break
|
|
622
|
+
h.update(b)
|
|
623
|
+
if self.antiDebug and h.hexdigest() != self._original_hash:
|
|
624
|
+
os._exit(1)
|
|
625
|
+
except Exception:
|
|
626
|
+
pass
|
|
627
|
+
t = threading.Timer(120.0, _tick)
|
|
628
|
+
t.daemon = True
|
|
629
|
+
t.start()
|
|
630
|
+
t = threading.Timer(120.0, _tick)
|
|
631
|
+
t.daemon = True
|
|
632
|
+
t.start()
|
|
633
|
+
|
|
528
634
|
def _post_json(self, endpoint, payload):
|
|
635
|
+
if self.antiDebug and self._is_domain_hijacked("authly.cc"):
|
|
636
|
+
os._exit(1)
|
|
529
637
|
self._reset_response()
|
|
530
638
|
if payload is None or not isinstance(payload, dict):
|
|
531
639
|
return self._set_failure("INVALID_PAYLOAD", "Payload cannot be null.")
|
|
@@ -548,8 +656,27 @@ class Auth:
|
|
|
548
656
|
"x-auth-timestamp": str(ts),
|
|
549
657
|
}
|
|
550
658
|
|
|
659
|
+
max_attempts = 3
|
|
660
|
+
retry_delays = [1.0, 2.0]
|
|
661
|
+
|
|
662
|
+
for attempt in range(1, max_attempts + 1):
|
|
663
|
+
session = requests.Session()
|
|
664
|
+
session.hooks["response"].append(lambda r, *a, **kw: self._assert_ssl_issuer(r))
|
|
665
|
+
try:
|
|
666
|
+
r = session.post(url, data=body.encode("utf-8"), headers=headers, timeout=30, proxies={})
|
|
667
|
+
break
|
|
668
|
+
except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as ex:
|
|
669
|
+
AuthlyXLogger.Log(f"[SDK] Network error on attempt {attempt}: {str(ex)}")
|
|
670
|
+
if attempt < max_attempts:
|
|
671
|
+
time.sleep(retry_delays[attempt - 1])
|
|
672
|
+
continue
|
|
673
|
+
return self._set_failure("NETWORK_ERROR", f"Network error after {max_attempts} attempts: {str(ex)}")
|
|
674
|
+
except requests.exceptions.RequestException as ex:
|
|
675
|
+
return self._set_failure("NETWORK_ERROR", f"Network error: {str(ex)}")
|
|
676
|
+
else:
|
|
677
|
+
return self._set_failure("NETWORK_ERROR", "Request failed after all retry attempts.")
|
|
678
|
+
|
|
551
679
|
try:
|
|
552
|
-
r = requests.post(url, data=body.encode("utf-8"), headers=headers, timeout=30)
|
|
553
680
|
raw = r.text or ""
|
|
554
681
|
AuthlyXLogger.Log(f"[SDK][RESPONSE] {r.status_code} {raw}")
|
|
555
682
|
|
|
@@ -594,10 +721,6 @@ class Auth:
|
|
|
594
721
|
self._load_chat_data(obj)
|
|
595
722
|
|
|
596
723
|
return bool(self.response["success"])
|
|
597
|
-
except requests.exceptions.Timeout as ex:
|
|
598
|
-
return self._set_failure("TIMEOUT", f"Request timed out: {str(ex)}")
|
|
599
|
-
except requests.exceptions.RequestException as ex:
|
|
600
|
-
return self._set_failure("NETWORK_ERROR", f"Network error: {str(ex)}")
|
|
601
724
|
except Exception as ex:
|
|
602
725
|
return self._set_failure("SDK_ERROR", f"Unexpected SDK error: {str(ex)}")
|
|
603
726
|
|
|
@@ -621,6 +744,9 @@ class Auth:
|
|
|
621
744
|
self._prompt_update_if_needed(force_show=(self.response.get("code") == "UPDATE_REQUIRED"))
|
|
622
745
|
if ok and self.sessionId:
|
|
623
746
|
self.initialized = True
|
|
747
|
+
self._original_hash = self.applicationHash
|
|
748
|
+
self._start_integrity_heartbeat()
|
|
749
|
+
self._start_exe_integrity_check()
|
|
624
750
|
return bool(self.initialized)
|
|
625
751
|
|
|
626
752
|
def Login(self, identifier, password=None, deviceType=None):
|
|
@@ -640,7 +766,10 @@ class Auth:
|
|
|
640
766
|
"sid": self._get_system_identifier(),
|
|
641
767
|
"ip": self._get_public_ip(),
|
|
642
768
|
}
|
|
643
|
-
|
|
769
|
+
ok = self._post_json("login", payload)
|
|
770
|
+
if ok:
|
|
771
|
+
self.CheckBlacklist()
|
|
772
|
+
return ok
|
|
644
773
|
|
|
645
774
|
def LicenseLogin(self, licenseKey):
|
|
646
775
|
if not self._ensure_initialized():
|
|
@@ -651,7 +780,10 @@ class Auth:
|
|
|
651
780
|
"sid": self._get_system_identifier(),
|
|
652
781
|
"ip": self._get_public_ip(),
|
|
653
782
|
}
|
|
654
|
-
|
|
783
|
+
ok = self._post_json("licenses", payload)
|
|
784
|
+
if ok:
|
|
785
|
+
self.CheckBlacklist()
|
|
786
|
+
return ok
|
|
655
787
|
|
|
656
788
|
def DeviceLogin(self, deviceType, deviceId):
|
|
657
789
|
if not self._ensure_initialized():
|
|
@@ -744,6 +876,16 @@ class Auth:
|
|
|
744
876
|
payload = {"session_id": self.sessionId}
|
|
745
877
|
return self._post_json("validate-session", payload)
|
|
746
878
|
|
|
879
|
+
def CheckBlacklist(self):
|
|
880
|
+
if not self._ensure_initialized():
|
|
881
|
+
return False
|
|
882
|
+
payload = {
|
|
883
|
+
"session_id": self.sessionId,
|
|
884
|
+
"hwid": self._get_system_identifier(),
|
|
885
|
+
"ip": self._get_public_ip(),
|
|
886
|
+
}
|
|
887
|
+
return self._post_json("blacklist/check", payload)
|
|
888
|
+
|
|
747
889
|
def IsInitialized(self):
|
|
748
890
|
return bool(self.initialized)
|
|
749
891
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|