-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy pathhook_sessionStorage_removeItem.js
More file actions
78 lines (69 loc) · 2.85 KB
/
hook_sessionStorage_removeItem.js
File metadata and controls
78 lines (69 loc) · 2.85 KB
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
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// ==UserScript==
// @name hook_localStorage
// @namespace https://github.com/0xsdeo/Hook_JS
// @version 2025-02-17
// @description hook localStorage all methods
// @author 0xsdeo
// @match http://*/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function () {
'use strict';
const SCRIPT_ID = 'hook_sessionStorage_removeItem';
function clear_Antidebug(id) {
localStorage.removeItem("Antidebug_breaker_" + id + "_flag");
localStorage.removeItem("Antidebug_breaker_" + id + "_param");
localStorage.removeItem("Antidebug_breaker_" + id + "_debugger");
localStorage.removeItem("Antidebug_breaker_" + id + "_stack");
}
function initHook() {
let flag = localStorage.getItem("Antidebug_breaker_" + SCRIPT_ID + "_flag");
let param = JSON.parse(localStorage.getItem("Antidebug_breaker_" + SCRIPT_ID + "_param"));
let is_debugger = localStorage.getItem("Antidebug_breaker_" + SCRIPT_ID + "_debugger");
let is_stack = localStorage.getItem("Antidebug_breaker_" + SCRIPT_ID + "_stack");
let temp_sessionStorage_removeItem = sessionStorage.removeItem;
sessionStorage.removeItem = function () {
if (flag === "0") {
console.log("移除了sessionStorage键\n键名 ---> " + arguments[0]);
if (is_debugger === "1") {
debugger;
}
if (is_stack === "1") {
console.log(new Error().stack);
}
} else {
if (arguments[0] && param.some(item => arguments[0].includes(item))) {
console.log(`捕获到移除了sessionStorage键 ---> ${arguments[0]}`);
if (is_debugger === "1") {
debugger;
}
if (is_stack === "1") {
console.log(new Error().stack);
}
}
}
return temp_sessionStorage_removeItem.call(this, ...arguments);
}
clear_Antidebug(SCRIPT_ID);
}
function setupConfigListener() {
window.addEventListener('message', function (event) {
// 只接受来自扩展的消息
if (event.source !== window ||
!event.data ||
event.data.source !== 'antidebug-extension' ||
event.data.type !== 'HOOK_CONFIG_READY') {
return;
}
// 检查是否包含当前脚本ID
const scriptIds = event.data.scriptIds || [];
if (scriptIds.includes(SCRIPT_ID)) {
// 配置已就绪,初始化Hook
initHook();
}
});
}
// 立即设置监听器
setupConfigListener();
})();