2024-12-13 07:37:36 +02:00
|
|
|
import cheerio from"assets://js/lib/cheerio.min.js";import"assets://js/lib/crypto-js.js";import"./node-rsa.js";import"./pako.min.js";import 模板 from"./模板.js";import{gbkTool}from"./gbk.js";import"./json5.js";import"./jinja.js";const _jinja2=cheerio.jinja2;cheerio.jinja2=function(template,obj){try{return jinja.render(template,obj)}catch(e){console.log("新的jinja2库渲染失败,换回原始cheerio:"+e.message);return _jinja2(template,obj)}};function init_test(){console.log("init_test_start");console.log("当前版本号:"+VERSION);console.log("本地代理地址:"+getProxyUrl());console.log(RKEY);console.log(JSON.stringify(rule));console.log("init_test_end")}function ocr_demo_test(){let img_base64=`iVBORw0KGgoAAAANSUhEUgAAAIAAAAAoBAMAAADEX+97AAAAG1BMVEXz+/4thQTa7N6QwIFFkyNeokKozqDB3b93sWHFR+MEAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABN0lEQVRIie2TQU+DQBCFt9vScvQpxR4xrcSjJCZ67JDGXsX+AdR4B3vpsSYm/m2HXaRLmuySepR3Gdidb/btDAjRq5dT96eCMlfBuzi1QLZUoZy2yz5sOvI+9iomaPEZ6nWnEtxqIyiM1RcAy44GNDhBXUjot/VVNweV1ah68FqWRyjKIOqAcyYF6rGcmpYnHzGt3fycNoMw0d3/THFu7hFSJ/8OXO6iTM8/KSg09obAzIHLO250LgQ0txOZSfgrV4Exdw98uGycJ0ErAeExZGhOmFHV9zHO6qVSj0MpLq7xZON56o++MjlsEgfVhbQWWME+xQX7J4V6zfi9A1Ly9rP1BvEXp+BbVJ/M77n+wfOIDVp51pZ4iBxvmj9AGrtvry6emwfKnVkW+ZRKd5ZNMvob36vXP9YPDmQki8QiCFAAAAAASUVORK5CYII=`;OcrApi.api=OCR_API;let code=OcrApi.classification(img_base64);log("测试验证码图片的ocr识别结果为:"+code)}function rsa_demo_test(){let t1=(new Date).getTime();let pkcs1_public=`
|
|
|
|
-----BEGIN RSA PUBLIC KEY-----
|
|
|
|
MEgCQQCrI0pQ/ERRpJ3Ou190XJedFq846nDYP52rOtXyDxlFK5D3p6JJu2RwsKwy
|
|
|
|
lsQ9xY0xYPpRZUZKMEeR7e9gmRNLAgMBAAE=
|
|
|
|
-----END RSA PUBLIC KEY-----
|
|
|
|
`.trim();let pkcs1_public_pem=`
|
|
|
|
MEgCQQCrI0pQ/ERRpJ3Ou190XJedFq846nDYP52rOtXyDxlFK5D3p6JJu2RwsKwy
|
|
|
|
lsQ9xY0xYPpRZUZKMEeR7e9gmRNLAgMBAAE=
|
|
|
|
`.trim();let pkcs8_public=`
|
|
|
|
-----BEGIN PUBLIC KEY-----
|
|
|
|
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/
|
|
|
|
nas61fIPGUUrkPenokm7ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQ==
|
|
|
|
-----END PUBLIC KEY-----`.trim();let pkcs8_public_pem=`
|
|
|
|
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/
|
|
|
|
nas61fIPGUUrkPenokm7ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQ==
|
|
|
|
`.trim();let pkcs1_private=`
|
|
|
|
-----BEGIN RSA PRIVATE KEY-----
|
|
|
|
MIIBOAIBAAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/nas61fIPGUUrkPenokm7
|
|
|
|
ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQI/b6OV1z65UokQaMvSeRXt
|
|
|
|
0Yv6wiYtduQI9qpq5nzy/ytaqsbBfClNTi/HifKPKxlRouWFkc518EQI8LBxoarJ
|
|
|
|
AiEA4DaONMplV8PQNa3TKn2F+SDEvLOCjdL0kHKdN90Ti28CIQDDZnTBaHgZwZbA
|
|
|
|
hS7Bbf5yvwjWMhO6Y7l04/Qm7R+35QIgPuQuqXIoUSD080mp1N5WyRW++atksIF+
|
|
|
|
5lGv9e6GP/MCICnj8y/rl6Pd7tXDN6zcSeqLrfdNsREKhB3dKOCXgW9JAiAFYtFS
|
|
|
|
EJNBXVRTK42SNsZ2hJ/9xLwOwnH2epT8Q43s3Q==
|
|
|
|
-----END RSA PRIVATE KEY-----
|
|
|
|
`.trim();let pkcs8_private=`
|
|
|
|
-----BEGIN PRIVATE KEY-----
|
|
|
|
MIIBUgIBADANBgkqhkiG9w0BAQEFAASCATwwggE4AgEAAkEAqyNKUPxEUaSdzrtf
|
|
|
|
dFyXnRavOOpw2D+dqzrV8g8ZRSuQ96eiSbtkcLCsMpbEPcWNMWD6UWVGSjBHke3v
|
|
|
|
YJkTSwIDAQABAj9vo5XXPrlSiRBoy9J5Fe3Ri/rCJi125Aj2qmrmfPL/K1qqxsF8
|
|
|
|
KU1OL8eJ8o8rGVGi5YWRznXwRAjwsHGhqskCIQDgNo40ymVXw9A1rdMqfYX5IMS8
|
|
|
|
s4KN0vSQcp033ROLbwIhAMNmdMFoeBnBlsCFLsFt/nK/CNYyE7pjuXTj9CbtH7fl
|
|
|
|
AiA+5C6pcihRIPTzSanU3lbJFb75q2SwgX7mUa/17oY/8wIgKePzL+uXo93u1cM3
|
|
|
|
rNxJ6out902xEQqEHd0o4JeBb0kCIAVi0VIQk0FdVFMrjZI2xnaEn/3EvA7CcfZ6
|
|
|
|
lPxDjezd
|
|
|
|
-----END PRIVATE KEY-----
|
|
|
|
`.trim();let data=`
|
|
|
|
NodeRsa
|
|
|
|
这是node-rsa 现在修改集成在drpy里使用`.trim();let encryptedWithPublic=NODERSA.encryptRSAWithPublicKey(data,pkcs1_public,{outputEncoding:"base64",options:{environment:"browser",encryptionScheme:"pkcs1_oaep"}});console.log("公钥加密");console.log(encryptedWithPublic);let decryptedWithPrivate=NODERSA.decryptRSAWithPrivateKey(encryptedWithPublic,pkcs1_private,{options:{environment:"browser",encryptionScheme:"pkcs1_oaep"}});console.log("私钥解密");console.log(decryptedWithPrivate);let pkcs1_sha256_sign=NODERSA.sign("1",pkcs1_private,{outputEncoding:"base64",options:{environment:"browser",encryptionScheme:"pkcs1",signingScheme:"pkcs1-sha256"}});console.log("pkcs1_sha256_sign");console.log(pkcs1_sha256_sign);let pkcs1_sha256_sign_verify=NODERSA.verify("1","Oulx2QrgeipKYBtqEDqFb2s/+ndk2cGQxO4CkhU7iBM1vyNmmvqubpsmeoUuN3waGrYZLknSEdwBkfv0tUMpFQ==",pkcs1_private,{options:{environment:"browser",encryptionScheme:"pkcs1",signingScheme:"pkcs1-sha256"}});console.log("pkcs1_sha256_sign_verify");console.log(pkcs1_sha256_sign_verify);let pkcs1_oaep_sha256=NODERSA.encryptRSAWithPublicKey(data,`-----BEGIN RSA PUBLIC KEY-----
|
|
|
|
MIIBCgKCAQEA5KOq1gRNyllLNWKQy8sGpZE3Q1ULLSmzZw+eaAhj9lvqn7IsT1du
|
|
|
|
SYn08FfoOA2qMwtz+1O2l1mgzNoSVCyVpVabnTG+C9XKeZXAnJHd8aYA7l7Sxhdm
|
|
|
|
kte+iymYZ0ZBPzijo8938iugtVvqi9UgDmnY3u/NlQDqiL5BGqSxSTd/Sgmy3zD8
|
|
|
|
PYzEa3wD9vehQ5fZZ45vKIq8GNVh2Z8+IGO85FF1OsN7+b2yGJa/FmDDNn0+HP+m
|
|
|
|
PfI+kYBqEVpo0Ztbc3UdxgFwGC8O1n8AQyriwHnSOtIiuBH62J/7qyC/3LEAApRb
|
|
|
|
Dd9YszqzmODjQUddZKHmvc638VW+azc0EwIDAQAB
|
|
|
|
-----END RSA PUBLIC KEY-----
|
|
|
|
`,{outputEncoding:"base64",options:{environment:"browser",encryptionScheme:{scheme:"pkcs1_oaep",hash:"sha256"}}});console.log("pkcs1_oaep_sha256");console.log(pkcs1_oaep_sha256);decryptedWithPrivate=NODERSA.decryptRSAWithPrivateKey("kSZesAAyYh2hdsQnYMdGqb6gKAzTauBKouvBzWcc4+F8RvGd0nwO6mVkUMVilPgUuNxjEauHayHiY8gI3Py45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browser",encryptionScheme:"pkcs1_oaep"}});console.log("decryptedWithPrivate");console.log(decryptedWithPrivate);(()=>{let key=new NODERSA.NodeRSA({b:1024});key.setOptions({encryptionScheme:"pkcs1"});let text=`你好drpy node-ras`;let encrypted=key.encrypt(text,"base64");console.log("encrypted: ",encrypted);const decrypted=key.decrypt(encrypted,"utf8");console.log("decrypted: ",decrypted)})();let t2=(new Date).getTime();console.log("rsa_demo_test 测试耗时:"+(t2-t1)+"毫秒")}function pre(){if(typeof rule.预处理==="string"&&rule.预处理&&rule.预处理.trim()){let code=rule.预处理.trim();console.log("执行预处理代码:"+code);if(code.startsWith("js:")){code=code.replace("js:","")}try{eval(code)}catch(e){console.log(`预处理执行失败:${e.message}`)}}}let rule={};let vercode=typeof pdfl==="function"?"drpy2.1":"drpy2";const VERSION=vercode+" 3.9.51beta2 20240711";const MOBILE_UA="Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36";const PC_UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36";const UA="Mozilla/5.0";const UC_UA="Mozilla/5.0 (Linux; U; Android 9; zh-CN; MI 9 Build/PKQ1.181121.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.5.5.1035 Mobile Safari/537.36";const IOS_UA="Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1";const RULE_CK="cookie";const CATE_EXCLUDE="首页|留言|APP|下载|资讯|新闻|动态";const TAB_EXCLUDE="猜你|喜欢|下载|剧情|榜|评论";const OCR_RETRY=3;const OCR_API="https://api.nn.ci/ocr/b64/text";if(typeof MY_URL==="undefined"){var MY_URL}var HOST;var RKEY;var fetch;var print;var log;var rule_fetch_params;var fetch_params;var oheaders;var _pdfh;var _pdfa;var _pd;const DOM_CHECK_ATTR=/(url|src|href|-original|-src|-play|-url|style)$/;const SPECIAL_URL=/^(ftp|magnet|thunder|ws):/;const NOADD_INDEX=/:eq|:lt|:gt|:first|:last|^body$|^#/;const URLJOIN_ATTR=/(url|src|href|-original|-src|-play|-url|style)$|^(data-|url-|src-)/;const SELECT_REGEX=/:eq|:lt|:gt|#/g;const SELECT_REGEX_A=/:eq|:lt|:gt/g;const $js={toString(func){let strfun=func.toString();return strfun.replace(/^\(\)(\s+)?=>(\s+)?\{/,"js:").replace(/\}$/,"")}};function window_b64(){let b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let base64DecodeChars=new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);function btoa(str){var out,i,len;var c1,c2,c3;len=str.length;i=0;out="";while(i<len){c1=str.charCodeAt(i++)&255;if(i==len){out+=b64map.charAt(c1>>2);out+=b64map.charAt((c1&3)<<4);out+="==";break}c2=str.charCodeAt(i++);if(i==len){out+=b64map.charAt(c1>>2);out+=b64map.charAt((c1&3)<<4|(c2&240)>>4);out+=b64map.charAt((c2&15)<<2);out+="=";break}c3=str.charCodeAt(i++);out+=b64map.charAt(c1>>2);out+=b64map.charAt((c1&3)<<4|(c2&240)>>4);out+=b64map.charAt((c2&15)<<2|(c3&192)>>6);out+=b64map.charAt(c3&63)}return out}function atob(str){var c1,c2,c3,c4;var i,len,out;len=str.length;i=0;out="";while(i<len){do{c1=base64DecodeChars[str.charCodeAt(i++)&255]}while(i<len&&c1==-1);if(c1==-1)break;do{c2=base64DecodeChars[str.charCodeAt(i++)&255]}while(i<len&&c2==-1);if(c2==-1)break;out+=String.fromCharCode(c1<<2|(c2&48)>>4);do{c3=str.charCodeAt(i++)&255;if(c3==61)return out;c3=base64DecodeChars[c3]}while(i<len&&c3==-1);if(c3==-1)break;out+=String.fromCharCode((c2&15)<<4|(c3&60)>>2);do{c4=str.charCodeAt(i++)&255;if(c4==61)return out;c4=base64DecodeChars[c4]}while(i<len&&c4==-1);if(c4==-1)break;out+=String.fromCharCode((c3&3)<<6|c4)}return out}return{atob:atob
|