0%

execjs的使用教程

Js逆向库:execjs的使用教程

1、安装

pip3 install PyExecJS

2、运行:

import execjs  # 导入包

def _run_js(Str_start, keys):
code = """
function decrypt(word, keys) { // 此处定义了一个js函数
const CryptoJS = require('crypto-js'); // 导入 crypto-js 加密、解密模块
const decrypted = CryptoJS.AES.decrypt(word, keys); # 开始解密
const plaintext = JSON.parse(decrypted.toString(CryptoJS.enc.Utf8)) # 最后将解密的内容,转换成json格式
return plaintext # 返回解密完成的数据 ==>> Json_string(调用函数)
}
"""

decrypt_ = execjs.compile(code) # 加载 js 代码
Json_string = decrypt_.call("decrypt", Str_start, keys) # 用call 方法 传入已经加载的js内容,并且传入 实参
return Json_string # 返回解密后的内容

string_ = "xxxxxxx" # 这里是你需要解密的内容
keys = "xxxxx" # 这里是解密用到的key
_run_js(string_, keys) # 调用解密函数开始解密