需要先安装node环境。
扣下来的webpak,与补还境js,动不动上万行,高并发服务器资源占用过大,使用express搭建服务能有效节省资源。
安装express模块
npm install express
const express = require('express')
const app = express();
const port = 3000;
app.use(express.json());
app.post('/', (req, res) => {
const data = req.body;
// console.log(data)
const body = data['body']
const n_ = data['n_']
const e_ = data['e_']
const str_ma_value1 = data['str_ma_value1']
const resp = getpwd(body,n_,e_,str_ma_value1);
// console.log(resp)
res.send(resp);
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}!`);
})
port为端口号,app.post为请求方式,可以自定义,req.body为请求头中的表单数据,以json的格式传递。
def set_pwd(self, body, Authorization, Token,str_ma_value1):
url = 'http://localhost:3000/'
data = {
'body': body, 'n_': Authorization, 'e_': Token,'str_ma_value1':str_ma_value1}
for i in range(1, 4):
try:
response = requests.post(url, json=data)
if response.status_code == 200:
return response.json()
except Exception as e:
print(f'获取加密字符串失败{e}')
请求接口既可得到js加密结果。
补还境需要v8环境,可以用vm2模块或者找编译好的v8dll。
const express = require('express');
const fs = require('fs');
const app = express();
const scriptPath = 'zhifu.js';
var { VM , VMScript} = require('vm2');
const script = new VMScript(fs.readFileSync(scriptPath));
var vm = new VM();
app.use(express.json());
app.post('/UO', (req, res) => {
console.log(req.body)
const data = req.body['data'];
// console.log(data)
const result = vm.run(script,data)
res.send(result);
});
app.listen(3000, () => {
console.log('Server started at http://localhost:3000');
});
需要注意的是,如果使用vm2模块来传参的话, const result = vm.run(script,data),,vm.rum第二个参数传递的是以字典的形式传递的,