Files
OpenFUT/fifa17-recon/tools/ghidra_queries/q_hub_3.py
T
funman300 89da7b7609 fifa17-recon: /hub refutes yesterday's envelope conclusion, and two ENDPOINT_MAP freezes
Three things: the envelope rule was wrong and is corrected, /hub is settled, and two
documented response shapes that would freeze the client are fixed.

THE CORRECTION. The previous commit concluded that a three-token root consumes `{`, the
first field name and that field's value without dispatching them, so the first key of a
flat body was silently eaten, and that `login` had therefore never been delivered on
POST /user. That is WRONG and is withdrawn, along with the claim that the key order of
the auth dict is load-bearing.

The first call to FUN_1801c7f10 returns token 7 and consumes NO input. It is a
once-only start-of-document token, guarded by the flag at parser+0xda together with the
zero character counter at parser+0x30. So the three tokens are BOF, `{`, and the FIRST
FIELD NAME, and the key loop dispatches from that first key onward. The `== 10` test on
the third token is not an envelope check, it is the empty-object early-out: for `{}` the
third token is END_OBJECT and the root exits with its constructor defaults intact, which
is why answering `{}` has always been safe.

Corrected enum: 7=BOF 9=START_OBJECT 10=END_OBJECT 11=FIELD_NAME 12=START_ARRAY
13=END_ARRAY. The enum itself was right before; the inference from it was not.

HOW IT WAS CAUGHT, which is the part worth keeping. Not by more decompiling. /hub is
served flat and the wrong model predicted its first key would be discarded, so the
prediction was checked against the client's own memory: clubPlayers read back as 205,
the value the server sent, at model+0x1fd70+0x3c with the slide proven against the FNV
prologue first. One live read refuted a chain of otherwise sound static reasoning in
about a minute. tools/hub_counter_probe.py keeps it repeatable.

Consequence worth flagging: a wrapper is not just unnecessary for these roots, it would
be harmful, since a wrapper key hashes to an atom with no arm and the whole object is
skipped. That makes the createPackResponse envelope DOUBTFUL rather than confirmed.
Atom 0xbe has no arm in FUN_180162880. There is no live evidence either way because
nothing has ever parsed that body, so the buy path is left exactly as it is.

TWO ERRORS OF MINE ON THE WAY, both recorded in the doc because both are cheap to
repeat. I searched for RS4:FutGetHubServerResponse, found nothing and reported that no
hub class existed; the class is FutGetHubDataServerResponse (literal 0x18022ce40,
vtable 0x18022cd48, deser 0x1801738b0, control FutSquadSave -> 0x180171a60 matched in
the same run). Then I scanned 152 deserializers for clubPlayers, got zero hits and a
passing control, because the guard is `!= 0x90` and my pattern only matched `== 0x`.
The control passed only because auctionCount happens to use `==`. A control that does
not exercise the same code shape as the target is not a control. The comment already at
utas_server.py:1076 had the hub chain right the whole time.

ENDPOINT_MAP corrections, both freeze-risky as written, neither affecting what we serve
today:
  * duplicateItemIdList is an ARRAY OF OBJECTS (element deser 0x180138e10), not the int
    list at :1095. Bare ints where the element parser expects objects is a tokenizer
    desync, i.e. a hard freeze at 0x1801c7f1a. Control that this is not a misread:
    dreamSquads 0xe9 in FutMoveCard genuinely is a bare int array.
  * FutDiscardCardServerResponse is {"items":[{"id":N}],"totalCredits":N}. There is no
    top-level id.

No behaviour change. utas_server.py is comment-only. 439 contract checks pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 19:35:27 -07:00

103 lines
4.3 KiB
Python

"""What does the hub body actually contain? Read the sub-parser the hub root delegates to.
CHAIN ESTABLISHED SO FAR:
FutGetHubDataServerResponse literal 0x18022ce40 -> vtable 0x18022cd48 -> deser
0x1801738b0 (control FutSquadSave -> 0x180171a60 MATCHED in the same run).
0x1801738b0 spends TWO tokenizer calls and then tail-delegates to FUN_180139610.
That is the /purchased shape: root spends 2, the sub-parser spends the 3rd and owns
the key loop.
We answer GET /hub with a FLAT two-key body {"clubPlayers":205,"auctionCount":0}.
q_hub_1 scanned 152 deserializers for a direct comparison against clubPlayers (0x90)
and found ZERO, with a passing control. auctionCount (0x33) got 7 hits, one of which
is FUN_180139610 itself.
WHY THAT IS NOT YET AN ANSWER. A source grep for `== 0x90` cannot see running-sum
sub/dec ladder dispatch, which is common in this binary, so zero hits is suggestive and
not conclusive. Read the ladder instead of grepping it.
QUESTIONS
Q1 print FUN_180139610 IN FULL and enumerate every atom its ladder handles, including
any expressed as a running-sum sub/dec chain rather than an equality test
Q2 is clubPlayers 0x90 among them, in ANY dispatch form
Q3 does it consume a token before its loop (making the total 3, and therefore eating
the first key/value pair of a flat body) or does it start looping immediately
Q4 FUN_1801c8210(parser, 3, 1) is called by the hub root and not by the other roots
read so far. Find out what it configures, since it may change the token semantics
CONTROL: FUN_180139610 must show auctionCount 0x33 somewhere, since the q_hub_1 grep
already found it there. If the atom enumeration below cannot see 0x33, the enumeration
is broken and its verdict on 0x90 is void.
"""
import traceback
SUB = 0x180139610
CFG = 0x1801C8210
A_CLUB = 0x90
A_AUCTION = 0x33
try:
for va, title in ((SUB, "hub body sub-parser"), (CFG, "parser config called by the hub root")):
f = func(va)
src = dec(va)
print("=" * 78)
print("%#x %s body %d bytes / decompile %d chars (IN FULL)"
% (va, title, f.getBody().getNumAddresses() if f else -1, len(src)))
print("=" * 78)
print(src)
print()
# Enumerate atoms mechanically from the instruction stream, which unlike a source
# grep also catches sub/dec ladder steps.
print("=" * 78)
print("ATOMS REACHABLE IN %#x, read from the instruction stream" % SUB)
print("=" * 78)
f = func(SUB)
imms, runsum = [], 0
for ad in f.getBody().getAddresses(True):
ins = listing.getInstructionAt(ad)
if ins is None:
continue
m = ins.getMnemonicString().lower()
txt = str(ins)
if m in ("cmp", "sub", "dec", "add", "mov"):
for i in range(ins.getNumOperands()):
for o in ins.getOpObjects(i):
try:
v = int(o.getValue())
except Exception:
continue
if 0 < v <= 0x400:
imms.append((int(ad.getOffset()), m, v, txt))
print(" %d candidate immediates in range 1..0x400" % len(imms))
# running-sum reconstruction: consecutive sub/dec on the same register accumulate
acc = 0
print("\n addr mnem imm running-sum disasm")
for a, m, v, txt in imms:
if m in ("sub", "dec"):
acc += v
print(" %#010x %-4s %#-6x %#-11x %s" % (a, m, v, acc, txt))
else:
print(" %#010x %-4s %#-6x %-11s %s" % (a, m, v, "", txt))
seen = {v for _, m, v, _ in imms}
sums = set()
acc = 0
for _, m, v, _ in imms:
if m in ("sub", "dec"):
acc += v
sums.add(acc)
print("\n distinct raw immediates : %s" % " ".join("%#x" % v for v in sorted(seen)))
print(" distinct running sums : %s" % " ".join("%#x" % v for v in sorted(sums)))
print("\n CONTROL auctionCount %#x present? %s"
% (A_AUCTION, "YES" if (A_AUCTION in seen or A_AUCTION in sums) else "NO -- enumeration broken, verdict void"))
print(" clubPlayers %#x present? %s"
% (A_CLUB, "YES" if (A_CLUB in seen or A_CLUB in sums) else "NO"))
print("\n callees of %#x:" % SUB)
for a, n in callees(SUB):
print(" %#x %s" % (a, n))
except Exception:
traceback.print_exc()