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.
148 lines
6.5 KiB
148 lines
6.5 KiB
const {jsdomFromText, browser} = require("sdenv"); |
|
const {Script} = require("node:vm"); |
|
const fs = require("node:fs"); |
|
const FpCrypt = require("../../routes/service/static/fp/fp-crypt"); |
|
|
|
|
|
var baseUrl = 'https://dppt.guangdong.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 DTSwUOYx7MiWN = "bd232e748674a385df6c5e99901a43b4dc24fb3112038672608a42924006a46a" |
|
// var dzfpSsotoken = "9a0759a97f3742449ea38701a5c19717" |
|
// var lzkqow38189 = "1727331696505"; |
|
|
|
var loginCookieStr = `oauth2_referer=dppt.guangdong.chinatax.gov.cn; dzfp-ssotoken=fa284f7756fd4d94b850d233a3545a38; SSO_SECURITY_CHECK_TOKEN=66ed9c58a548466f86f0f01462104519; c_time=12; lzkqow39189=6ebec9d6f48b4739a20bdf6664af0954; DTSwUOYx7MiWN=e19a43e42435051de9e20836c2f7b13bfaaeffb2a0f94b649b61d584cba7d7e; lzkqow38189=1727348343254; MKls83gqduGS=023d54cd5928041edd03ea399186756763ca1cb446a65a26cb50ec6b56fc2c2f2ee43ca9eb0fa6c2c5888aea7763550c` |
|
|
|
|
|
var urlPath = `/szzhzz/qlfpcx/v1/queryFpjcxx?t=${new Date().getTime()}` |
|
// var urlPath = `/szzhzz/qlfpcx/v1/queryFpjcxx` |
|
// TODO:如果有 param 加密后得到 enParam |
|
var param = '{"gjbq":"1","fpztDm":["01","02","03","04"],"fplyDm":"0","fplxDm":[],"kprqq":"2024-09-09","kprqz":"2024-09-25","tfrqq":"2024-09-09","tfrqz":"2024-09-25","sflzfp":"","dtBz":"N","pageNumber":1,"pageSize":20}'; |
|
let fpCrypt = new FpCrypt(loginCookieStr, { |
|
publicKey: "MIGf1MA0GCSqGSI2b03DQEBAQUAA4GNADCBiQKBgQCf1rfXNEN4DhiBwUArI95aomsBQUb/zmCrohl3Sye2jkySQ4dZi21oIqTjwkOGp31NmoScCA+dtZpER1N1sbkZjIO9etgdFtGMjRNvGw2stuAOUPa0RUQ0wXHlhzJktoDd3R0EV9ztpaACq2KhpYheh1sZnrf5NHqszR9vC9nvoQIDAQAB", |
|
tokenKey: "0706aeab77e14192853af569233c0e0a" |
|
}); |
|
|
|
let handleParam = fpCrypt.handleParam(param, urlPath); |
|
var enParam = JSON.stringify({'Jmbw': handleParam["enVal"]}); |
|
// headers['security-mes-key'] = $e["enMesKey"] |
|
let handleSuffix = fpCrypt.handleSuffix(urlPath); |
|
|
|
get_los(handleSuffix, enParam); |
|
|
|
|
|
// fpService = new FpService() |
|
|
|
// get_los_test_service() |
|
// async function get_los_test_service() { |
|
// let los = await fpService.get_los(url, enParam, html, loginCookieStr); |
|
// 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": "0684966ef19e4ee286caa4255c336517", |
|
// "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" |
|
// }); |
|
// |
|
// |
|
// console.log('测试getPublicKey请求', await getPublicKey.json()) |
|
// } |
|
|
|
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": { |
|
"security-mes-key": "", |
|
"accept": "application/json, text/plain, */*", |
|
"accept-language": "zh-CN,zh;q=0.9", |
|
"accept-encoding": "gzip, deflate, br, zstd", |
|
"nsrsbh": "91420112MA49HA6G1W", |
|
// "origin": "https://dppt.hubei.chinatax.gov.cn:8443", |
|
// "cache-control": "no-cache", |
|
"content-type": "application/json", |
|
"lzkqow23819": `${los.hd}`, |
|
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36", |
|
// "x-api-type": "xhr", |
|
// "sso_security_check_token": "0684966ef19e4ee286caa4255c336517", |
|
"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", |
|
// "x-b3-sampled":"1", |
|
// "x-b3-spanid": "c850e3c1a85ee988", |
|
// "x-b3-traceid": "c850e3c1a85ee988", |
|
// "x-tsf-client-timestamp": `${new Date().getTime()}000` |
|
}, |
|
"body": `${los.bd}`, |
|
"method": "POST" |
|
}); |
|
|
|
let newVar = await getPublicKey.text(); |
|
|
|
console.log('测试请求', newVar) |
|
}
|
|
|