You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
4.3 KiB
100 lines
4.3 KiB
const {jsdomFromText, browser} = require("sdenv"); |
|
const {Script} = require("node:vm"); |
|
const fs = require("node:fs"); |
|
|
|
var baseUrl = 'https://dppt.hubei.chinatax.gov.cn:8443' |
|
// TODO 需要文件内的 meta name="_y_ds" content 标签内容 |
|
var html = fs.readFileSync('./invoice-business.html', 'utf8').toString(); |
|
let js = fs.readFileSync('./chunk-npjg4qgmmrfrjl3r.js', 'utf8').toString(); |
|
|
|
// TODO:用户登陆token 测试时需要替换 |
|
|
|
var loginCookieStr = "tpass_b6edq5qqc5cb4c3288q6aq6fab5qc3b4=eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6Ijg5OWU0YmY0Zjc1MDQ2MjVhN2Q5ZDhlOGI1NDgzMzIyIn0.uLlvtURVPmXLcdNNJ3CXhGny-DkOGdxwpNXUG6PFHvdU1neB9KuAtv-BgMASpVNkDdcaE7X83KNYQBo71RRgsw; oauth2_referer=tpass.hubei.chinatax.gov.cn; dzfp-ssotoken=ead1a9f890334b87afe794f7a7cb253b; SSO_SECURITY_CHECK_TOKEN=d993b316a5364fe0b6468097ff17ed34; lzkqow39189=b3ed138d997243298f97b8928c890282; DTSwUOYx7MiWN=7e54eee01efbde62fbfd2ee721ffdeb410a0c8af47c6187720cb2c505694923f" |
|
|
|
async function get_los(url, param) { |
|
console.time('js执行时长') |
|
const [jsDom, cookieJar] = jsdomFromText({ |
|
url: `${baseUrl}/invoice-query/invoice-query`, |
|
referrer: baseUrl, |
|
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36', |
|
contentType: "text/html", |
|
runScripts: "outside-only", // runScripts: 'dangerously'/'outside-only' |
|
}) |
|
// 加载dom |
|
let dom = await jsDom(html); |
|
const window = dom.window |
|
|
|
// 设置 cookie |
|
for (let cookie of loginCookieStr.trim().split("; ")) { |
|
cookieJar.setCookieSync(cookie, baseUrl); |
|
} |
|
|
|
browser(window, 'chrome'); |
|
// 加载js |
|
let script = new Script(js); |
|
let internalVMContext = dom.getInternalVMContext(); |
|
// 执行 js |
|
script.runInContext(internalVMContext, {timeout: 1000}); |
|
|
|
if (window.$dunm.$byno) { |
|
window.$dunm.$byno(); |
|
} |
|
|
|
let los = window[window["_d_ts"]](url, param); |
|
|
|
console.log('js执行完成,返回结果 ', los) |
|
// 关闭 |
|
dom.window.close() |
|
console.timeEnd('js执行时长') |
|
// console.log(cookieJar.getCookieStringSync(baseUrl)) |
|
var getPublicKey = await fetch(`${baseUrl + los.hurl}`, { |
|
"headers": { |
|
// "accept": "*/*", |
|
// "accept-language": "zh-CN,zh;q=0.9", |
|
// "cache-control": "no-cache", |
|
// "content-type": "text/plain;charset=UTF-8", |
|
"lzkqow23819": `${los.hd}`, |
|
// "bluewareguid": "d8fd3f2be1d8f629", |
|
// "cache-contro": "no-store", |
|
// "connection": "keep-alive", |
|
// "content-length": "421", |
|
// "date": "Mon, 23 Sep 2024 06:38:44 GMT", |
|
// "pragma": "no-cache", |
|
// "server": "Unknown", |
|
// "x-content-options": "nosniff", |
|
// "x-proxy-by": "Tif-accessgate", |
|
// "x-xss-protection": "1;mode=block", |
|
// "pragma": "no-cache", |
|
// "sec-ch-ua": "\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\"", |
|
// "sec-ch-ua-mobile": "?0", |
|
// "sec-ch-ua-platform": "\"Linux\"", |
|
// "sec-fetch-dest": "empty", |
|
// "sec-fetch-mode": "cors", |
|
// "sec-fetch-site": "same-origin", |
|
// "sso_security_check_token": "d993b316a5364fe0b6468097ff17ed34", |
|
// "x-requested-with": "XMLHttpRequest", |
|
"cookie": cookieJar.getCookieStringSync(baseUrl), |
|
// "Referer": "https://dppt.hubei.chinatax.gov.cn:8443/invoice-business?ruuid=1726970597058", |
|
// "Referrer-Policy": "strict-origin-when-cross-origin" |
|
}, |
|
"body": "", |
|
"method": "POST" |
|
}); |
|
// { |
|
// "ruuid":1727075086647, |
|
// "security-token-key":"dzfp-ssotoken", |
|
// "tokenKey":"2e488a0f3bb44011a69e0508be32d1e5", |
|
// "sign":"38b5dc93648cc6e984228f1c4cacddd5", |
|
// "securityrate":900, |
|
// "publicKey":"MIGf1MA0GCSqGSI2b03DQEBAQUAA4GNADCBiQKBgQCWDd8IFBrE4mBL/QCRv6JaDXtku2Onfq0ddfwlrVbsQtrAzVGuFlBwX+ElZk2qjLMKy5p8hww+CwTrV4g2tmAEb/iZsgqosaKtM7OsrnQ7Zisv7gHgVLxTGlFBPBcaCNYFi31SwktZzwt4SbXTlAmDqYmhqVooSrpT9tBrO6artQIDAQAB", |
|
// "securityrate1":300 |
|
// } |
|
|
|
console.log('测试getPublicKey请求', await getPublicKey.json()) |
|
} |
|
|
|
var url = `/kpfw/cssSecurity/v1/getPublicKey?t=${new Date().getTime()}` |
|
// TODO:如果有 param 加密后得到 enParam |
|
var enParam = "" |
|
get_los(url, enParam); |
|
|
|
|