dan92 commited on
Commit
19ad44b
·
verified ·
1 Parent(s): 52835f1

Upload 6 files

Browse files
Files changed (5) hide show
  1. README.md +2 -0
  2. app.py +34 -1
  3. gitattributes +35 -0
  4. output.txt +1 -0
  5. register_bot.py +281 -0
README.md CHANGED
@@ -10,3 +10,5 @@ app_port: 3000
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
13
+
14
+ [email protected]|password123
app.py CHANGED
@@ -6,6 +6,7 @@ import time
6
  import uuid
7
  import re
8
  import socket
 
9
  from concurrent.futures import ThreadPoolExecutor
10
  from functools import lru_cache, wraps
11
  from typing import Dict, Any, Callable, List, Tuple
@@ -650,7 +651,39 @@ def make_request(payload, auth_manager, model_id):
650
  auth_manager = multi_auth_manager.get_next_auth_manager(model_id)
651
  if not auth_manager:
652
  logger.error(f"No available accounts for model {model_id}")
653
- raise Exception(f"No available accounts for model {model_id}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
654
 
655
  for attempt in range(max_retries):
656
  try:
 
6
  import uuid
7
  import re
8
  import socket
9
+ import subprocess # 新增 subprocess 模块用于执行外部脚本
10
  from concurrent.futures import ThreadPoolExecutor
11
  from functools import lru_cache, wraps
12
  from typing import Dict, Any, Callable, List, Tuple
 
651
  auth_manager = multi_auth_manager.get_next_auth_manager(model_id)
652
  if not auth_manager:
653
  logger.error(f"No available accounts for model {model_id}")
654
+
655
+ # 尝试自动注册新账号
656
+ try:
657
+ register_bot_path = os.path.join(os.path.dirname(__file__), 'register_bot.py')
658
+
659
+ # 执行 register_bot.py 脚本
660
+ result = subprocess.run(
661
+ [sys.executable, register_bot_path], # 使用当前 Python 解释器执行脚本
662
+ capture_output=True, # 捕获标准输出和标准错误
663
+ text=True, # 返回文本输出而非字节
664
+ timeout=600 # 设置超时时间为10分钟
665
+ )
666
+
667
+ # 记录注册脚本的输出
668
+ logger.info(f"Register bot stdout: {result.stdout}")
669
+ logger.error(f"Register bot stderr: {result.stderr}")
670
+
671
+ # 重新初始化 multi_auth_manager
672
+ credentials = get_auth_credentials()
673
+ if credentials:
674
+ multi_auth_manager = MultiAuthManager(credentials)
675
+
676
+ # 重新尝试获取账号
677
+ auth_manager = multi_auth_manager.get_next_auth_manager(model_id)
678
+ if not auth_manager:
679
+ raise Exception("Failed to register new accounts")
680
+
681
+ except subprocess.CalledProcessError as e:
682
+ logger.error(f"Error executing register_bot.py: {e}")
683
+ raise Exception(f"No available accounts for model {model_id} and failed to register new accounts")
684
+ except Exception as e:
685
+ logger.error(f"Unexpected error during account registration: {e}")
686
+ raise Exception(f"No available accounts for model {model_id} and failed to register new accounts")
687
 
688
  for attempt in range(max_retries):
689
  try:
gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
output.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ [email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|zhoudan9.28;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123;[email protected]|password123
register_bot.py ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from bs4 import BeautifulSoup
3
+ from requests.adapters import HTTPAdapter
4
+ from requests.packages.urllib3.util.retry import Retry
5
+ import uuid
6
+ import json
7
+ import time
8
+ import re
9
+ import hashlib
10
+ import base64
11
+ import random
12
+ import string
13
+ import os
14
+ import sys
15
+ from urllib.parse import quote, urlparse, parse_qs
16
+ import concurrent.futures
17
+ import logging
18
+
19
+ # 获取当前脚本所在目录
20
+ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
21
+
22
+ # 配置日志
23
+ try:
24
+ LOG_FILE = os.path.join(SCRIPT_DIR, 'registration_log.txt')
25
+ logging.basicConfig(level=logging.INFO,
26
+ format='%(asctime)s - %(levelname)s - %(message)s',
27
+ filename=LOG_FILE,
28
+ filemode='a')
29
+ except PermissionError:
30
+ # 如果无法写入文件,使用控制台日志
31
+ logging.basicConfig(level=logging.INFO,
32
+ format='%(asctime)s - %(levelname)s - %(message)s',
33
+ stream=sys.stdout)
34
+ logging.warning("Could not write to log file. Logging to console instead.")
35
+
36
+ # 获取环境变量
37
+ PASTE_API_URL = os.getenv('PASTE_API_URL')
38
+ PASTE_API_PASSWORD = os.getenv('PASTE_API_PASSWORD')
39
+
40
+ # 构建上传 URL
41
+ UPLOAD_URL = PASTE_API_URL.replace('/api/paste/', '/api/admin/paste/') + '/content'
42
+
43
+ # 新的临时邮箱API
44
+ TEMP_EMAIL_API = "https://www.1secmail.com/api/v1/?action=genRandomMailbox"
45
+
46
+ # 注册 API 地址
47
+ REGISTER_API_URL = "https://spuckhogycrxcbomznwo.supabase.co/auth/v1/signup?redirect_to=https%3A%2F%2Fchat.notdiamond.ai"
48
+
49
+ # Supabase API Key
50
+ SUPABASE_API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNwdWNraG9neWNyeGNib216bndvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDcyNDYwMzksImV4cCI6MjAyMjgyMjAzOX0.tvlGT7NZY8bijMjNIu1WhAtPnSKuDeYhtveo4DRt6xg"
51
+
52
+ # 请求限制和重试相关配置
53
+ MAX_RETRIES = 3
54
+ RETRY_DELAY = 10 # 秒
55
+ RATE_LIMIT_DELAY = 60 # 秒
56
+
57
+ def generate_strong_password():
58
+ """固定密码为password123"""
59
+ return "password123"
60
+
61
+ def generate_code_verifier():
62
+ return base64.urlsafe_b64encode(uuid.uuid4().bytes).decode('utf-8').rstrip('=')
63
+
64
+ def generate_code_challenge(code_verifier):
65
+ code_challenge = hashlib.sha256(code_verifier.encode('utf-8')).digest()
66
+ return base64.urlsafe_b64encode(code_challenge).decode('utf-8').rstrip('=')
67
+
68
+ def get_temp_email():
69
+ session = requests.Session()
70
+ retries = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
71
+ session.mount('https://', HTTPAdapter(max_retries=retries))
72
+
73
+ try:
74
+ response = session.get(TEMP_EMAIL_API)
75
+ if response.status_code == 200:
76
+ return response.json()[0]
77
+ except requests.exceptions.SSLError as e:
78
+ logging.error(f"SSL Error: {e}")
79
+ return None
80
+
81
+ def register(email, password):
82
+ for attempt in range(MAX_RETRIES):
83
+ session = requests.Session()
84
+ headers = {
85
+ 'apikey': SUPABASE_API_KEY,
86
+ 'authorization': f'Bearer {SUPABASE_API_KEY}',
87
+ 'content-type': 'application/json'
88
+ }
89
+
90
+ code_verifier = generate_code_verifier()
91
+ code_challenge = generate_code_challenge(code_verifier)
92
+
93
+ payload = {
94
+ 'email': email,
95
+ 'password': password,
96
+ 'code_challenge': code_challenge,
97
+ 'code_challenge_method': 's256',
98
+ 'data': {},
99
+ 'gotrue_meta_security': {}
100
+ }
101
+
102
+ try:
103
+ response = session.post(REGISTER_API_URL, headers=headers, json=payload)
104
+
105
+ if response.status_code == 200:
106
+ logging.info(f"Registered with email: {email}")
107
+ return True
108
+ elif response.status_code == 429:
109
+ logging.warning(f"Rate limit reached. Waiting {RATE_LIMIT_DELAY} seconds.")
110
+ time.sleep(RATE_LIMIT_DELAY)
111
+ else:
112
+ logging.error(f"Failed to register with email: {email}. Response: {response.text}")
113
+ return False
114
+
115
+ except requests.exceptions.RequestException as e:
116
+ logging.error(f"Request error: {e}")
117
+ if attempt < MAX_RETRIES - 1:
118
+ logging.info(f"Retrying in {RETRY_DELAY} seconds...")
119
+ time.sleep(RETRY_DELAY)
120
+ else:
121
+ logging.error("Max retries reached.")
122
+ return False
123
+
124
+ return False
125
+
126
+ def save_account(email, password):
127
+ # 上传到指定 URL
128
+ try:
129
+ # 先获取现有内容
130
+ session = requests.Session()
131
+
132
+ # 首先进行认证
133
+ auth_url = PASTE_API_URL
134
+ auth_headers = {
135
+ 'accept': '*/*',
136
+ 'accept-language': 'zh-CN,zh;q=0.9',
137
+ 'user-agent': 'Mozilla/5.0',
138
+ 'x-password': PASTE_API_PASSWORD
139
+ }
140
+
141
+ # 获取现��内容
142
+ response = session.get(auth_url, headers=auth_headers)
143
+
144
+ if response.status_code != 200:
145
+ logging.error(f"认证失败,状态码:{response.status_code}")
146
+ return
147
+
148
+ # 从响应获取现有内容
149
+ existing_data = response.json()
150
+ existing_content = existing_data.get('content', '')
151
+
152
+ # 构建新的内容
153
+ if existing_content:
154
+ new_content = f"{existing_content};{email}|{password}"
155
+ else:
156
+ new_content = f"{email}|{password}"
157
+
158
+ # 上传新内容
159
+ upload_headers = {
160
+ 'Authorization': 'Basic emhvdWRhbjp6aG91ZGFu',
161
+ 'Content-Type': 'application/json'
162
+ }
163
+
164
+ upload_payload = {
165
+ 'content': new_content
166
+ }
167
+
168
+ upload_response = session.put(UPLOAD_URL, headers=upload_headers, json=upload_payload)
169
+
170
+ if upload_response.status_code == 200:
171
+ logging.info(f"Successfully uploaded account {email}")
172
+ else:
173
+ logging.error(f"Failed to upload account {email}. Status code: {upload_response.status_code}")
174
+
175
+ except Exception as e:
176
+ logging.error(f"Error uploading account: {e}")
177
+
178
+ def check_email(email):
179
+ domain = email.split('@')[1]
180
+ login = email.split('@')[0]
181
+
182
+ # 获取消息ID
183
+ mailbox_url = f"https://www.1secmail.com/api/v1/?action=getMessages&login={login}&domain={domain}"
184
+
185
+ session = requests.Session()
186
+ retries = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
187
+ session.mount('https://', HTTPAdapter(max_retries=retries))
188
+
189
+ time.sleep(10)
190
+
191
+ for _ in range(20):
192
+ response = session.get(mailbox_url)
193
+ if response.status_code == 200 and response.json():
194
+ for message in response.json():
195
+ if "Confirm Your Signup" in message.get('subject', ''):
196
+ # 获取完整邮件内容
197
+ message_url = f"https://www.1secmail.com/api/v1/?action=readMessage&login={login}&domain={domain}&id={message['id']}"
198
+ message_response = session.get(message_url)
199
+
200
+ if message_response.status_code == 200:
201
+ full_message = message_response.json()
202
+ logging.info(f"Full message content: {full_message}")
203
+
204
+ # 提取验证链接
205
+ match = re.search(r'https?://chat\.notdiamond\.ai/auth/confirm\?[^\s]+', full_message.get('body', ''))
206
+ if match:
207
+ verification_link = match.group(0)
208
+ logging.info(f"Verification link found: {verification_link}")
209
+
210
+ # 解析 URL 并获取参数
211
+ parsed_url = urlparse(verification_link)
212
+ query_params = parse_qs(parsed_url.query)
213
+
214
+ # 使用 Supabase API 进行验证
215
+ verify_url = "https://spuckhogycrxcbomznwo.supabase.co/auth/v1/verify"
216
+ headers = {
217
+ 'apikey': SUPABASE_API_KEY,
218
+ 'authorization': f'Bearer {SUPABASE_API_KEY}',
219
+ 'content-type': 'application/json'
220
+ }
221
+
222
+ payload = {
223
+ 'token_hash': query_params['token_hash'][0],
224
+ 'type': 'signup' # 硬编码为 'signup'
225
+ }
226
+
227
+ verify_response = session.post(verify_url, headers=headers, json=payload)
228
+
229
+ if verify_response.status_code == 200:
230
+ logging.info(f"Email verified for {email}")
231
+ return True
232
+ else:
233
+ logging.error(f"Failed to verify email for {email}: {verify_response.text}")
234
+ return False
235
+ else:
236
+ logging.error(f"Failed to extract verification link from email for {email}")
237
+ return False
238
+ time.sleep(5)
239
+ logging.warning(f"No verification email found for {email}")
240
+ return False
241
+
242
+ def register_and_verify(num_accounts=1):
243
+ successful_accounts = []
244
+ with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: # 降低并发数
245
+ futures = []
246
+ for _ in range(num_accounts):
247
+ email = get_temp_email()
248
+ if email:
249
+ futures.append(executor.submit(process_account, email))
250
+ time.sleep(RETRY_DELAY) # 添加延迟
251
+
252
+ for future in concurrent.futures.as_completed(futures):
253
+ result = future.result()
254
+ if result:
255
+ successful_accounts.append(result)
256
+
257
+ return successful_accounts
258
+
259
+ def process_account(email):
260
+ try:
261
+ # 使用固定密码
262
+ password = generate_strong_password()
263
+
264
+ if register(email, password):
265
+ save_account(email, password)
266
+ if check_email(email):
267
+ return {'email': email, 'password': password}
268
+ except Exception as e:
269
+ logging.error(f"Error processing account {email}: {e}")
270
+ return None
271
+
272
+ def main():
273
+ num_accounts = 5 # 可以根据需要修改注册数量
274
+ successful_accounts = register_and_verify(num_accounts)
275
+ logging.info(f"Successfully registered {len(successful_accounts)} accounts:")
276
+ for account in successful_accounts:
277
+ logging.info(f"Email: {account['email']}, Password: {account['password']}")
278
+ print(f"Successfully registered {len(successful_accounts)} accounts. Check registration_log.txt for details.")
279
+
280
+ if __name__ == "__main__":
281
+ main()