Files

66 lines
1.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""在 window 上找「会话工具 / 加解密封装」对象(含 getSessionData / decrypt 方法)。"""
import json
import sys
import time
try:
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
except Exception:
pass
from DrissionPage import ChromiumPage
SCAN = r"""
var out = [];
function probe(name, v) {
if (!v || (typeof v !== 'object' && typeof v !== 'function')) return;
var methods = [];
try {
var cur = v, d = 0;
while (cur && d < 3) {
Object.getOwnPropertyNames(cur).forEach(function (n) {
try { if (typeof v[n] === 'function' && methods.indexOf(n) < 0) methods.push(n); } catch (e) {}
});
cur = Object.getPrototypeOf(cur); d++;
}
} catch (e) {}
var interesting = methods.filter(function (n) {
return /session|decrypt|encrypt|sign|plain|sm2|sm4|aes|token/i.test(n);
});
if (interesting.length) {
out.push({ name: name, type: typeof v, all: methods.slice(0, 40), hit: interesting });
}
}
try {
Object.keys(window).forEach(function (k) {
try { probe('window.' + k, window[k]); } catch (e) {}
});
} catch (e) {}
// jQuery 上的工具(页面用 $.ajax)
try {
var $ = window.jQuery || window.$;
if ($) {
out.push({ name: 'jQuery', type: 'function', all: ['ajax', 'extend'], hit: ['ajax'] });
Object.keys($).forEach(function (k) {
try { probe('jQuery.' + k, $[k]); } catch (e) {}
});
}
} catch (e) {}
return JSON.stringify(out.slice(0, 40));
"""
page = ChromiumPage('127.0.0.1:9333')
print('URL:', page.url, flush=True)
raw = page.run_js(SCAN)
try:
data = json.loads(raw) if raw else []
except Exception:
data = []
print(f'找到 {len(data)} 个候选对象', flush=True)
for it in data:
s = json.dumps(it, ensure_ascii=False)
if len(s) > 600:
s = s[:600] + '...'
print(s, flush=True)