-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaccount-generator.py
405 lines (337 loc) · 10.7 KB
/
account-generator.py
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# made by V¡ktor
# Account Generator
parameters = {
"community-link": None,
"save-path": "accounts-generared.json",
"proxies-path": "https-proxy.txt"
}
import os
from random import randint, choice, shuffle
from hmac import new
from json import dumps, loads, dump
from pathlib import Path
from hashlib import sha1
from string import ascii_letters, digits
from bs4 import BeautifulSoup
from threading import Thread
from contextlib import suppress
from uuid import uuid4 as uuid_generator
from base64 import b64encode
from time import (
time as timestamp,
sleep
)
try: os.system("pip install -r requirements.txt")
finally:
from flask import Flask
import names
from requests import Session
from secmail import SecMail
PREFIX = "19"
SIGKEY = "dfa5ed192dda6e88a12fe12130dc6206b1251e44"
DEVKEY = "e7309ecc0953c6fa60005b2765f99dbbc965c8e9"
#-----------------FLASK-APP-----------------
flask_app = Flask(__name__)
@flask_app.route('/')
def home(): return "Account Generator is on! :b"
ht = '0.0.0.0'
pt = randint(2000, 9000)
def run(): flask_app.run(host=ht, port=pt)
#----------------------------------------------------
class LimitationError(Exception): pass
class TooManyRequests(Exception): pass
full_path = lambda filename: os.path.abspath(
os.path.join(
os.path.dirname(__file__),
filename
)
)
clear = lambda: os.system('cls' if os.name=='nt' else 'clear')
RED = lambda *text: "\033[1;31m" + " ".join(i for i in text) + "\033[0m"
GREEN = lambda *text: "\033[1;32m" + " ".join(i for i in text) + "\033[0m"
YELLOW = lambda *text: "\033[1;33m" + " ".join(i for i in text) + "\033[0m"
class Client:
sid: str = None
uid: str = None
device = None
session = None
proxies = None
uuid = None
def __init__(
self,
device: str = None,
proxies: dict = None
) -> None:
self.session: object = Session()
self.device: str = device or self.device_gen()
self.proxies: dict = proxies or {}
self.uuid = str(uuid_generator())
def device_gen(
self,
id: bytes = os.urandom(20)
) -> str:
device_info: bytes = bytes.fromhex(PREFIX) + id
new_device: str = (
device_info + new(
bytes.fromhex(DEVKEY),
device_info,
sha1
).digest()
).hex().upper()
return new_device
def sig(
self,
data: str = None
) -> str:
signature: str = b64encode(
bytes.fromhex(PREFIX) + new(
bytes.fromhex(SIGKEY),
data.encode("utf-8"),
sha1
).digest()
).decode("utf-8")
return signature
def headers(
self,
data: str = None
) -> dict:
headers = {
"NDCDEVICEID": self.device,
"SMDEVICEID": self.uuid,
"Accept-Language": "en-US",
"Content-Type":
"application/x-www-form-urlencoded; charset=utf-8",
"User-Agent":
'Apple iPhone12,1 iOS v15.5 Main/3.12.2',
"Host": "service.narvii.com",
"Accept-Encoding": "gzip",
"Connection": "Keep-Alive"
}
if data is not None:
headers["Content-Length"] = str(len(data))
headers["NDC-MSG-SIG"] = self.sig(data)
if self.sid is not None:
headers["NDCAUTH"] = "sid=%s" % self.sid
return headers
def request(
self,
method: ["DELETE", "GET", "POST", "PUT"],
url: str = "",
data: str = None,
**kwargs: dict
) -> object:
kwargs = {
"data": data,
"headers": self.headers(data = data),
"method": method.upper(),
"proxies": self.proxies or {},
"url": "https://service.aminoapps.com/api/v1/%s" % url
}
with self.session.request(**kwargs) as response:
if response.status_code != 200:
if response.status_code in [403]:
raise LimitationError(response.text)
elif response.status_code in [400]:
if "3 accounts" in response.json()["api:message"]:
raise LimitationError(response.json())
raise TooManyRequests(response.json())
raise Exception([response.status_code, response.text])
return response
def register(
self,
email: str,
password: str,
nickname: str,
code: str
) -> dict:
data = dumps({
"address": None,
"clientCallbackURL": "narviiapp://relogin",
"clientType": 100,
"deviceID": self.device,
"email": email,
"identity": email,
"latitude": 0,
"longitude": 0,
"nickname": nickname,
"secret": "0 %s" % password,
"timestamp": int(timestamp() * 1000),
"type": 1,
"validationContext": {
"data": {
"code": str(code)
},
"type": 1,
"identity": email
}
})
return self.request(
method = "POST",
url = "g/s/auth/register",
data = data
).json()
def request_verify_code(
self,
email: str,
password: bool = False
) -> dict:
data = {
"deviceID": self.device,
"identity": email,
"type": 1
}
if password is not False:
data["level"] = 2
data["purpose"] = "reset-password"
data = dumps(data)
return self.request(
method = "POST",
url = "g/s/auth/request-security-validation",
data=data
).json()
def login(
self,
email: str,
password: str
) -> dict:
data = dumps({
"email": email,
"v": 2,
"secret": f"0 {password}",
"deviceID": self.device,
"clientType": 100,
"action": "normal",
"timestamp": int(timestamp() * 1000)
})
login = self.request(
method = "POST",
url = "g/s/auth/login",
data = data
).json()
self.sid = login["sid"]
self.uid = login["account"]["uid"]
self.secret = login["secret"]
return login
class AccountGenerator:
# Class to Generate One Account
account: dict = {}
email = None
password = None
device = None
def __init__(
self,
proxies: dict = None
) -> None:
amino: object = Client(proxies=proxies)
email = self.get_new_email(1)
print(GREEN("\n~ Generating account for:"), email)
sleep(2)
password = self.get_new_password(10)
print(GREEN("~ Password:"), "*" * len(password))
nickname = self.get_new_nickname()
amino.request_verify_code(email=email)
sleep(4)
captcha = self.get_captcha(email)
print(GREEN("~ Captcha:"), captcha)
code = self.captcha_solver(captcha)
print(GREEN("~ Code:"), code)
sleep(2)
account = amino.register(
email=email,
password=password,
nickname=nickname,
code=code
)
with suppress(Exception):
amino.login(email, password)
self.account = {
"email": email,
"password": password,
"secret": amino.secret,
"device": amino.device,
"sid": amino.sid,
"uid": amino.uid
}
print(YELLOW("~ Account saved!"))
def get_new_email(
self,
count: int=None
) -> str:
return SecMail().generate_email(
count = count or 1
)
def get_new_password(
self,
length: int = 6,
characters = list(ascii_letters + digits + "@#&"*2)
) -> str:
shuffle(characters)
return "".join(choice(characters) for _ in range(int(length)))
def get_new_nickname(self) -> str:
return names.get_full_name(
gender = choice(["male", "female"])
)
def get_captcha(self, email: str) -> str:
inbox = SecMail().get_messages(email = email)
for id in inbox.id:
with suppress(Exception):
msg = SecMail().read_message(
email = email, id = id
).htmlBody
images = BeautifulSoup(
msg, "html.parser"
).find_all("a")[0]
url = images['href']
if url is not None:
return url
def captcha_solver(
self,
captcha: str,
session: object = Session()
) -> str:
return session.post(
"https://captcha-solver-iukzq.run-eu-central1.goorm.app/predict", json={"url": captcha}
).json()['prediction']
def get_proxies() -> object:
if not (path := parameters.get("proxies-path", False)):
raise Exception("Invalid proxies-path: %r" % path)
try:
proxy_path_name = full_path(parameters["proxies-path"])
with open(proxy_path_name, "r") as proxy_path:
yield from [{
"https": proxy.replace("https://", "")
} for proxy in proxy_path.read().split()
]
except FileNotFoundError:
print(GREEN(
"\n~ %r file isn't in this this generator path."
"Run `proxy-gen.py`."
) % parameters["proxies-path"]
); exit(1)
if __name__ == "__main__":
Thread(target=run).start()
sleep(2); clear()
save_path_name = full_path(parameters["save-path"])
try: accounts: list = loads(open(save_path_name).read())
except: accounts: list = []
proxies: object = get_proxies()
proxy = None
while True:
try:
accounts.append(AccountGenerator(proxies=proxy).account)
with open(save_path_name, "w") as save_path:
dump(accounts, save_path, indent=4, sort_keys=True)
except LimitationError:
try: proxy: str = next(proxies)
except StopIteration:
proxies: object = get_proxies()
proxy: str = next(proxies)
finally:
print(GREEN("~ Proxy updated:"), proxy)
sleep(3)
except TooManyRequests as Error:
print(RED("~ Error %d:" % Error.args[0]["api:statuscode"], Error.args[0]["api:message"]))
sleep(5)
except Exception as Error:
print(RED("~ Error:" % Error.args[0]))
sleep(3)