|
| 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 "×tamp=" + 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