self_example/Spider/Chapter11_JavaScript逆向/python模拟执行Js/testCrypto.py

31 lines
479 B
Python

# -*- encoding:utf-8 -*-
'''
@Author : dingjiawen
@Date : 2024/01/12 20:28
@Usage :
@Desc :模拟执行crypto
'''
import execjs
import json
player = {
"name": "凯文-杜兰特",
"image": "durant.png",
"birthday": "1988-09-29",
"height": "208cm",
"weight": "108.9KG"
}
file = 'crypto.js'
node = execjs.get()
ctx = node.compile(open(file).read())
js = f"getToken({json.dumps(player, ensure_ascii=False)})"
print(js)
result = ctx.eval(js)
print(result)