Files

64 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
"""下载门户前端 bundle,定位「国密信封 / 鉴权头」相关代码,评估逆向成本。
搜:session/create、plainText、SecurityType、Authorization、DigitalEnvelope、interceptors
"""
import os
import re
import sys
import requests
try:
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
except Exception:
pass
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
OUT_DIR = os.path.join(REPO, 'logs', 'bankcomm_probe', 'js')
os.makedirs(OUT_DIR, exist_ok=True)
BASE = 'https://merchantapp.bankcomm.com/mm/js/'
FILES = [
'bundle.app.d353b068.js',
'bundle.chunk-libs.84ed967f.js',
'bundle.1.b8b6b54d.js',
'bundle.4.8e0b362d.js',
'bundle.8.72ee03e6.js',
'bundle.18.8c325f96.js',
'manifest.d26e73da8a4be83757f4.js',
]
KEYWORDS = ['session/create', 'plainText', 'SecurityType', 'DigitalEnvelope', 'interceptors',
'encryptData', 'Token-Id', 'Authorization', 'keyou', 'KeyouCryptography']
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120.0.0.0 Safari/537.36',
'Referer': 'https://merchantapp.bankcomm.com/mm/'}
for name in FILES:
path = os.path.join(OUT_DIR, name)
if not os.path.exists(path):
try:
r = requests.get(BASE + name, headers=headers, timeout=60)
if r.status_code != 200:
print(f'{name}: HTTP {r.status_code}')
continue
open(path, 'wb').write(r.content)
except Exception as e:
print(f'{name}: 下载失败 {e}')
continue
size = os.path.getsize(path)
text = open(path, 'r', encoding='utf-8', errors='ignore').read()
hits = {k: text.count(k) for k in KEYWORDS if k in text}
print(f'{name} {size / 1024:.0f}KB 命中: {hits}', flush=True)
# 定位关键代码片段
app = os.path.join(OUT_DIR, 'bundle.app.d353b068.js')
if os.path.exists(app):
text = open(app, 'r', encoding='utf-8', errors='ignore').read()
for kw in ('session/create', 'DigitalEnvelope', 'SecurityType'):
idx = text.find(kw)
print('\n' + '=' * 90)
print(f'### {kw} @ {idx}')
if idx > 0:
print(text[max(0, idx - 1500):idx + 1500].replace('\n', ' '))