Initialize encryption and JavaScript reverse-engineering study repository

Document the project structure and setup while excluding local dependencies and IDE settings.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 23:25:05 +08:00
commit 418a0411d1
34 changed files with 1544 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
import time
import requests
import execjs
headers = {
"Accept": "application/json, text/plain, */*",
"Accept-Language": "zh-CN,zh;q=0.9",
"Connection": "keep-alive",
"Content-Length": "0",
"Origin": "https://ec.minmetals.com.cn",
"Referer": "https://ec.minmetals.com.cn/open/home/purchase-info",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36",
"sec-ch-ua": "\"Chromium\";v=\"152\", \"Not?A_Brand\";v=\"24\", \"Google Chrome\";v=\"152\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\""
}
with open("五矿集团.js", "r", encoding="utf-8") as f:
code_js = f.read()
cookies = {
# "__jsluid_s": "e761c17024077e17ad5b78ccdd2b3df3",
"SUNWAY-ESCM-COOKIE": "a9a9e461-c1c4-4348-b1f3-60ace80a499e",
"JSESSIONID": "C1F0A4A6E17FA8D3F9674563DF3F20C9"
}
ctx = execjs.compile(code_js)
for page in range(1, 6):
public_key = requests.post("https://ec.minmetals.com.cn/open/homepage/public", headers=headers).text
encrypt_params = ctx.call("encrypt_param", public_key, page)
json_data = {
"param": encrypt_params,
}
response = requests.post(
"https://ec.minmetals.com.cn/open/homepage/zbs/by-lx-page",
cookies=cookies,
headers=headers,
json=json_data
)
print(response.json())
# print(response.text)
time.sleep(1)

View File

@@ -0,0 +1,103 @@
var JSEncrypt = require("jsencrypt");
var crypto_js = require("crypto-js");
function w(A) {
var e, t, n = "", r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", a = "=";
for (e = 0; e + 3 <= A.length; e += 3)
t = parseInt(A.substring(e, e + 3), 16),
n += r.charAt(t >> 6) + r.charAt(63 & t);
e + 1 == A.length ? (t = parseInt(A.substring(e, e + 1), 16),
n += r.charAt(t << 2)) : e + 2 == A.length && (t = parseInt(A.substring(e, e + 2), 16),
n += r.charAt(t >> 2) + r.charAt((3 & t) << 4));
while ((3 & n.length) > 0)
n += a;
return n
}
function encryptLong(jsencrypt_object, A) {
var e = jsencrypt_object.getKey()
, t = (e.n.bitLength() + 7 >> 3) - 11;
try {
var n = ""
, r = "";
if (A.length > t)
return n = A.match(/.{1,50}/g),
n.forEach((function (A) {
var t = e.encrypt(A);
r += t
}
)),
w(r);
var a = e.encrypt(A)
, s = w(a);
return s
} catch (i) {
return i
}
}
function v(A, e) {
var t = Object.keys(A);
if (Object.getOwnPropertySymbols) {
var n = Object.getOwnPropertySymbols(A);
e && (n = n.filter((function (e) {
return Object.getOwnPropertyDescriptor(A, e).enumerable
}
))),
t.push.apply(t, n)
}
return t
}
function encode_MD5(data) {
return crypto_js.MD5(data).toString()
}
function m(A) {
for (var e = 1; e < arguments.length; e++) {
var t = null != arguments[e] ? arguments[e] : {};
e % 2 ? v(Object(t), !0).forEach((function (e) {
b(A, e, t[e])
}
)) : Object.getOwnPropertyDescriptors ? Object.defineProperties(A, Object.getOwnPropertyDescriptors(t)) : v(Object(t)).forEach((function (e) {
Object.defineProperty(A, e, Object.getOwnPropertyDescriptor(t, e))
}
))
}
return A
}
function b(A, e, t) {
return e in A ? Object.defineProperty(A, e, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : A[e] = t,
A
}
function encrypt_param(public_key, page) {
var r = public_key;
var t = new JSEncrypt();
t.setPublicKey(r);
var e = {
"inviteMethod": "",
"businessClassfication": "",
"mc": "",
"lx": "ZBGG",
"dwmc": "",
"pageIndex": page
};
a = m(m({}, e), {}, {
sign: encode_MD5(JSON.stringify(e)),
timeStamp: +new Date
});
return encryptLong(t, JSON.stringify(a))
}
// var key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrD7FHuUUHUCWeInEnnRraglf7ytCal3jB4bP66T7vkUQZRepM1uNr1LWucdPMYvDsaN8LSsu8HHwoqqRoQx33T5pNrFWe4/daccjbM7m7h8VWRQ2Ny3rgRNuSIIg012o25ORgpAHjGBXQ+mMzFYvCFYzY6sKMmqS3k0xYpy6KwwIDAQAB";
// console.log(new JSEncrypt().__proto__)
// console.log(encrypt_param(key, 0))