# Tokenpay Gateway Pentest

> Use when a TokenPay crypto payment gateway is in scope.

- Skill: `yufeifeio/tokenpay-gateway-pentest` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx get-skill add yufeifeio/tokenpay-gateway-pentest`
- Raw SKILL.md: https://api.skillmd.com/api/skills/yufeifeio/tokenpay-gateway-pentest/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Yufeifeio (https://skillmd.com/u/yufeifeio)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/yufeifeio/tokenpay-gateway-pentest

---


# TokenPay / self-hosted crypto payment gateway pentest

Load when a merchant/shop flow hands off to a page titled `TokenPay支付中心` (open-source .NET gateway,
LightCountry/TokenPay) — domains like `tokenpay.<apex>` or a processor brand (`*.cardkeymax.com`-style).
The ecosystem pattern: faka shops sell digital goods, the gateway takes USDT/TRX and calls the shop back.
Win conditions: crack the merchant `ApiToken` (→ forge "Paid" callbacks → goods auto-deliver) or prove the
callback chain forgeable.

## 1. Discover & fingerprint

- Probe `tokenpay.<apex>` for every apex in scope. Wildcard CDNs answer every hostname — confirm by real
  content (`<title>…TokenPay支付中心`), never by status code alone.
- Fingerprint set: `GET /admin` → 404 = admin disabled (current default); `GET /Check/<random-guid>` →
  whatever default the build returns for unknown orders ("Pending"/"Expired" — remember it, it becomes the
  shared-DB oracle below); `GET /Query?Id=<guid>&Signature=x` → `{"success":false,"message":"签名验证失败！"}`
  = signature enforced; `GET /error-development` may exist (500 ProblemDetails). Static `?v=` hashes identify
  builds — identical hashes across domains = same release.

## 2. Shared-DB detection across sibling instances

- Take a KNOWN order GUID from instance A and `GET /Check/<guid>` on instance B: a known order returns its
  REAL status while unknown GUIDs return the default — a real status proves the two share one database/backend.
  Consequences: one cracked `ApiToken` opens every sibling, and a ban on one domain leaves the others as live
  oracles.
- `GET /Pay?Id=<guid>` renders the order (address, exact amount, expiry) and its JS embeds the merchant
  callback/notify URL — harvest session state and callback routes (`/pay/<plugin>/notify`, `.../callback...`)
  from it. Pay windows are short (~15 min) — forge promptly or create a fresh order.

## 3. /Query signature oracle → `ApiToken` cracking

- Spec (gateway repo `Wiki/docs.md`): canonical = `Id=<lowercase-hyphenated-guid>`;
  `Signature = md5(canonical + ApiToken)` by default, `HMAC-SHA256(key=ApiToken, msg=canonical)` when the
  build sets `Signature:UseHmacSha256=true`. Older builds may use the bare guid as canonical — test both.
  Modes to sweep: md5ck, md5kc, hmac, guid-md5, guid-hmac over brand words + operator identities +
  `brand@year` + 10k-most-common + rockyou.
- **Detection rule: parse the JSON and treat `message == '签名验证失败！'` as failure; ANY other response
  (success JSON or `订单不存在！`) is a hit. Chinese messages arrive unicode-escaped (`\u7B7E…`), so raw
  substring matching for the Chinese string false-positives a failure as a hit — parse, never substring.**
- **Pace: ~5 req/s (2 threads, 0.2–0.4 s jitter) survives tens of thousands of requests; sustained 15–20+/s
  gets the IP banned after a few tens of thousands (a banned host then answers empty/000 — indistinguishable
  from "down" unless you remember you were cracking). If banned, switch to a sibling instance: shared DB
  means the same key still works there.**
- Ready-to-run harness: `scripts/tokenpay_oracle_crack.py` (argv: base-url, guid, wordlist, mode).

## 4. Notify forgery (merchant side)

Goal: forge the gateway→shop "Paid" callback so the shop marks your order paid and auto-delivers.

1. Clone the gateway repo: `Wiki/docs.md` (signing spec) plus `Plugs/card-system|dujiaoka|epay-pro`
   (reference PHP verifiers to copy the canonicalization from). Canonical = all received fields except
   `Signature`, byte-sorted (`ksort SORT_STRING`), skip null/'', joined `k=v&`, NO url-encoding; bools
   lowercase; amounts kept as the exact strings sent.
2. Find the shop-side notify route (from the pay page, §2) — e.g. `/pay/token_pay/notify`. It reads the raw
   JSON body (`php://input`); form-encoded fails, JSON only.
3. Calibrate with junk: missing `Signature` → `Invalid data`; present-but-wrong → `Signature verification
   failed`; success → `ok`.
4. Body = the official dic: `Id, OutOrderId, OrderUserKey, PayTime, Amount (chain), ActualAmount (fiat),
   Currency, ToAddress, Status:1 (int), BaseCurrency, BlockChainName, CurrencyName, PayAmount,
   IsDynamicAmount, IsCustomAmount, SignatureType`.
5. Create a REAL fresh order first (short expiry windows); the order supplies `Id` (payId) and `OutOrderId`
   (trade_no) for the forged body.
6. Sign `md5(canonical + key)` (default) and the hmac variant; single-shot each. On `ok`, confirm delivery
   via the shop's own oracle (order page / status endpoint / delivery mail).

## Pitfalls

- Unicode-escaped JSON (see §3) — the single costliest trap in this whole chain.
- Never sustain >10 req/s against a gateway host; bans outlive the session and reading a ban as "route dead"
  wastes the campaign.
- `Amount` (chain, e.g. USDT) vs `ActualAmount` (fiat) semantics are swapped in some integrations — mirror
  the pay page (chain vs fiat) when constructing forged bodies, and keep body values identical to canonical.
- Merchant `/admin` is disabled by default on current builds (404) with PasswordHasher auth + 5/10 min
  limit — don't grind it; this skill's path is the signature oracle and the shop callback.
- When the shop's endpoints stop answering curl (CF challenge / 520 flaps) while a real browser session still
  loads them, run the critical POSTs (order create, notify) as browser page-context fetch instead.

