-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathindex.py
203 lines (189 loc) · 6.88 KB
/
index.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
import datetime
import os
import re
import sys
import time
from urllib.parse import urlparse
import requests
from bs4 import BeautifulSoup
# server酱key
key = ''
# 账号
email = ''
# 密码
passwd = ''
# session
session = requests.session()
# 登陆
def login(host):
parsed_url = urlparse(host)
# 1. 做浏览器认证
headers = {
'host': parsed_url.netloc,
'Connection': 'keep-alive',
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'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',
'Sec-Fetch-Site': 'none',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-User': '?1',
'Sec-Fetch-Dest': 'document',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
}
res = session.get(url=host, headers=headers)
# print(res.text)
cookie = requests.utils.dict_from_cookiejar(res.cookies)
if 'ge_ua_p' in cookie:
time.sleep(5)
print(cookie)
n = cookie['ge_ua_p']
s = re.search('var nonce = \d+;', res.text)
nonce = int(s[0][s[0].rindex('=') + 1:-1])
print(nonce)
a = 0
for o in range(len(n)):
d = n[o]
if d.isalpha() or d.isdigit():
a += ord(d) * (nonce + o)
print('a', a)
headers = {
'Host': parsed_url.netloc,
'Connection': 'keep-alive',
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
'sec-ch-ua-platform': '"Windows"',
'X-GE-UA-Step': 'prev',
'sec-ch-ua-mobile': '?0',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Content-type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
'Origin': host,
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Referer': host + '/',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cookie': 'ge_ua_p=' + n,
}
res = session.post(
url=res.url,
data={'sum': a, 'nonce': nonce},
headers=headers
)
print(res.text)
# 2. 登录
url = '{}/auth/login'.format(host)
params = {
'email': email,
'passwd': passwd,
'code': ''
}
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Origin': url,
'Referer': '{}/auth/login'.format(url),
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest',
}
res = session.post(url=url, headers=headers, data=params, timeout=30)
msg = res.json()['msg']
print(msg)
ret = ''
if msg == '登录成功':
# 登陆成功之后,去更新hosts.txt
del headers['Content-Type']
headers[
'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'
html = session.get('{}/user'.format(host), headers=headers, timeout=30).text
soup = BeautifulSoup(html, 'lxml')
hosts = set()
for i in soup.find_all('h6'):
if '购买地址' not in i.text:
a = i.find('a', text=re.compile('http.*'))
if a and re.search(r'[\u4e00-\u9fa5]', a.text) is None:
hosts.add(a.text)
with open('hosts.txt', 'w', encoding='utf-8') as f:
for i in hosts:
f.write('{}\n'.format(i))
print('更新hosts.txt完成')
# 获取登陆信息
statistics = soup.find_all(class_='card card-statistic-2')
for i in statistics:
for j in i.text.split('\n'):
if len(j) > 1:
a = j.replace('\n', '').replace('\r', '').replace('升级套餐', '').strip()
ret += a + ' '
ret += '\n\n'
return ret
else:
raise Exception(msg)
# 速鹰666签到领流量
def clockIn(host):
url = '{}/user/checkin'.format(host)
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Content-Length': '0',
'Origin': host,
'Referer': '{}/user'.format(host),
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest',
}
res = session.post(url=url, headers=headers, timeout=30)
json = res.json()
print(json)
return json
def sendMessage(msg):
# print(msg)
if key:
res = requests.post(
url='https://sc.ftqq.com/' + key + '.send',
data={
'title': '速鹰666自动签到结果通知',
'desp': msg
},
timeout=30
)
# print(res.text)
def main_handler(event, context):
hosts = [i.strip() for i in open('hosts.txt', 'r', encoding='utf-8').readlines()]
for host in hosts:
try:
print('try', host)
lmsg = login(host)
json = clockIn(host)
msg = json['msg']
ret = json['ret']
# print(lmsg + '今日签到 ' + msg)
if ret == 1:
sendMessage(lmsg + '今日签到 ' + msg)
break
else:
break
except Exception as e:
print(e)
# 当没有更新hosts时,保留原有的hosts
hosts2 = [i.strip() for i in open('hosts.txt', 'r', encoding='utf-8').readlines()]
if not hosts2:
with open('hosts.txt', 'w', encoding='utf-8') as f:
for i in hosts:
f.write('{}\n'.format(i))
if __name__ == '__main__':
os.chdir(os.path.dirname(os.path.abspath(__file__)))
if len(sys.argv) != 4:
print('usage:python3 {} "email" "passwd" "key"'.format(sys.argv[0]))
exit()
print(datetime.datetime.now())
email, passwd, key = sys.argv[1:]
if (not len(email)) or (not len(passwd)):
print('email or passwd is null')
exit()
main_handler({}, {})