1
0
Fork 0
mirror of synced 2026-12-06 18:42:25 +00:00
No description
Find a file
2026-11-22 12:03:12 -05:00
.github Extend the shared settings from regulad/.github 2026-11-22 12:03:12 -05:00
README.md Add --session to reuse an existing session_id 2026-11-05 16:15:58 -05:00
wq_coupon.py Add --session to reuse an existing session_id 2026-11-05 16:15:58 -05:00

wendyQuestCracker

Reverse-engineering notes on how Wendy Quest (Steam app 3339970), Wendy's promotional RPG, hands out restaurant coupon codes, plus a Python reimplementation of its coupon client.

Written by Claude Opus 5.5 (Anthropic), working in Claude Code: the analysis, this README and the original offline wq_coupon.py. The script's live-dispatch mode was added later with Qwen-Coder.

TL;DR

  • Coupon codes are not generated client-side. There is no code algorithm in the game. Codes come from GET https://wqserver.81monkeys.com/fresh-quest-coupons-prod/api/coupons/retrieve.
  • The check that you earned a coupon is entirely client-side. The server receives only an anonymous, server-issued session ID and a stone number (type=1..5), nothing tied to gameplay.
  • Session IDs are not generated client-side either. The client calls GET app/session and stores whatever session_id comes back.
  • The obfuscation is light. There's a blanket javascript-obfuscator pass on every plugin, and the coupon module's names were also shortened to single letters. On top of that, the API URL is base64-encoded and the auth header is just an MD5 of the current minute plus a hardcoded salt.

Target

Engine RPG Maker MZ on NW.js, so all game logic is JavaScript under package.nw/ and no native code is involved (Ghidra was not needed)
Coupon client js/plugins/WendyQuest.js, the WendyQuest.t object
Coupon UI js/plugins/MenuScene.js: Scene_Coupons, Window_CouponList, Window_CouponResponse, Scene_File.createCouponButton
Save/stone bookkeeping js/plugins/MonkeyWrenchMZ.js: DataManager.makeSavefileInfo, DataManager.getGlobalStoneInfo, Utils.getCountryCode

Analyzed build (install dated 2026-11-05):

7bada2c22cdecfcaa6324fc815496cfece36f7549565b9dcc42dcc2c928bf70e  js/plugins/WendyQuest.js
e8c0b49d396d40911d774e63b3bf5bab3dc270eaeae57192d203a82273550009  js/plugins/MenuScene.js
31b9c99912471db9da1bccd91be6b7572c2e52e018af710362163fc7ec74916b  js/plugins/MonkeyWrenchMZ.js

Method

The plugins were copied out of the install and deobfuscated with webcrack 2.16.0 (deobfuscate: true, unminify: true, mangle: false). Instead of webcrack's default isolated-vm sandbox, a node:vm sandbox was supplied; webcrack only uses it to evaluate the obfuscator's string-array decoder. The game install itself was never modified. Code below is quoted from the deobfuscated output.

The coupon flow

The API base is stored base64-encoded in t.m() and decoded with atob() at every call site:

aHR0cHM6Ly93cXNlcnZlci44MW1vbmtleXMuY29tL2ZyZXNoLXF1ZXN0LWNvdXBvbnMtcHJvZC9hcGkv
  -> https://wqserver.81monkeys.com/fresh-quest-coupons-prod/api/

81 Monkeys is the developer. The client makes three GET requests:

# Client fn Request Response used
1 t.A() app/session session_id, persisted to global save data
2 t._() app/init?session_id=… promotion_status ("1" active, "2" coupons unavailable, "3" promotion ended) and ui_texts for the popups
3 t.F(i) coupons/retrieve?session_id=…&type=i+1 { "result": "successful", "coupon_code": "…" }

On success the code is cached in global save data (couponCodes[i]) and shown with a "copy" button and a deep link to the Wendy's app (https://m-wendys.app.link/9B57RO3lj2b).

Request "authentication"

Every request carries one header:

var stamp = new Date().toISOString().replace(/\D/g, "").slice(0, 12);  // UTC YYYYMMDDHHMM
headers.append("X-Pmmf-Ac", md5(stamp + "e67Y2i"));

That is a hardcoded salt plus the current minute, so anyone who reads the client can compute it. The NW.js (Steam) transport t.P() also sends Keep-Alive: 300 and Connection: keep-alive; the Capacitor/mobile transport t.k() sends only X-Pmmf-Ac. md5 is stock js-md5 0.8.0 from js/libs/md5.min.js.

Where the checks live

Check Where Notes
You earned the stone Client only The five stones are items 31–35 (Fry, Frosty, Spicy, Breakfast, Beef). makeSavefileInfo copies them into each save slot's stones[]; getGlobalStoneInfo ORs them across the three slots. The Rewards button (Scene_File.createCouponButton) only appears if you hold at least one stone, and Window_CouponList.selectCoupon only proceeds for stones you hold. Only the stone number reaches the server.
US only Client, possibly server too t.l() requires Utils.getCountryCode() (Steam's greenworks.getIPCountry() on desktop) to be US/USA. The error popup asks players to "turn off any VPNs", which hints at a server-side IP check as well.
Promotion is running Server promotion_status from app/init.
One code per stone Client cache; server unknown t.F() returns the cached code if one exists. Whether the server limits codes per session or per IP isn't visible from the client.

The server can't tell whether a caller ever finished the game, and a new session costs one anonymous request. Any abuse resistance must therefore live on the server, in the form of a limited code pool, rate limits, IP checks and the promotion window. None of that was tested.

Session ID generation

There isn't any on the client. The whole of t.A() (obfuscator variable names shortened to r; the verbatim version is quoted in wq_coupon.py):

A: async function () {
  var r = atob(this.m()) + "app/session";
  var r = await this.U(r);
  return !!r && !!r.session_id && !(r = r.session_id, DataManager.setCustomGlobalData("session_id", r), 0);
},

That means: request a session, store the session_id the server returns, and return true or false. The only client-side random-ID code anywhere in package.nw is generateFid() in assets/web-Bb9l9miq.js. That is the stock Firebase Installations ID used for analytics, and it isn't sent to the coupon server.

Obfuscation

  • Blanket javascript-obfuscator pass. Every plugin went through it, including open-source third-party ones such as Community_Lighting_MZ.js, so this was a build step rather than something aimed at the coupons. It uses a light preset: a rotated string array with plaintext entries (no base64/RC4 string encoding), hex numeric literals and !0x1 booleans. There is no control-flow flattening, dead-code injection, self-defending code or debugger traps, and webcrack fully reverses it.
  • Coupon module renamed to single letters. WendyQuest.t is the only object in the deobfuscated code whose members are single letters (i h o u l g m M p S I v T R A _ C F U P k). Everything else keeps descriptive names such as WendyQuest.ShowRewardTokenAnimation. The short names appear as literal property keys rather than in the string array, so they were renamed before the obfuscator ran.
  • Base64 API URL, decoded with atob() at each call site.
  • The X-Pmmf-Ac header described above.
  • --disable-devtools in package.json's chromium-args.

None of these hide the session or coupon logic, because the client has none worth hiding. They mainly obscure where the server is and make the requests look harder to reproduce than they are.

wq_coupon.py

A reimplementation of the client's coupon module (Python 3.11+, stdlib only). By default it actually dispatches the three GETs the client would send, threading the server-minted session_id from app/session into app/init and coupons/retrieve, and prints whatever each endpoint returns:

python wq_coupon.py beef                # or 1-5, "Frosty Stone", spicy, ...
python wq_coupon.py 3 --at 2026-11-05T15:28Z   # header for a fixed time (naive = UTC)
python wq_coupon.py 1 --offline           # print the requests the client would send, no I/O
python wq_coupon.py 2 --session <id>      # reuse a session_id from an earlier run; skips app/session

Note: the X-Pmmf-Ac header rotates every minute and the server rejects stale stamps, so --at <historical time> against the live server will 401. That is the client's behavior, not a bug; use --offline or the current time to avoid it.

The script's header was checked against the game's own JS expression using the game's own md5.min.js for a fixed timestamp (2026-11-05T15:28:42Z):

202611051528 2b9001e369484b9d7db787cbd7a92b13   # node + package.nw/js/libs/md5.min.js
X-Pmmf-Ac  md5("202611051528e67Y2i") = 2b9001e369484b9d7db787cbd7a92b13   # wq_coupon.py