-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthvaultix.py
More file actions
304 lines (252 loc) · 9.27 KB
/
authvaultix.py
File metadata and controls
304 lines (252 loc) · 9.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
from datetime import datetime
import os
import json
import requests
import platform
import binascii
import subprocess
import hashlib
class api:
def __init__(self, name, ownerid, secret, version, api_url):
if not ownerid or len(ownerid) < 10:
raise ValueError("Invalid ownerid")
if not secret or len(secret) < 64:
raise ValueError("Invalid secret")
if not api_url.startswith("http"):
raise ValueError("Invalid API URL")
self.name = name
self.ownerid = ownerid
self.secret = secret
self.version = version
self.api_url = api_url
self.sessionid = ""
self.initialized = False
self.user_data = {}
self.app_data = {}
self.init()
# ================= USER INFO =================
def get_user_info(self):
if not self.user_data:
return None
data = self.user_data
result = {
"username": data.get("username"),
"ip": data.get("ip"),
"hwid": data.get("hwid"),
"created": self._to_local(data.get("createdate")),
"last_login": self._to_local(data.get("lastlogin")),
"expires": self._to_local(data.get("expires")),
"subscriptions": []
}
subs = data.get("subscriptions", [])
for sub in subs:
result["subscriptions"].append({
"name": sub.get("subscription"),
"expiry": self._to_local(sub.get("expiry")),
"timeleft": self._format_timeleft(sub.get("timeleft"))
})
return result
def _to_local(self, ts):
if not ts:
return "N/A"
return datetime.fromtimestamp(int(ts)).strftime('%Y-%m-%d %I:%M:%S %p')
def _format_timeleft(self, seconds):
if not seconds:
return "0d 0h 0m"
seconds = int(seconds)
days = seconds // 86400
hours = (seconds % 86400) // 3600
minutes = (seconds % 3600) // 60
return f"{days}d {hours}h {minutes}m"
# ================= INIT =================
def init(self):
if self.sessionid:
print("Already initialized!")
return
enckey = binascii.hexlify(os.urandom(16)).decode()
post_data = {
"type": "init",
"name": self.name,
"ownerid": self.ownerid,
"ver": self.version,
"enckey": enckey
}
response = self.do_request(post_data)
if response == "Authvaultix_Invalid":
print("Invalid app")
return
data = json.loads(response)
if not data.get("success"):
print("Init failed:", data.get("message"))
return
self.sessionid = data["sessionid"]
self.app_data = data["appinfo"]
self.initialized = True
print("Initialization successful!")
# ================= LOGIN =================
def login(self, username, password, hwid=None):
self._check_init()
if not hwid:
hwid = self.get_hwid()
post_data = {
"type": "login",
"username": username,
"pass": password,
"hwid": hwid,
"sessionid": self.sessionid,
"name": self.name,
"ownerid": self.ownerid
}
data = json.loads(self.do_request(post_data))
if data.get("success"):
self.user_data = data["info"]
print("Login successful!")
return True
else:
print("Login failed:", data.get("message"))
return False
def register(self, username, password, license_key, hwid=None):
self._check_init()
if not hwid:
hwid = self.get_hwid()
post_data = {
"type": "register",
"username": username,
"pass": password,
"key": license_key,
"hwid": hwid,
"sessionid": self.sessionid,
"name": self.name,
"ownerid": self.ownerid
}
response = self.do_request(post_data)
data = json.loads(response)
if data.get("success"):
self.user_data = data["info"]
print("Registration successful!")
else:
print("Registration failed:", data.get("message"))
def license(self, license_key, hwid=None):
self._check_init()
if not hwid:
hwid = self.get_hwid()
post_data = {
"type": "license",
"key": license_key,
"sessionid": self.sessionid,
"name": self.name,
"ownerid": self.ownerid,
"hwid": hwid
}
response = self.do_request(post_data)
data = json.loads(response)
if data.get("success"):
self.user_data = data["info"]
print("License applied successfully!")
else:
print("License failed:", data.get("message"))
def var(self, var_name):
self._check_init()
post_data = {
"type": "var",
"varid": var_name,
"sessionid": self.sessionid,
"name": self.name,
"ownerid": self.ownerid
}
response = self.do_request(post_data)
data = json.loads(response)
if data.get("success"):
return data.get("message")
else:
print("Failed to fetch variable:", data.get("message"))
return None
def setvar(self, var_name, var_data):
self._check_init()
post_data = {
"type": "setvar",
"var": var_name,
"data": var_data,
"sessionid": self.sessionid,
"name": self.name,
"ownerid": self.ownerid
}
response = self.do_request(post_data)
data = json.loads(response)
if data.get("success"):
return True
else:
print("Failed to set variable:", data.get("message"))
return False
def logout(self):
self._check_init()
post_data = {
"type": "logout",
"sessionid": self.sessionid,
"name": self.name,
"ownerid": self.ownerid
}
response = self.do_request(post_data)
data = json.loads(response)
if data.get("success"):
print("Logged out successfully!")
self.sessionid = ""
self.initialized = False
else:
print("Logout failed:", data.get("message"))
# =================== INTERNAL METHODS ===================
def do_request(self, post_data):
try:
response = requests.post(self.api_url, data=post_data, timeout=10)
return response.text
except requests.exceptions.Timeout:
print("Request timed out. Server may be down/slow.")
return "{}"
def _check_init(self):
if not self.initialized:
raise Exception("Client not initialized. Call init() first.")
@staticmethod
def hwid_to_sid(hwid):
try:
parts = [
hwid[0:8],
hwid[8:16],
hwid[16:24],
hwid[24:32]
]
nums = [str(int(p, 16)) for p in parts]
return f"S-1-5-21-{nums[0]}-{nums[1]}-{nums[2]}-{nums[3]}"
except:
return "INVALID_SID"
@staticmethod
def get_hwid():
system = platform.system()
try:
data = ""
if system == "Windows":
cpu = subprocess.check_output("wmic cpu get ProcessorId", shell=True).decode().split("\n")[1].strip()
disk = subprocess.check_output("wmic diskdrive get SerialNumber", shell=True).decode().split("\n")[1].strip()
board = subprocess.check_output("wmic baseboard get SerialNumber", shell=True).decode().split("\n")[1].strip()
guid = subprocess.check_output(
'reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid',
shell=True
).decode().split()[-1]
data = cpu + disk + board + guid
elif system == "Linux":
with open("/etc/machine-id") as f:
machine = f.read().strip()
cpu = subprocess.getoutput("cat /proc/cpuinfo | grep Serial | awk '{print $3}'")
disk = subprocess.getoutput("lsblk -o SERIAL | head -n 2 | tail -n 1")
data = machine + cpu + disk
elif system == "Darwin":
serial = subprocess.check_output(
"system_profiler SPHardwareDataType | grep 'Serial Number'",
shell=True
).decode().split(":")[1].strip()
data = serial
# 🔒 Step 1: Hash
hwid_hash = hashlib.sha256(data.encode()).hexdigest()
# 🔒 Step 2: Convert to SID format
return api.hwid_to_sid(hwid_hash)
except Exception:
return "UNKNOWN_HWID"