XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

poe.com update (still patched)

2b30701b
t.me/xtekky <98614666+xtekky@users.noreply.github.com>
提交于

代码差异

4 个文件 +220 -95
Modified quora/__init__.py +47 -62
@@ -1,6 +1,7 @@
1 1 from quora.api import Client as PoeClient
2 from quora.mail import Mail
2 from quora.mail import Emailnator
3 3 from requests import Session
4 from tls_client import Session as TLS
4 5 from re import search, findall
5 6 from json import loads
6 7 from time import sleep
@@ -13,6 +14,9 @@ from hashlib import md5
13 14 from json import dumps
14 15 from pypasser import reCaptchaV3
15 16
17 # from twocaptcha import TwoCaptcha
18 # solver = TwoCaptcha('72747bf24a9d89b4dcc1b24875efd358')
19
16 20 def extract_formkey(html):
17 21 script_regex = r'<script>if\(.+\)throw new Error;(.+)</script>'
18 22 script_text = search(script_regex, html).group(1)
@@ -157,50 +161,54 @@ class Model:
157 161
158 162 return ModelResponse(response.json())
159 163
164
160 165 class Account:
161 166 def create(proxy: None or str = None, logging: bool = False, enable_bot_creation: bool = False):
162 client = Session()
167 client = TLS(client_identifier='chrome110')
163 168 client.proxies = {
164 169 'http': f'http://{proxy}',
165 170 'https': f'http://{proxy}'} if proxy else None
166 171
167 mail = Mail(client.proxies)
168 mail_token = None
169 _, mail_address = mail.get_mail()
170 if mail_address is None:
171 raise Exception('Error creating mail, please use proxies')
172 mail_client = Emailnator()
173 mail_address = mail_client.get_mail()
172 174
173 175 if logging: print('email', mail_address)
174 176
175 177 client.headers = {
176 "host" : "poe.com",
177 "connection" : "keep-alive",
178 "cache-control" : "max-age=0",
179 "sec-ch-ua" : "\"Microsoft Edge\";v=\"111\", \"Not(A:Brand\";v=\"8\", \"Chromium\";v=\"111\"",
180 "sec-ch-ua-mobile" : "?0",
181 "sec-ch-ua-platform": "\"macOS\"",
182 "user-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.54",
183 "accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
184 "sec-fetch-site" : "same-origin",
185 "sec-fetch-mode" : "navigate",
186 "content-type" : "application/json",
187 "sec-fetch-user" : "?1",
188 "sec-fetch-dest" : "document",
189 "accept-encoding" : "gzip, deflate, br",
190 "accept-language" : "en-GB,en;q=0.9,en-US;q=0.8",
191 "upgrade-insecure-requests": "1",
178 'authority' : 'poe.com',
179 'accept' : '*/*',
180 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
181 'content-type' : 'application/json',
182 'origin' : 'https://poe.com',
183 'poe-formkey' : 'null',
184 'poe-tag-id' : 'null',
185 'poe-tchannel' : 'null',
186 'referer' : 'https://poe.com/login',
187 'sec-ch-ua' : '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
188 'sec-ch-ua-mobile' : '?0',
189 'sec-ch-ua-platform': '"macOS"',
190 'sec-fetch-dest': 'empty',
191 'sec-fetch-mode': 'cors',
192 'sec-fetch-site': 'same-origin',
193 'user-agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
192 194 }
193 195
194 196 client.headers["poe-formkey"] = extract_formkey(client.get('https://poe.com/login').text)
195 197 client.headers["poe-tchannel"] = client.get('https://poe.com/api/settings').json()['tchannelData']['channel']
196 198
197 token = reCaptchaV3('https://www.recaptcha.net/recaptcha/enterprise/anchor?ar=1&k=6LflhEElAAAAAI_ewVwRWI9hsyV4mbZnYAslSvlG&co=aHR0cHM6Ly9wb2UuY29tOjQ0Mw..&hl=en&v=vkGiR-M4noX1963Xi_DB0JeI&size=invisible&cb=hhps5wd06eue')
199 token = reCaptchaV3('https://www.recaptcha.net/recaptcha/enterprise/anchor?ar=1&k=6LflhEElAAAAAI_ewVwRWI9hsyV4mbZnYAslSvlG&co=aHR0cHM6Ly9wb2UuY29tOjQ0Mw..&hl=en&v=4PnKmGB9wRHh1i04o7YUICeI&size=invisible&cb=bi6ivxoskyal')
200 # token = solver.recaptcha(sitekey='6LflhEElAAAAAI_ewVwRWI9hsyV4mbZnYAslSvlG',
201 # url = 'https://poe.com/login?redirect_url=%2F',
202 # version = 'v3',
203 # enterprise = 1,
204 # invisible = 1,
205 # action = 'login',)['code']
198 206
199 207 payload = dumps(separators = (',', ':'), obj = {
200 208 'queryName': 'MainSignupLoginSection_sendVerificationCodeMutation_Mutation',
201 209 'variables': {
202 'emailAddress': mail_address,
203 'phoneNumber': None,
210 'emailAddress' : mail_address,
211 'phoneNumber' : None,
204 212 'recaptchaToken': token
205 213 },
206 214 'query': 'mutation MainSignupLoginSection_sendVerificationCodeMutation_Mutation(\n $emailAddress: String\n $phoneNumber: String\n $recaptchaToken: String\n) {\n sendVerificationCode(verificationReason: login, emailAddress: $emailAddress, phoneNumber: $phoneNumber, recaptchaToken: $recaptchaToken) {\n status\n errorMessage\n }\n}\n',
@@ -208,33 +216,31 @@ class Account:
208 216
209 217 base_string = payload + client.headers["poe-formkey"] + 'WpuLMiXEKKE98j56k'
210 218 client.headers["poe-tag-id"] = md5(base_string.encode()).hexdigest()
211
219
220 print(dumps(client.headers, indent=4))
221
212 222 response = client.post('https://poe.com/api/gql_POST', data=payload)
223
224 if 'automated_request_detected' in response.text:
225 print('please try using a proxy / wait for fix')
226
213 227 if 'Bad Request' in response.text:
214 228 if logging: print('bad request, retrying...' , response.json())
215 229 quit()
216 230
217 231 if logging: print('send_code' ,response.json())
218
219 while True:
220 sleep(1)
221 messages = mail.fetch_inbox()
222
223 if len(messages["messages"]) > 0:
224 email_content = mail.get_message_content(messages["messages"][0]["_id"])
225 mail_token = findall(r';">(\d{6,7})</div>', email_content)[0]
226
227 if mail_token:
228 break
232
233 mail_content = mail_client.get_message()
234 mail_token = findall(r';">(\d{6,7})</div>', mail_content)[0]
229 235
230 236 if logging: print('code', mail_token)
231 237
232 238 payload = dumps(separators = (',', ':'), obj={
233 239 "queryName": "SignupOrLoginWithCodeSection_signupWithVerificationCodeMutation_Mutation",
234 240 "variables": {
235 "verificationCode" : mail_token,
236 "emailAddress" : mail_address,
237 "phoneNumber" : None
241 "verificationCode": str(mail_token),
242 "emailAddress": mail_address,
243 "phoneNumber": None
238 244 },
239 245 "query": "mutation SignupOrLoginWithCodeSection_signupWithVerificationCodeMutation_Mutation(\n $verificationCode: String!\n $emailAddress: String\n $phoneNumber: String\n) {\n signupWithVerificationCode(verificationCode: $verificationCode, emailAddress: $emailAddress, phoneNumber: $phoneNumber) {\n status\n errorMessage\n }\n}\n"
240 246 })
@@ -244,27 +250,6 @@ class Account:
244 250
245 251 response = client.post('https://poe.com/api/gql_POST', data = payload)
246 252 if logging: print('verify_code', response.json())
247
248 token = parse.unquote(client.cookies.get_dict()['p-b'])
249
250 with open(Path(__file__).resolve().parent / 'cookies.txt', 'a') as f:
251 f.write(f'{token}\n')
252
253 if enable_bot_creation:
254
255 payload = dumps(separators = (',', ':'), obj={
256 "queryName": "UserProfileConfigurePreviewModal_markMultiplayerNuxCompleted_Mutation",
257 "variables": {},
258 "query": "mutation UserProfileConfigurePreviewModal_markMultiplayerNuxCompleted_Mutation {\n markMultiplayerNuxCompleted {\n viewer {\n hasCompletedMultiplayerNux\n id\n }\n }\n}\n"
259 })
260
261 base_string = payload + client.headers["poe-formkey"] + 'WpuLMiXEKKE98j56k'
262 client.headers["poe-tag-id"] = md5(base_string.encode()).hexdigest()
263
264 resp = client.post("https://poe.com/api/gql_POST", data = payload)
265 if logging: print(resp.json())
266
267 return token
268 253
269 254 def get():
270 255 cookies = open(Path(__file__).resolve().parent / 'cookies.txt', 'r').read().splitlines()
Modified quora/cookies.txt +9 -0
@@ -19,3 +19,12 @@ wfUfJIlwQwUss8l-3kDt3w==
19 19 f6Jw_Nr0PietpNCtOCXJTw==
20 20 6Jc3yCs7XhDRNHa4ZML09g==
21 21 3vy44sIy-ZlTMofFiFDttw==
22 p9FbMGGiK1rShKgL3YWkDg==
23 pw6LI5Op84lf4HOY7fn91A==
24 QemKm6aothMvqcEgeKFDlQ==
25 cceZzucA-CEHR0Gt6VLYLQ==
26 JRRObMp2RHVn5u4730DPvQ==
27 XNt0wLTjX7Z-EsRR3TJMIQ==
28 csjjirAUKtT5HT1KZUq1kg==
29 8qZdCatCPQZyS7jsO4hkdQ==
30 esnUxcBhvH1DmCJTeld0qw==
Modified quora/mail.py +60 -33
@@ -1,39 +1,66 @@
1 import html
2 import json
3 from tls_client import Session
4
5 class Mail:
6 def __init__(self, proxies: str = None, timeout: int = 15, bearer_token: str or None = None) -> None:
7 self.session = Session(client_identifier='chrome110')
8 self.base_url = 'https://web2.temp-mail.org'
9 self.proxies = proxies
10 self.timeout = timeout
11
12 self.session.headers['authorization'] = f'Bearer {bearer_token}' if bearer_token else None
1 from requests import Session
2 from time import sleep
3 from re import search, findall
4 from json import loads
13 5
14 def get_mail(self) -> str:
15 status: html = self.session.get(self.base_url).status_code
16
17 try:
18 if status == 200:
19 data = self.session.post(f'{self.base_url}/mailbox').json()
6 class Emailnator:
7 def __init__(self) -> None:
8 self.client = Session()
9 self.client.get('https://www.emailnator.com/', timeout=6)
10 self.cookies = self.client.cookies.get_dict()
20 11
21 self.session.headers['authorization'] = f'Bearer {data["token"]}'
22 return data["token"], data["mailbox"]
12 self.client.headers = {
13 'authority' : 'www.emailnator.com',
14 'origin' : 'https://www.emailnator.com',
15 'referer' : 'https://www.emailnator.com/',
16 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36 Edg/101.0.1722.39',
17 'x-xsrf-token' : self.client.cookies.get("XSRF-TOKEN")[:-3]+"=",
18 }
23 19
24 except Exception as e:
25 print(e)
26 return f'Email creation error. {e} | use proxies', False
27
28 def fetch_inbox(self) -> json:
29 return self.session.get(f'{self.base_url}/messages').json()
20 self.email = None
21
22 def get_mail(self):
23 response = self.client.post('https://www.emailnator.com/generate-email',json = {
24 'email': [
25 'domain',
26 'plusGmail',
27 'dotGmail',
28 ]
29 })
30
31 self.email = loads(response.text)["email"][0]
32 return self.email
30 33
31 def get_message_content(self, message_id: str):
32 return self.session.get(f'{self.base_url}/messages/{message_id}').json()["bodyHtml"]
34 def get_message(self):
35 print("waiting for code...")
36
37 while True:
38 sleep(2)
39 mail_token = self.client.post('https://www.emailnator.com/message-list',
40 json = {'email': self.email})
41
42 mail_token = loads(mail_token.text)["messageData"]
43
44 if len(mail_token) == 2:
45 print(mail_token[1]["messageID"])
46 break
47
48 mail_context = self.client.post('https://www.emailnator.com/message-list', json = {
49 'email' : self.email,
50 'messageID': mail_token[1]["messageID"],
51 })
52
53 return mail_context.text
54
55 # mail_client = Emailnator()
56 # mail_adress = mail_client.get_mail()
57
58 # print(mail_adress)
59
60 # mail_content = mail_client.get_message()
61
62 # print(mail_content)
33 63
34 # if __name__ == '__main__':
64 # code = findall(r';">(\d{6,7})</div>', mail_content)[0]
65 # print(code)
35 66
36 # email_client = TempMail()
37 # token, email = email_client.get_mail()
38 # print(email)
39 # print(token)
Added quora/poe_account_create_test.py +104 -0
@@ -0,0 +1,104 @@
1 from requests import Session
2 from tls_client import Session as TLS
3 from json import dumps
4 from hashlib import md5
5 from time import sleep
6 from re import findall
7 from pypasser import reCaptchaV3
8 from quora import extract_formkey
9 from quora.mail import Emailnator
10 from twocaptcha import TwoCaptcha
11
12 solver = TwoCaptcha('72747bf24a9d89b4dcc1b24875efd358')
13
14 class Account:
15 def create(proxy: None or str = None, logging: bool = False, enable_bot_creation: bool = False):
16 client = TLS(client_identifier='chrome110')
17 client.proxies = {
18 'http': f'http://{proxy}',
19 'https': f'http://{proxy}'} if proxy else None
20
21 mail_client = Emailnator()
22 mail_address = mail_client.get_mail()
23
24 if logging: print('email', mail_address)
25
26 client.headers = {
27 'authority' : 'poe.com',
28 'accept' : '*/*',
29 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
30 'content-type' : 'application/json',
31 'origin' : 'https://poe.com',
32 'poe-formkey' : 'null',
33 'poe-tag-id' : 'null',
34 'poe-tchannel' : 'null',
35 'referer' : 'https://poe.com/login',
36 'sec-ch-ua' : '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
37 'sec-ch-ua-mobile' : '?0',
38 'sec-ch-ua-platform': '"macOS"',
39 'sec-fetch-dest': 'empty',
40 'sec-fetch-mode': 'cors',
41 'sec-fetch-site': 'same-origin',
42 'user-agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
43 }
44
45 client.headers["poe-formkey"] = extract_formkey(client.get('https://poe.com/login').text)
46 client.headers["poe-tchannel"] = client.get('https://poe.com/api/settings').json()['tchannelData']['channel']
47
48 #token = reCaptchaV3('https://www.recaptcha.net/recaptcha/enterprise/anchor?ar=1&k=6LflhEElAAAAAI_ewVwRWI9hsyV4mbZnYAslSvlG&co=aHR0cHM6Ly9wb2UuY29tOjQ0Mw..&hl=en&v=4PnKmGB9wRHh1i04o7YUICeI&size=invisible&cb=bi6ivxoskyal')
49 token = solver.recaptcha(sitekey='6LflhEElAAAAAI_ewVwRWI9hsyV4mbZnYAslSvlG',
50 url = 'https://poe.com/login?redirect_url=%2F',
51 version = 'v3',
52 enterprise = 1,
53 invisible = 1,
54 action = 'login',)['code']
55
56 payload = dumps(separators = (',', ':'), obj = {
57 'queryName': 'MainSignupLoginSection_sendVerificationCodeMutation_Mutation',
58 'variables': {
59 'emailAddress' : mail_address,
60 'phoneNumber' : None,
61 'recaptchaToken': token
62 },
63 'query': 'mutation MainSignupLoginSection_sendVerificationCodeMutation_Mutation(\n $emailAddress: String\n $phoneNumber: String\n $recaptchaToken: String\n) {\n sendVerificationCode(verificationReason: login, emailAddress: $emailAddress, phoneNumber: $phoneNumber, recaptchaToken: $recaptchaToken) {\n status\n errorMessage\n }\n}\n',
64 })
65
66 base_string = payload + client.headers["poe-formkey"] + 'WpuLMiXEKKE98j56k'
67 client.headers["poe-tag-id"] = md5(base_string.encode()).hexdigest()
68
69 print(dumps(client.headers, indent=4))
70
71 response = client.post('https://poe.com/api/gql_POST', data=payload)
72
73 if 'automated_request_detected' in response.text:
74 print('please try using a proxy / wait for fix')
75
76 if 'Bad Request' in response.text:
77 if logging: print('bad request, retrying...' , response.json())
78 quit()
79
80 if logging: print('send_code' ,response.json())
81
82 mail_content = mail_client.get_message()
83 mail_token = findall(r';">(\d{6,7})</div>', mail_content)[0]
84
85 if logging: print('code', mail_token)
86
87 payload = dumps(separators = (',', ':'), obj={
88 "queryName": "SignupOrLoginWithCodeSection_signupWithVerificationCodeMutation_Mutation",
89 "variables": {
90 "verificationCode": str(mail_token),
91 "emailAddress": mail_address,
92 "phoneNumber": None
93 },
94 "query": "mutation SignupOrLoginWithCodeSection_signupWithVerificationCodeMutation_Mutation(\n $verificationCode: String!\n $emailAddress: String\n $phoneNumber: String\n) {\n signupWithVerificationCode(verificationCode: $verificationCode, emailAddress: $emailAddress, phoneNumber: $phoneNumber) {\n status\n errorMessage\n }\n}\n"
95 })
96
97 base_string = payload + client.headers["poe-formkey"] + 'WpuLMiXEKKE98j56k'
98 client.headers["poe-tag-id"] = md5(base_string.encode()).hexdigest()
99
100 response = client.post('https://poe.com/api/gql_POST', data = payload)
101 if logging: print('verify_code', response.json())
102
103
104 Account.create(proxy = 'xtekky:wegwgwegwed_streaming-1@geo.iproyal.com:12321', logging = True)