Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 53 additions & 54 deletions src/analyzer/param-encryption-analyzer.js
Original file line number Diff line number Diff line change
@@ -1,105 +1,104 @@
/**
* 分析参数加密
* 参数加密分析器类,用于检测输入参数的加密类型。
*/
class ParamEncryptionAnalyzer {

/**
*
* @param param {Param}
* 分析参数的加密类型。
* @param {Param} param - 需要分析的参数对象,包含一个 `value` 属性。
* @returns {string|null} 返回检测到的加密类型,如果无法识别则返回 `null`。
*/
analyze(param) {
return this.detectEncryptionType(param.value);
}

/**
* 检测输入字符串的加密类型。
* @param {string} input - 需要检测的输入字符串。
* @returns {string|null} 返回检测到的加密类型,如果无法识别则返回 `null`。
*/
detectEncryptionType(input) {
// Base64
const base64Regex = /^[A-Za-z0-9+/]+={0,2}$/;
if (base64Regex.test(input) && input.length % 4 === 0) {
return "Base64";

// 如果输入为空,直接返回 null
if (!input) {
return null;
}

// MD5
// // Base64 编码检测
// const base64Regex = /^[A-Za-z0-9+/]+={0,2}$/;
// if (base64Regex.test(input) && input.length % 4 === 0) {
// return "Base64";
// }

// MD5 哈希检测
const md5Regex = /^[a-f0-9]{32}$/i;
if (md5Regex.test(input)) {
return "MD5";
}

// SHA-1
// SHA-1 哈希检测
const sha1Regex = /^[a-f0-9]{40}$/i;
if (sha1Regex.test(input)) {
return "SHA-1";
}

// SHA-256
// SHA-256 哈希检测
const sha256Regex = /^[a-f0-9]{64}$/i;
if (sha256Regex.test(input)) {
return "SHA-256";
}

// SHA-512
// SHA-512 哈希检测
const sha512Regex = /^[a-f0-9]{128}$/i;
if (sha512Regex.test(input)) {
return "SHA-512";
}

// bcrypt
// bcrypt 哈希检测
const bcryptRegex = /^\$2[aby]\$\d{2}\$[.\/A-Za-z0-9]{53}$/;
if (bcryptRegex.test(input)) {
return "bcrypt";
}

// URL编码
const urlEncodedRegex = /%[0-9A-Fa-f]{2}/;
if (urlEncodedRegex.test(input)) {
return "URL Encoded";
}

// Hex编码
const hexRegex = /^[0-9A-Fa-f]+$/;
if (hexRegex.test(input) && input.length % 2 === 0) {
return "Hex Encoded";
}

// ROT13
const rot13Regex = /^[A-Za-z]+$/;
if (rot13Regex.test(input) && input === input.replace(/[A-Za-z]/g, function (c) {
return String.fromCharCode(c.charCodeAt(0) + (c.toLowerCase() < 'n' ? 13 : -13));
})) {
return "ROT13";
}

// JWT
const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
if (jwtRegex.test(input)) {
return "JWT";
}

// UUID
// // URL 编码检测
// const urlEncodedRegex = /%[0-9A-Fa-f]{2}/;
// if (urlEncodedRegex.test(input)) {
// return "URL Encoded";
// }
//
// // Hex 编码检测
// const hexRegex = /^[0-9A-Fa-f]+$/;
// if (hexRegex.test(input) && input.length % 2 === 0) {
// return "Hex Encoded";
// }

// // ROT13 编码检测
// const rot13Regex = /^[A-Za-z]+$/;
// if (rot13Regex.test(input) && input === input.replace(/[A-Za-z]/g, function (c) {
// return String.fromCharCode(c.charCodeAt(0) + (c.toLowerCase() < 'n' ? 13 : -13));
// })) {
// return "ROT13";
// }

// // JWT (JSON Web Token) 检测
// const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
// if (jwtRegex.test(input)) {
// return "JWT";
// }

// UUID 检测
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
if (uuidRegex.test(input)) {
return "UUID";
}

// 如果都不匹配,返回未知
// 如果以上所有加密类型都不匹配,返回 null 表示未知加密类型
return null;
}

// // 测试示例
// console.log(detectEncryptionType("SGVsbG8gV29ybGQ=")); // Base64
// console.log(detectEncryptionType("5d41402abc4b2a76b9719d911017c592")); // MD5
// console.log(detectEncryptionType("2fd4e1c67a2d28fced849ee1bb76e7391b93eb12")); // SHA-1
// console.log(detectEncryptionType("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")); // SHA-256
// console.log(detectEncryptionType("$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy")); // bcrypt
// console.log(detectEncryptionType("Hello%20World")); // URL Encoded
// console.log(detectEncryptionType("48656c6c6f20576f726c64")); // Hex Encoded
// console.log(detectEncryptionType("Uryyb Jbeyq")); // ROT13
// console.log(detectEncryptionType("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")); // JWT
// console.log(detectEncryptionType("550e8400-e29b-41d4-a716-446655440000")); // UUID
// console.log(detectEncryptionType("randomstring")); // Unknown Encryption Type

}


// 导出 ParamEncryptionAnalyzer 类
module.exports = {
ParamEncryptionAnalyzer
}
11 changes: 10 additions & 1 deletion src/analyzer/request-analyzer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const {getUnsafeWindow} = require("../utils/scope-util");
const {ParamEncryptionAnalyzer} = require("./param-encryption-analyzer");

/**
* 分析请求中的jsonp情况,主要是看一下是否存在jsonp参数,并将其识别出来
Expand All @@ -10,16 +11,24 @@ class RequestAnalyzer {
* @param requestContext {RequestContext}
*/
analyze(requestContext) {

if (!requestContext.params) {
return null;
}
requestContext.params = this.computeParamsJsonpCallbackScore(requestContext.params);

// 自动推断出jsonp参数
requestContext.params = this.computeParamsJsonpCallbackScore(requestContext.params);
// 选出其中可能性最大的一个参数作为jsonp callback参数
if (requestContext.params && requestContext.params.length && requestContext.params[0].jsonpCallbackScore > 0) {
requestContext.params[0].isJsonpCallback = true;
}

// 推断参数加密方式
const paramEncryptionAnalyzer = new ParamEncryptionAnalyzer();
for (let param of requestContext.params) {
param.encryptType = paramEncryptionAnalyzer.analyze(param);
}

}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class Config {
this.language = "english";

// 让用户能够自己指定前缀,也许会有一些拥有感?之前ast hook好像就有个哥们喜欢这样干...
this.prefix = "CC11001100";
this.prefix = "JSREI";

this.hookType = "use-proxy-function";

// 是否忽略.js后缀的请求
this.isIgnoreJsSuffixRequest = true;
this.isIgnoreJsSuffixRequest = false;

// 是否忽略不是jsonp的请求
this.isIgnoreNotJsonpRequest = true;
this.isIgnoreNotJsonpRequest = false;

// 在打开配置页面的时候自动跳转到项目主页
this.autoJumpProjectSiteOnConfiguraion = true;
Expand Down
12 changes: 6 additions & 6 deletions src/config/ui/component/configuration-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const {getGlobalConfig} = require("../../config");
const {getLanguage} = require("./language");

/**
* 使用之前要签署用户协议
* 配置组件
*/
class ConfigurationComponent {

constructor() {
this.modalHTML = `
<div id="cc11001100-js-script-hook-configuration-modal-window" style="display:none !important; position:fixed !important; left:0 !important; top:0 !important; width:100% !important; height:100% !important; background-color:rgba(0,0,0,0.85) !important; z-index:2147483646 !important; overflow-y:auto !important;">
<div id="jsrei-js-script-hook-configuration-modal-window" style="display:none !important; position:fixed !important; left:0 !important; top:0 !important; width:100% !important; height:100% !important; background-color:rgba(0,0,0,0.85) !important; z-index:2147483646 !important; overflow-y:auto !important;">
<div class="js-script-hook-scrollable-div" style="display: flex; width: 930px !important; text-align: center !important; padding: 30px !important; margin: 10px !important; position:absolute !important; left:50% !important; top:50% !important; transform:translate(-50%, -50%) !important; background:white !important; border-radius:5px !important; box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important; max-width:80% !important; text-align:center !important; z-index:99999999999; !important">
<button id="cc11001100-js-script-hook-configuration-close-btn" style="position:absolute; right:8px; top:8px; cursor:pointer; padding:3px 6px; border:none; background-color:#f44336; color:white; border-radius:50%; font-size:10px;">×</button>
<button id="jsrei-js-script-hook-configuration-close-btn" style="position:absolute; right:8px; top:8px; cursor:pointer; padding:3px 6px; border:none; background-color:#f44336; color:white; border-radius:50%; font-size:10px;">×</button>
<div id="js-script-hook-configuration-content" style="color: black;"></div>
</div>
</div>
Expand All @@ -39,15 +39,15 @@ class ConfigurationComponent {
$("#js-script-hook-configuration-content").append(debuggerManager.render(language, getGlobalConfig().debuggers));

// 关闭按钮事件处理
document.getElementById("cc11001100-js-script-hook-configuration-close-btn").addEventListener('click', this.closeModalWindow);
document.getElementById("cc11001100-js-script-hook-configuration-modal-window").style.display = 'flex';
document.getElementById("jsrei-js-script-hook-configuration-close-btn").addEventListener('click', this.closeModalWindow);
document.getElementById("jsrei-js-script-hook-configuration-modal-window").style.display = 'flex';
}

/**
* 隐藏模态框的函数
*/
closeModalWindow() {
const element = document.getElementById("cc11001100-js-script-hook-configuration-modal-window");
const element = document.getElementById("jsrei-js-script-hook-configuration-modal-window");
if (element) {
element.parentNode.removeChild(element);
}
Expand Down
Loading