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,37 @@
// JSEncrypt() node-rsa 两个包
// npm install node-rsa
var node_rsa = require("node-rsa").NodeRSA; // node-rsa 2.x 导出的是 { NodeRSA, default }
class RsaEncryptDecrypt {
constructor(key_size = 1024) {
this.node_rsa = new node_rsa({b: key_size});
this.public_key = this.node_rsa.exportKey("pkcs8-public");
this.private_key = this.node_rsa.exportKey("pkcs8-private");
console.log("公钥:", this.public_key);
console.log("私钥", this.private_key);
}
encrypt(data) {
const public_instance = new node_rsa(this.public_key, "pkcs8-public");
return public_instance.encrypt(data, "base64");
}
decrypt(data) {
const private_instance = new node_rsa(this.private_key, "pkcs8-private");
return private_instance.decrypt(data, "utf8");
}
}
const rsa = new RsaEncryptDecrypt();
const source_data = "你好,世界";
const enc_data = rsa.encrypt(source_data);
console.log("base", enc_data);
const dec_data = rsa.decrypt(enc_data);
console.log("解密结果", dec_data);

View File

@@ -0,0 +1,42 @@
# pip install rsa
import rsa
import base64
"""
非对称加解密需要一对密钥(公钥,私钥)
加密过程中,一般情况使用公钥加密,私钥解密
也能用私钥加密,公钥解密
"""
def create_key():
public_key, private_key = rsa.newkeys(1024) # 字节长度
# print("公钥", public_key)
# print("私钥", private_key)
return public_key, private_key
# 使用公钥加密,私钥解密
def encrypt_data(text, public_key):
bytes_text = text.encode("utf-8")
encrypted_text = rsa.encrypt(bytes_text, public_key)
return base64.b64encode(encrypted_text)
def decrypt_data(encrypted_text, private_key):
bytes_text = base64.b64decode(encrypted_text)
bytes_decrypted_text = rsa.decrypt(bytes_text, private_key)
return bytes_decrypted_text.decode("utf-8")
def main():
public_key, private_key = create_key()
source_data = "你好,世界!"
encrypted_text = encrypt_data(source_data, public_key)
print("base64的密文结果", encrypted_text)
decrypted_text = decrypt_data(encrypted_text, private_key)
print("解密结果", decrypted_text)
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,38 @@
const JSEncrypt = require("jsencrypt")
// function et(_0x32033c) {
// var _0x283d00 = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsgDq4OqxuEisnk2F0EJFmw4xKa5IrcqEYHvqxPs2CHEg2kolhfWA2SjNuGAHxyDDE5MLtOvzuXjBx/5YJtc9zj2xR/0moesS+Vi/xtG1tkVaTCba+TV+Y5C61iyr3FGqr+KOD4/XECu0Xky1W9ZmmaFADmZi7+6gO9wjgVpU9aLcBcw/loHOeJrCqjp7pA98hRJRY+MML8MK15mnC4ebooOva+mJlstW6t/1lghR8WNV8cocxgcHHuXBxgns2MlACQbSdJ8c6Z3RQeRZBzyjfey6JCCfbEKouVrWIUuPphBL3OANfgp0B+QG31bapvePTfXU48TYK0M5kE+8LgbbWQIDAQAB';
// var _0x1defd6 = new JSEncrypt();
// _0x1defd6['setPublicKey'](_0x283d00);
// var _0x4bd6d3 = _0x1defd6['encrypt'](_0x32033c);
// return _0x4bd6d3;
// }
function et(data) {
const key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsgDq4OqxuEisnk2F0EJFmw4xKa5IrcqEYHvqxPs2CHEg2kolhfWA2SjNuGAHxyDDE5MLtOvzuXjBx/5YJtc9zj2xR/0moesS+Vi/xtG1tkVaTCba+TV+Y5C61iyr3FGqr+KOD4/XECu0Xky1W9ZmmaFADmZi7+6gO9wjgVpU9aLcBcw/loHOeJrCqjp7pA98hRJRY+MML8MK15mnC4ebooOva+mJlstW6t/1lghR8WNV8cocxgcHHuXBxgns2MlACQbSdJ8c6Z3RQeRZBzyjfey6JCCfbEKouVrWIUuPphBL3OANfgp0B+QG31bapvePTfXU48TYK0M5kE+8LgbbWQIDAQAB';
const encrypt_instance = new JSEncrypt();
encrypt_instance.setPublicKey(key);
return encrypt_instance.encrypt(data);
}
/*
* 非堆成加密:在加密过程中key固定,密文不固定
*
* */
const password = "admin";
console.log(et(password));
/*
* 在js环境中和实现rsa 有两种方式
* 1. rsa-node
* 2. jsencrypt
* 区别
* rsa-node: 可以自己生成密钥对,并且完成加解密
* jsencrypt: 不能自己生成密钥对,不能完成解密,只能加密(js逆向的中重点使用)
*
*
*/

View File

@@ -0,0 +1,41 @@
import time
import requests
import execjs
with open("参数加密.js", "r", encoding="utf-8") as f:
code_js = f.read()
code = execjs.compile(code_js)
for page in range(1, 2):
temp_params = code.call("beforeSend", page)
headers = {
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Language": "zh-CN,zh;q=0.9",
"Connection": "keep-alive",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Origin": "https://www.birdreport.cn",
"Referer": "https://www.birdreport.cn/",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"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",
"requestId": str(temp_params["requestId"]),
"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\"",
"sign": str(temp_params["sign"]),
"timestamp": str(temp_params["timestamp"])
}
enc_data = temp_params["data"]
url = 'https://api.birdreport.cn/front/activity/search'
response = requests.post(url, headers=headers, data=enc_data)
response_json = response.json()
result = code.call("aes_decrypt", response_json["data"])
print(result)
print(response)
time.sleep(1)

View File

@@ -0,0 +1,51 @@
const JSEncrypt = require("jsencrypt");
var crypto_js = require("crypto-js");
const encrypt = new JSEncrypt();
var paramPublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvxXa98E1uWXnBzXkS2yHUfnBM6n3PCwLdfIox03T91joBvjtoDqiQ5x3tTOfpHs3LtiqMMEafls6b0YWtgB1dse1W5m+FpeusVkCOkQxB4SZDH6tuerIknnmB/Hsq5wgEkIvO5Pff9biig6AyoAkdWpSek/1/B7zYIepYY0lxKQIDAQAB";
encrypt.setPublicKey(paramPublicKey);
function MD5(text) {
return crypto_js.MD5(text).toString();
}
function getUuid() {
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 32; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 16), 1)
}
s[14] = "4";
s[19] = hexDigits.substr(s[19] & 3 | 8, 1);
s[8] = s[13] = s[18] = s[23];
var uuid = s.join("");
return uuid
}
function beforeSend(page) {
var timestamp = Date.parse(new Date);
var requestId = getUuid();
var data = `{"limit":"20","page":"${page}"}`
const sign = MD5(data + requestId + timestamp)
return {
timestamp: timestamp,
requestId: requestId,
sign: sign,
data: encrypt.encrypt(data)
};
}
function aes_decrypt(encrypt_data) {
var key = crypto_js.enc.Utf8.parse("C8EB5514AF5ADDB94B2207B08C66601C");
var iv = crypto_js.enc.Utf8.parse("55DD79C6F04E1A67");
var decrypted = crypto_js.AES.decrypt(encrypt_data, key, {
iv: iv,
mode: crypto_js.mode.CBC,
padding: crypto_js.pad.Pkcs7,
})
return decrypted.toString(crypto_js.enc.Utf8);
}
// console.log(beforeSend(1));

View File

@@ -0,0 +1,9 @@
_0x48989b["prototype"]['decode'] = function (_0x291626) {
var _0x3c6fa1 = CryptoJS['enc']["Utf8"]["parse"]("C8EB5514AF5ADDB94B2207B08C66601C")
, _0x3ec027 = CryptoJS["enc"]["Utf8"]["parse"]("55DD79C6F04E1A67");
return CryptoJS["AES"]["decrypt"](_0x291626, _0x3c6fa1, {
'iv': _0x3ec027,
'mode': CryptoJS["mode"]['CBC'],
'padding': CryptoJS['pad']["Pkcs7"]
})['toString'](CryptoJS['enc']['Utf8']);
}