Skip to content

Commit b0b166f

Browse files
authored
set timezone to Asia/Shanghai (fix njzjz#19) (njzjz#20)
* set timezone to Asia/Shanghai (fix njzjz#19) * update code
1 parent ec54716 commit b0b166f

File tree

4 files changed

+211
-56
lines changed

4 files changed

+211
-56
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
language: python
22
python: 3.6
33
script: python ithome.py -u $user -p $password
4+
before_install:
5+
- export TZ=Asia/Shanghai

ithome.py

+1-56
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,8 @@
33
Based on https://github.com/daimiaopeng/ithome_qiandao
44
'''
55

6-
import requests
7-
import json
8-
import re
9-
import datetime
106
import argparse
11-
import Crypto.Cipher.DES
12-
13-
# 更新时间 2020年6月30日14:48:58
14-
# 使用说明:安装python3,再在cmd里输入pip install requests 然后改动下面数据就可以了日志文件保存
15-
# 在同目录下的log.txt
16-
def auto_fill(x):
17-
if len(x) > 24:
18-
raise "密钥长度不能大于等于24位!"
19-
else:
20-
while len(x) < 32:
21-
x += "\0"
22-
return x.encode()
23-
24-
25-
def getHash(text):
26-
key = "(#i@x*l%"
27-
x = Crypto.Cipher.DES.new(key.encode(), Crypto.Cipher.DES.MODE_ECB)
28-
a = x.encrypt(auto_fill(str(text))).hex()
29-
return str(a)
30-
31-
32-
def run(username, password):
33-
session = requests.session()
34-
url_login = 'https://my.ruanmei.com/Default.aspx/LoginUser'
35-
data = {'mail': username, 'psw': password, 'rememberme': 'true'}
36-
header = {
37-
'Accept': 'application/json, text/javascript, */*; q=0.01',
38-
'Accept-Encoding': 'gzip, deflate',
39-
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
40-
'Cache-Control': 'no-cache',
41-
'Connection': 'keep-alive',
42-
'Content-Length': '60',
43-
'Content-Type': 'application/json; charset=UTF-8',
44-
'Host': 'my.ruanmei.com',
45-
'Origin': 'http://my.ruanmei.com',
46-
'Pragma': 'no-cache',
47-
'Referer': 'http://my.ruanmei.com/',
48-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
49-
'X-Requested-With': 'XMLHttpRequest',
50-
}
51-
try:
52-
response = session.post(url=url_login, data=json.dumps(data), headers=header).headers['Set-Cookie']
53-
user_hash = re.search(r'user=hash=[a-zA-Z0-9]{160,160}', response).group()[10:]
54-
md5 = getHash(str(datetime.date.today()))
55-
url_qiandao = 'https://my.ruanmei.com/api/UserSign/Sign?userHash=%s&type=0&endt=%s' % (user_hash, md5)
56-
qiandao = session.get(url=url_qiandao).json()
57-
with open('log.txt', 'a', encoding='utf-8') as f:
58-
f.write(str(datetime.datetime.now()) + ' ' + username + ' ' + str(qiandao['msg']) + '\n')
59-
print(qiandao)
60-
except:
61-
print("用户名或密码错误")
62-
7+
from run import run
638

649
if __name__=='__main__':
6510
parser = argparse.ArgumentParser()

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
requests
22
pycrypto
3+
pyDes

run.py

+207
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
import requests
2+
import json
3+
import re
4+
import datetime
5+
import time
6+
from pyDes import des, ECB
7+
import binascii
8+
9+
requests.packages.urllib3.disable_warnings()
10+
11+
# 项目链连接:https://github.com/daimiaopeng/IthomeQianDao
12+
# 使用说明:安装python3,再在cmd里输入pip install requests 然后改动下面数据就可以了日志文件保存
13+
# 在同目录下的log.txt
14+
def make_up_data(data, mode='PAD_ZERO'):
15+
pad = 8 - len(data) % 8
16+
pad_str = ""
17+
if mode == "PAD_PKCS5":
18+
for i in range(pad):
19+
pad_str += chr(pad)
20+
elif mode == "PAD_ZERO":
21+
for i in range(pad):
22+
pad_str += chr(0)
23+
return data + pad_str
24+
25+
26+
def des_encrypt(s):
27+
"""
28+
DES 加密
29+
:param s: 原始字符串
30+
:return: 加密后字符串,16进制
31+
"""
32+
s = make_up_data(s)
33+
secret_key = KEY
34+
iv = secret_key
35+
k = des(secret_key, ECB, iv, pad=None)
36+
en = k.encrypt(s)
37+
return binascii.b2a_hex(en)
38+
39+
40+
def des_encrypt2(s, key):
41+
"""
42+
DES 加密
43+
:param s: 原始字符串
44+
:return: 加密后字符串,16进制
45+
"""
46+
s = make_up_data(s)
47+
secret_key = key
48+
iv = secret_key
49+
k = des(secret_key, ECB, iv, pad=None)
50+
en = k.encrypt(s)
51+
return binascii.b2a_hex(en).decode()
52+
53+
54+
def des_descrypt(s):
55+
"""
56+
DES 解密
57+
:param s: 加密后的字符串,16进制
58+
:return: 解密后的字符串
59+
"""
60+
secret_key = KEY
61+
iv = secret_key
62+
k = des(secret_key, ECB, iv, pad=None)
63+
de = k.decrypt(binascii.a2b_hex(s))
64+
return de
65+
66+
67+
# print(des_descrypt('b1d5d07310f93d040d19ee09ce9edfc106da4ace88148d05'))
68+
69+
def cn(x):
70+
return x.decode("u8")
71+
72+
73+
def getNowTime13():
74+
return str(int(round(time.time() * 1000)))
75+
76+
77+
def getNowTime132(dtime):
78+
print((str(int(time.mktime(dtime.timetuple()) * 1000))))
79+
return str(int(time.mktime(dtime.timetuple()) * 1000))
80+
81+
82+
def getTime(dtime):
83+
return int(time.mktime(dtime.timetuple())) * 1000
84+
85+
86+
def getDate(dtime):
87+
return dtime.day
88+
89+
90+
def getDate2(dtime):
91+
dtime = datetime.datetime.fromtimestamp(dtime / 1000)
92+
return dtime.day
93+
94+
95+
def parseInt(data):
96+
return int(data)
97+
98+
99+
def geKK(_0x249526, _0x2fce26):
100+
_0x17c13c = "hd7%b4f8p9)*fd4h5l6|)123/*-+!#$@%^*()_+?>?njidfds[]rfbcvnb3rz/ird|opqqyh487874515/%90hggigadfihklhkopjj`b3hsdfdsf84215456fi15451%q(#@Fzd795hn^Ccl$vK^L%#w$^yr%ETvX#0TaPSRm5)OeG)^fQnn6^%^UTtJI#3EZ@p6^Rf$^!O$(jnkOiBjn3#inhOQQ!aTX8R)9O%#o3zCVxo3tLyVorwYwA^$%^b9Yy$opSEAOOlFBsS^5d^HoF%tJ$dx%3)^q^c^$al%b4I)QHq^#^AlcK^KZFYf81#bL$n@$%j^H(%m^"
101+
_0x5c548d = getTime(_0x249526) # 时间戳
102+
_0x5c59ee = getDate(_0x249526) # 当月第几日
103+
_0x5c548d = round(_0x5c548d / 0xc350) * _0x5c59ee * 0x3
104+
if (_0x2fce26 == 3):
105+
return _0x17c13c[parseInt(_0x5c548d % 0x2710 / 0x3e8) * _0x5c59ee] + _0x17c13c[
106+
parseInt(_0x5c548d % 0x3e8 / 0x64) * _0x5c59ee] + _0x17c13c[parseInt(_0x5c548d % 0x64 / 0xa) * _0x5c59ee];
107+
elif (_0x2fce26 == 8):
108+
return _0x17c13c[parseInt(_0x5c548d % 0x5f5e100 / 0x989680) * _0x5c59ee] + _0x17c13c[
109+
parseInt(_0x5c548d % 0x989680 / 0xf4240) * _0x5c59ee] + _0x17c13c[
110+
parseInt(_0x5c548d % 0xf4240 / 0x186a0) * _0x5c59ee] + _0x17c13c[
111+
parseInt(_0x5c548d % 0x186a0 / 0x2710) * _0x5c59ee] + _0x17c13c[
112+
parseInt(_0x5c548d % 0x2710 / 0x3e8) * _0x5c59ee] + _0x17c13c[
113+
parseInt(_0x5c548d % 0x3e8 / 0x64) * _0x5c59ee] + _0x17c13c[
114+
parseInt(_0x5c548d % 0x64 / 0xa) * _0x5c59ee] + _0x17c13c[parseInt(_0x5c548d % 0xa) * _0x5c59ee];
115+
else:
116+
return None
117+
118+
119+
def geKK2(_0x249526, _0x2fce26):
120+
_0x17c13c = "hd7%b4f8p9)*fd4h5l6|)123/*-+!#$@%^*()_+?>?njidfds[]rfbcvnb3rz/ird|opqqyh487874515/%90hggigadfihklhkopjj`b3hsdfdsf84215456fi15451%q(#@Fzd795hn^Ccl$vK^L%#w$^yr%ETvX#0TaPSRm5)OeG)^fQnn6^%^UTtJI#3EZ@p6^Rf$^!O$(jnkOiBjn3#inhOQQ!aTX8R)9O%#o3zCVxo3tLyVorwYwA^$%^b9Yy$opSEAOOlFBsS^5d^HoF%tJ$dx%3)^q^c^$al%b4I)QHq^#^AlcK^KZFYf81#bL$n@$%j^H(%m^"
121+
_0x5c548d = _0x249526 # 时间戳
122+
_0x5c59ee = getDate2(_0x249526) # 当月第几日
123+
_0x5c548d = round(_0x5c548d / 0xc350) * _0x5c59ee * 0x3
124+
if (_0x2fce26 == 3):
125+
return _0x17c13c[parseInt(_0x5c548d % 0x2710 / 0x3e8) * _0x5c59ee] + _0x17c13c[
126+
parseInt(_0x5c548d % 0x3e8 / 0x64) * _0x5c59ee] + _0x17c13c[parseInt(_0x5c548d % 0x64 / 0xa) * _0x5c59ee];
127+
elif (_0x2fce26 == 8):
128+
return _0x17c13c[parseInt(_0x5c548d % 0x5f5e100 / 0x989680) * _0x5c59ee] + _0x17c13c[
129+
parseInt(_0x5c548d % 0x989680 / 0xf4240) * _0x5c59ee] + _0x17c13c[
130+
parseInt(_0x5c548d % 0xf4240 / 0x186a0) * _0x5c59ee] + _0x17c13c[
131+
parseInt(_0x5c548d % 0x186a0 / 0x2710) * _0x5c59ee] + _0x17c13c[
132+
parseInt(_0x5c548d % 0x2710 / 0x3e8) * _0x5c59ee] + _0x17c13c[
133+
parseInt(_0x5c548d % 0x3e8 / 0x64) * _0x5c59ee] + _0x17c13c[
134+
parseInt(_0x5c548d % 0x64 / 0xa) * _0x5c59ee] + _0x17c13c[parseInt(_0x5c548d % 0xa) * _0x5c59ee];
135+
else:
136+
return None
137+
138+
139+
def gneKK(_0x4060f6):
140+
return 'k' + des_encrypt2(geKK(_0x4060f6, 3), geKK(_0x4060f6, 8))
141+
142+
143+
def geKsK(_0x101b3e):
144+
return des_encrypt2(_0x101b3e.strftime('%Y-%m-%d %H:%M:%S'), geKK(_0x101b3e, 8))
145+
146+
147+
def gneKK2(_0x4060f6):
148+
return 'k' + des_encrypt2(geKK2(_0x4060f6, 3), geKK2(_0x4060f6, 8))
149+
150+
151+
def geKsK2(_0x101b3e):
152+
return des_encrypt2(datetime.datetime.fromtimestamp(_0x101b3e / 1000).strftime('%Y-%m-%d %H:%M:%S'),
153+
geKK2(_0x101b3e, 8))
154+
155+
156+
def getSign():
157+
now = int(time.time() * 1000)
158+
return "&timestamp=" + str(now) + "&" + gneKK2(now) + "=" + geKsK2(now)
159+
160+
161+
def run(username, password):
162+
qiandaocode = [0, 1, 2, 3, 256, 257, 258, 259, 512, 513, 514, 515, 768, 769, 770, 771]
163+
url_login = 'https://my.ruanmei.com/Default.aspx/LoginUser'
164+
data = {'mail': username, 'psw': password, 'rememberme': 'true'}
165+
header = {
166+
'Accept': 'application/json, text/javascript, */*; q=0.01',
167+
'Accept-Encoding': 'gzip, deflate',
168+
'Content-Type': 'application/json; charset=UTF-8',
169+
'Host': 'my.ruanmei.com',
170+
'Origin': 'http://my.ruanmei.com',
171+
'Referer': 'http://my.ruanmei.com/',
172+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
173+
'X-Requested-With': 'XMLHttpRequest',
174+
}
175+
try:
176+
response = requests.post(url=url_login, data=json.dumps(data), headers=header).headers['Set-Cookie']
177+
user_hash = re.search(r'user=hash=[a-zA-Z0-9]{160,160}', response).group()[10:]
178+
# 云函数时间可能早8个小时,应该使用下面时间
179+
# time = (datetime.datetime.now() + datetime.timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S')
180+
time = current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
181+
endt = getSign()
182+
session = requests.session()
183+
session.verify = False
184+
session.headers = {
185+
'user-agent': 'Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/81.0.4044.138 Mobile Safari/537.36 ithome/rmsdklevel2/night/7.26',
186+
'content-type': 'application/x-www-form-urlencoded',
187+
'accept': '*/*',
188+
'x-requested-with': 'com.ruanmei.ithome',
189+
'sec-fetch-site': 'same-origin',
190+
'sec-fetch-mode': 'cors',
191+
'sec-fetch-dest': 'empty',
192+
'referer': 'https://my.ruanmei.com/app/user/signin.html?hidemenu=1&appver=2',
193+
}
194+
for fuck in qiandaocode:
195+
url_qiandao = 'https://my.ruanmei.com/api/usersign/sign?userHash=%s&type=%s&endt=%s' % (
196+
user_hash, fuck, endt)
197+
try:
198+
qiandao = session.get(url=url_qiandao).json()
199+
print(qiandao)
200+
except Exception as e:
201+
print(e)
202+
continue
203+
except Exception as e:
204+
print(e)
205+
print("可能密码错误")
206+
207+

0 commit comments

Comments
 (0)