-
Notifications
You must be signed in to change notification settings - Fork 2
/
genomefi.py
490 lines (450 loc) · 21.1 KB
/
genomefi.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
import asyncio
import sys
import time
import schedule
import requests
import re
from datetime import datetime, timedelta
import httpx
from eth_account.messages import encode_defunct
from loguru import logger
from eth_account import Account
from faker import Faker
import random
import string
import secrets
import uuid
from base64 import b64encode
import json
import tls_client
requests.packages.urllib3.disable_warnings()
fake = Faker(locale='en-US')
g_success, g_fail = 0, 0
logger.remove()
logger.add(sys.stdout, colorize=True,
format="<w>{time:HH:mm:ss:SSS}</w> | <r>{extra[fail]}</r>-<g>{extra[success]}</g> | <level>{message}</level>")
logger = logger.patch(lambda record: record["extra"].update(fail=g_fail, success=g_success))
proxy_ip = '127.0.0.1:7890'
ezcaptcha_client_key = ''
def reCaptchaV2():
while True:
json_data = {
"clientKey": ezcaptcha_client_key,
"task":
{
"type": "ReCaptchaV2TaskProxyless",
"websiteURL": "https://event.genomefi.io/",
"websiteKey": "6LcK_aApAAAAAPAUR8Zo96ZMXGQF12jeUKR2KeGr",
"isInvisible": False,
}
}
response = requests.post(url='https://api.ez-captcha.com/createTask', json=json_data).json()
if response['errorId'] != 0:
raise ValueError(response)
task_id = response['taskId']
time.sleep(5)
for _ in range(30):
data = {"clientKey": ezcaptcha_client_key, "taskId": task_id}
response = requests.post(url='https://api.ez-captcha.com/getTaskResult', json=data).json()
if response['status'] == 'ready':
return response['solution']['gRecaptchaResponse']
else:
time.sleep(2)
async def auth_twitter(tw_token):
proxies = {
'http://': f'http://{proxy_ip}',
'https://': f'http://{proxy_ip}',
}
try:
http = httpx.AsyncClient(proxies=proxies, verify=False, timeout=10)
response = await http.get(url='https://twitter.com/home', cookies={
'auth_token': tw_token,
'ct0': '960eb16898ea5b715b54e54a8f58c172'
})
ct0 = re.findall('ct0=(.*?);', dict(response.headers)['set-cookie'])[0]
cookies = {'ct0': ct0, 'auth_token': tw_token}
http.headers = {'authority': 'twitter.com', 'accept': '*/*', 'accept-language': 'zh-CN,zh;q=0.9',
'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
'cache-control': 'no-cache', 'content-type': 'application/json',
'origin': 'https://twitter.com',
'pragma': 'no-cache',
'referer': 'https://twitter.com/puffer_finance/status/1751954283052810298',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
'x-csrf-token': ct0}
api_url = 'https://twitter.com/i/api/2/oauth2/authorize?code_challenge=challenge&code_challenge_method=plain&client_id=OHdOUXJvREY1R2oyUlE3akI4Vng6MTpjaQ&redirect_uri=https%3A%2F%2Fevent.genomefi.io%2Fevent%3Fsocial%3Dtwitter&response_type=code&scope=follows.read%20follows.write%20offline.access%20users.read%20tweet.read%20tweet.write%20like.read%20like.write&state=state'
response = await http.get(url=api_url, cookies=cookies)
auth_code = response.json()['auth_code']
data = {'approval': True, 'code': auth_code}
response = await http.post(url=api_url, cookies=cookies, json=data)
redirect_uri = response.json()['redirect_uri']
return auth_code
except Exception as e:
logger.error(e)
def build_trackers(user_agent) -> str:
return b64encode(json.dumps({"os": "Mac OS X", "browser": "Safari", "device": "", "system_locale": "zh-CN",
"browser_user_agent": user_agent,
"browser_version": "13.1.twitter_account", "os_version": "10.13.6", "referrer": "",
"referring_domain": "", "referrer_current": "", "referring_domain_current": "",
"release_channel": "stable", "client_build_number": 177662,
"client_event_source": None}, separators=(',', ':')).encode()).decode()
# 授权discord
def auth_discord(dc_token):
tls_proxies = {
'http': f'http://{proxy_ip}',
'https': f'http://{proxy_ip}',
}
try:
session = tls_client.Session(
random_tls_extension_order=True,
)
user_agent = fake.safari()
headers = {
'Host': 'discord.com',
'Connection': 'keep-alive',
'User-Agent': user_agent,
'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-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
}
_uuid = uuid.uuid4()
response = session.get(
url=f'https://discord.com/api/oauth2/authorize?client_id=1217013639458848778&response_type=code&redirect_uri=https%3A%2F%2Fevent.genomefi.io%2Fevent%3Fsocial%3Ddiscord&scope=identify&state=discord-{_uuid}',
headers=headers, proxy=tls_proxies, allow_redirects=False)
# logger.debug(response)
x_super_properties = build_trackers(user_agent)
headers.update({"Authorization": dc_token})
headers.update({"X-Super-Properties": x_super_properties})
headers.update({"X-Debug-Options": 'bugReporterEnabled'})
response = session.get(
url=f'https://discord.com/oauth2/authorize?client_id=1217013639458848778&response_type=code&redirect_uri=https%3A%2F%2Fevent.genomefi.io%2Fevent%3Fsocial%3Ddiscord&scope=identify&state=discord-{_uuid}',
headers=headers, proxy=tls_proxies, allow_redirects=False)
# logger.debug(response.status_code)
data = {"permissions": "0", "authorize": True, "integration_type": 0}
response = session.post(
url=f'https://discord.com/api/v9/oauth2/authorize?client_id=1217013639458848778&response_type=code&redirect_uri=https%3A%2F%2Fevent.genomefi.io%2Fevent%3Fsocial%3Ddiscord&scope=identify&state=discord-{_uuid}',
headers=headers, proxy=tls_proxies, allow_redirects=False, json=data).json()
# logger.debug(response)
location = response['location']
code = re.findall('code=(.*?)&state=', location)[0]
return code
except Exception as e:
logger.error(e)
class GenomeFi:
def __init__(self, pri_key, referral):
proxies = {
'http://': f'http://{proxy_ip}',
'https://': f'http://{proxy_ip}',
}
self.address = Account.from_key(pri_key).address
self.pri_key = pri_key
self.referral = referral
self.http = httpx.AsyncClient(proxies=proxies, verify=False, timeout=30)
self.http.headers = {
'Accept-Language': 'en-US,en;q=0.8',
'Origin': 'https://event.genomefi.io',
'Referer': 'https://event.genomefi.io/',
'Sec-Ch-Ua': '"Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"',
'Sec-Ch-Ua-Mobile': '?0',
'Sec-Ch-Ua-Platform': "Windows",
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'Sec-Gpc': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/'
}
self.token = None
async def login(self):
try:
nonce = secrets.token_hex(16)
issued_at = datetime.now().isoformat(timespec='milliseconds') + 'Z'
expiration_time = (datetime.now() + timedelta(minutes=10)).isoformat(timespec='milliseconds') + 'Z'
reCode = reCaptchaV2()
message = f"event.genomefi.io wants you to sign in with your Ethereum account:\n{self.address}\n\nSign in GenomeFi.\n\nURI: https://event.genomefi.io\nVersion: 1\nChain ID: 137\nNonce: {nonce}\nIssued At: {issued_at}\nExpiration Time: {expiration_time}"
signature = Account.from_key(self.pri_key).sign_message(encode_defunct(text=message))
data = {
"address": self.address,
"message": message,
"signed": signature.signature.hex(),
"reCode": reCode,
}
response = await self.http.post(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/auth/login/wallet', json=data)
if response.json()['success']:
self.token = response.json()['accessToken']
self.http.headers['Authorization'] = 'Bearer ' + self.token
logger.info(f'{self.address} 登录成功')
return True
logger.error(f'{self.address} 登录失败')
return False
except Exception as e:
logger.error(e)
return False
async def register(self):
try:
nonce = secrets.token_hex(16)
issued_at = datetime.now().isoformat(timespec='milliseconds') + 'Z'
expiration_time = (datetime.now() + timedelta(minutes=10)).isoformat(timespec='milliseconds') + 'Z'
message = f"event.genomefi.io wants you to sign in with your Ethereum account:\n{self.address}\n\nSign in GenomeFi.\n\nURI: https://event.genomefi.io\nVersion: 1\nChain ID: 137\nNonce: {nonce}\nIssued At: {issued_at}\nExpiration Time: {expiration_time}"
signature = Account.from_key(self.pri_key).sign_message(encode_defunct(text=message))
rand_str = generate_random_string()
reCode = reCaptchaV2()
data = {
"address": self.address,
"message": message,
"nickname": rand_str,
"reCode": reCode,
"signed": signature.signature.hex(),
"walletType": "MetaMask",
}
response = await self.http.post(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/auth/join/wallet?referral=' + self.referral,
json=data)
if response.json()['success']:
self.token = response.json()['accessToken']
self.http.headers['Authorization'] = 'Bearer ' + self.token
return True
logger.error(f'{self.address} 注册失败')
return False
except Exception as e:
logger.error(e)
return False
async def get_point(self):
try:
response = await self.http.get(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/point?page=1&item=4')
if response.json()['success']:
logger.info(f'{self.address} 当前积分:{str(response.json()["pointTotal"])}')
return response.json()["pointTotal"]
logger.error(f'{self.address} 获取用户信息失败')
return False
except Exception as e:
logger.error(e)
return False
async def get_nft(self):
try:
response = await self.http.get(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/dashboard/nft/mygallery?page=1')
if response.json()['success']:
return response.json()["data"]['data'][0]['fileKey']
return False
except Exception as e:
logger.error(e)
return False
async def get_status(self):
try:
response = await self.http.get(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/dashboard/status')
if response.json()['success']:
return response.json()['data']
logger.error(f'{self.address} 获取状态失败')
return False
except Exception as e:
logger.error(e)
return False
# onece task
async def bind_twitter(self, tw_token):
try:
auth_token = await auth_twitter(tw_token)
params = {
'code': auth_token,
'redirect': 'https://event.genomefi.io/event?social=twitter'
}
response = await self.http.post(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/task/social/twitter',
params=params)
if response.json()['success']:
logger.info(f'{self.address} 绑定推特成功')
return True
logger.error(f'{self.address} 绑定推特失败')
return False
except Exception as e:
logger.error(e)
return False
async def bind_discord(self, dc_token):
try:
auth_code = auth_discord(dc_token)
params = {
'code': auth_code,
'redirect': 'https://event.genomefi.io/event?social=discord'
}
response = await self.http.post(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/task/social/discord',
params=params)
if response.json()['success']:
logger.info(f'{self.address} 绑定DC成功')
return True
logger.error(f'{self.address} 绑定DC失败')
return False
except Exception as e:
logger.error(e)
return False
async def submit_Mbti(self):
try:
mbtis = ['INTJ', 'INTP', 'ENTJ', 'ENTP', 'INFJ', 'INFP', 'ENFJ', 'ENFP', 'ISTJ', 'ISFJ', 'ESTJ', 'ESFJ',
'ISTP', 'ISFP', 'ESTP', 'ESFP']
bloods = ['A', 'B', 'O', 'AB']
data = {
"mbti": random.choice(mbtis),
"blood": random.choice(bloods),
}
response = await self.http.post(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/task/mbti', json=data)
if response.json()['success']:
logger.info(f'{self.address} 提交MBTI成功')
return True
logger.error(f'{self.address} 提交MBTI失败')
return False
except Exception as e:
logger.error(e)
return False
async def submit_profile(self, profile):
try:
data = {
"profile": profile
}
response = await self.http.post(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/task/profile',
json=data)
if response.json()['success']:
logger.info(f'{self.address} 设置头像成功')
return True
logger.error(f'{self.address} 设置头像失败')
return False
except Exception as e:
logger.error(e)
return False
# daily task
async def check_in(self):
try:
response = await self.http.post(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/task/attendance')
if response.json()['success'] or response.json()['error']['msg'] == 'Already attended':
logger.info(f'{self.address} 签到成功')
return True
logger.error(f'{self.address} 签到失败')
return False
except Exception as e:
logger.error(e)
return False
async def ai_chat(self):
for i in range(5):
try:
data = {
'question': 'Please help me generate a paragraph that must contain the word "genome-related"'
}
response = await self.http.post(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/task/quiz/quest',
json=data)
if response.json()['success']:
logger.info(f'{self.address} AI聊天成功')
elif response.json()['error']['msg'] == 'Already Max chat today':
logger.info(f'{self.address} 今日AI聊天次数已用完')
return True
else:
logger.error(f'{self.address} AI聊天失败')
continue
except Exception as e:
logger.error(e)
continue
time.sleep(1)
async def ai_nft(self):
try:
data = {
'prompt': 'photorealistic, long_hair, realistic, solo, long_hair, (photorealistic:1.4), best quality, ultra high res, teeth, Long sleeve,Blue dress, Big mouth,full body,3girls, Grin, graffiti (medium), ok sign,'
}
response = await self.http.post(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/task/quiz/nft',
json=data)
if response.json()['success']:
logger.info(f'{self.address} AI生图成功')
return True
if response.json()['error']['msg'] == 'Already Max nft today':
logger.info(f'{self.address} 今日AI生图次数已用完')
return False
logger.error(f'{self.address} AI生图失败')
return False
except Exception as e:
logger.error(e)
return False
async def raffle(self, vgeno):
num = int(vgeno) // 10
for i in range(num):
try:
response = await self.http.post(
'https://sazn9rq17l.execute-api.ap-northeast-2.amazonaws.com/staging/user/event/task/raffle')
if response.json()['success']:
logger.info(f'{self.address} 抽奖成功,获得{response.json()["point"]}积分')
elif response.json()['error']['msg'] == 'Already Max raffle today':
logger.info(f'{self.address} 今日抽奖次数已用完')
return True
else:
logger.error(f'{self.address} 抽奖失败')
continue
except Exception as e:
logger.error(e)
continue
time.sleep(1)
def generate_random_string(length=8):
letters = string.ascii_letters
result_str = ''.join(random.choice(letters) for _ in range(length))
return result_str
async def go(filename, isSocial):
global g_fail, g_success
with open(filename, 'r') as f, open('genomefi-success.txt', 'a') as s, open('genomefi-error.txt', 'a') as e:
lines = f.readlines()
for line in lines:
if isSocial:
address = line.strip().split('----')[0]
private = line.strip().split('----')[1]
tw_token = line.strip().split('----')[2]
dc_token = line.strip().split('----')[3]
else:
address = line.strip().split('----')[0]
private = line.strip().split('----')[1]
tw_token = 'null'
dc_token = 'null'
try:
gf = GenomeFi(private, '')
if await gf.login():
# 补充信息
status = await gf.get_status()
if status['snsTwitter'] is None and tw_token != 'null':
await gf.bind_twitter(tw_token)
if status['snsDiscord'] is None and dc_token != 'null':
await gf.bind_discord(dc_token)
if status['mbti'] is None:
await gf.submit_Mbti()
if status['profileImg'] is None:
profile = await gf.get_nft()
if profile is not False and profile is not None:
await gf.submit_profile(profile)
# 签到
await gf.check_in(), await gf.ai_chat(), await gf.ai_nft()
point = await gf.get_point()
if point is not False:
await gf.raffle(point)
g_success += 1
logger.success(f'{address} 成功')
s.write(f'{address}----{private}\n')
else:
g_fail += 1
logger.error(f'{address} 失败')
e.write(f'{address}----{private}\n')
except Exception as ex:
g_fail += 1
logger.error(f'{address} 失败')
e.write(f'{address}----{private}\n')
continue
def main():
# rel_code = 'USqIXtBAfz' # 替换为你的邀请码
# count = 500 # 注册账号数量
filename = 'genomefi-account.txt'
isSocial = True # 是否绑定社交账号
asyncio.run(go(filename, isSocial))
main()
'''
schedule.every().day.at("15:05").do(main)
while True:
schedule.run_pending()
time.sleep(1)
'''