-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathpy直接调用AES加密.txt
47 lines (47 loc) · 1.62 KB
/
py直接调用AES加密.txt
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
import requests
import base64
import os
import time
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
def gettime():
time.sleep(1)
return str(int(time.time()))+'000'
def main():
# m为12位时间截,末尾增加一个0,除去最后一位后base64作为ecb的key
# f为10位时间截,末尾增加三个0
popularitylist = []
m = str(int(time.time()*1000))
f = gettime()
data = ''
nodejs = os.popen('node 0501 '+f)
data += nodejs.read().replace('\n', '')+','
nodejs.close()
for i in range(3):
nodejs = os.popen('node 0501 ' + gettime())
data += nodejs.read().replace('\n', '') + ','
nodejs.close()
nodejs = os.popen('node 0502 '+m)
cm = nodejs.read().replace('\n', '')
data += cm
nodejs.close()
key = base64.b64encode(m[:-1].encode())
cryptor = AES.new(key=key, mode=AES.MODE_ECB)
data = base64.b64encode(cryptor.encrypt(pad(data.encode(), AES.block_size))).decode()
headers = {
'cookie': 'm='+cm+'; RM4hZBv0dDon443M='+data
}
for page in range(1, 6):
url = 'http://match.yuanrenxue.com/api/match/5?page='+str(page)+'&m='+m+'&f='+f
response = requests.get(url, headers=headers).json()
for each in response['data']:
popularitylist.append(each['value'])
popularitylist.sort()
sums = sum(popularitylist[-5:])
print(sums)
# 前五名总和:47313
if __name__ == '__main__':
main()