-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
92 lines (65 loc) · 3.12 KB
/
main.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
import requests
import time
import os
import random
import json
import string
from concurrent.futures import ThreadPoolExecutor
from Logger import logging
emails = open('./Input/Mails.txt', 'r').read().splitlines()
config = json.load(open('./config.json', 'r'))
session = requests.Session()
session.headers = {"Authorization": f"Bearer {config["Main"]["Api-Key"]}"}
def generate_password() -> str:
return ''.join(random.choices(string.ascii_lowercase, k=8)) + ''.join(random.choices(string.ascii_uppercase, k=1)) + '!' + ''.join(random.choices(string.digits, k=4))
def format_line(line: str):
parts = line.split(":") if ":" in line else line.split("|") if "|" in line else None
if not parts or len(parts) <= 1 or len(parts) >= 4:
raise logging.error("Incorrect email format.", line)
return parts[0], parts[1]
class NotLetters():
@staticmethod
def change_password(email: str, cpass: str, npass: str):
while True:
try:
payload = {
"email": email,
"new_password": npass,
"old_password": cpass
}
resp = session.post("https://api.notletters.com/v1/change-password", json=payload)
if resp.status_code == 200:
logging.success("Succesfully changed password.", email, resp.status_code)
return True, 'Completed'
elif resp.status_code == 400:
logging.error("Invalid request data.", email, resp.status_code)
return True, 'Unknown_error'
elif resp.status_code == 403:
logging.error("Wrong ApiKey.", email, resp.status_code)
os._exit(1)
elif resp.status_code == 404:
logging.error("Password does not match.", email, resp.status_code)
return True, 'Password_does_not_match'
else:
logging.error(f"Unknown error {resp.text}", email, resp.status_code)
return True, 'Unknown_error'
except Exception as e:
print(e)
time.sleep(1)
def thread(line: str):
email, cpass = format_line(line)
if config["Password"]["Generate_password"] == True:
npass = generate_password()
else:
npass = config["Password"]["new_password"]
result, file = NotLetters.change_password(email, cpass, npass)
if result:
if not os.path.exists(f'./Output/{file}.txt'):
with open(f'./Output/{file}.txt', 'a') as file:
file.write(f"{email}:{npass}\n")
else:
with open(f'./Output/{file}.txt', 'a') as file:
file.write(f"{email}:{npass}\n")
with ThreadPoolExecutor(max_workers=config["Main"]["Threads"]) as executor:
for email in emails:
executor.submit(thread, email)