0x1843 完整發送鏈逐條指令核對mov $0x1843,%esi 在整個 libQotBase.so(10,593,976 B)只有一個命中,byte 偏移 0x3f1f02。mov $0x1,%edi 直接餵 SendCommand(CSChannelType, ...)。SerializeToString 在 0x3f1ee1 就已經跑完,之後才組 CSProtoData。即你 hook SendCommand 時 payload 已經係 ready bytes,不需自己 parse 再 re-serialize。DoSendSubReq 逐段拆解(0x3f16f0 – 0x3f2072)0x3f16f0 _ZN17NNBiz_Qot_PushQot12DoSendSubReqERKSt3setI12NN_CSMktType...b
push rbp/r15/r14/r13/r12/rbx ; sub $0x198,%rsp ← 408 B frame
0x3f1707 mov 0x7a8008(%rip),%r12 ← CQuoteAuthDataManager singleton guard
0x3f1733 call CQuoteAuthDataManager::GetIsQuoteAuthValid()
0x3f1740 je 0x3f2398 ← ★ 未授權 → 直接跳去寫 log 並 return
(0x3f2398 組 fmt 字串 0x23=35 字節錯誤訊息)
0x3f1828 call operator new(0x28) ← 每個 mkt type 建 node
0x3f1e70 addq $0x1,0x270(%rax) ← 累加 counter(+0x270 offset)
0x3f1ee1 call google::protobuf::MessageLite::SerializeToString(std::string*)
← ★ Req 在此序列化成 bytes
0x3f1f02 mov $0x1843,%esi ← ★★ COMMAND ID = 6211
0x3f1f23 mov %si,-0x110(%rbp) ← 存入 CSProtoData 的 cmd 欄位(16-bit 寫入!)
0x3f1f5a movzbl 0x0(%r13),%eax ← 取序列化結果第 0 字節
0x3f1f6c mov %r12,-0xa8(%rbp) ← std::string length
0x3f1f86 lea -0x108(%rbp),%rax ← std::string (payload) 地址
0x3f1fa1 call std::string::operator=(std::string&&) ← 搬入 CSProtoData
0x3f1fb8 mov $0x2710,%ecx ← 0x2710 = 10000
0x3f1fd9 mov %cx,-0xb0(%rbp) ← ★ 某 16-bit 欄位 = 10000(見下方分析)
0x3f201c movq $0x2,-0x128(%rbp) ← 一個 2
0x3f2042 mov %r13,%rcx ← arg4 = std::function callback
0x3f2045 mov %r12,%rdx ← arg3 = CSRequestExt* (nullptr)
0x3f2048 mov %r15,%rsi ← arg2 = &CSProtoData
0x3f204b mov $0x1,%edi ← ★★ CHANNEL = 1
0x3f206d call IFTChannelProxy::SendCommand(CSChannelType, const CSProtoData&,
const CSRequestExt*, std::function<...>, QObject*)
0x3f2072 mov %rax,%r14 ← 回傳 request id
0x3f2080 test %r14,%r14 ; je 0x3f2095
0x3f2082 movabs $0x300000000,%rax
0x3f208c or %rax,%rcx ← ★ 錯誤碼包裝:高位塞 3
0x3f20e8 call CQotSubBitMgr::GetMapQotSubByMkt(NN_CSMktType)
以上為 objdump -d --no-show-raw-insn 原文,可按偏移自行核對。
0x3f1f02 mov $0x1843,%esi ; esi = 32-bit 常數 0x3f1f23 mov %si,-0x110(%rbp) ; 但只搬低 16 bit 入結構
含意:如果你打算自己砌封包,cmd 欄位是 uint16。用 32-bit 寫入會踩到相鄰欄位。
另 0x3f1fad 附近 mov $0x2710,%ecx + mov %cx,-0xb0(%rbp) 同樣是 16-bit 寫入
(0x2710 = 10000,不是 sub bit 0x2711)——兩者相差 1,極易混淆。
0x2711,在另一條路徑0x3ed890 _ZN17NNBiz_Qot_PushQot9PushKlineERKN18FTCmdStockQuoteSub9QuotePushE
0x3ed9c2 cmp $0x29,%edx ; 0x29 = 41
0x3ed9cb cmp $0x2711,%edx ; 0x2711 = 10001 ← ★ K 線 sub bit
0x3ed9d1 je 0x3ed95e ; → 走 Kline 分支
0x3ed96f call INNProtoCenter::OnPushKline(uint64, optional<CSBrokerId>,
NN_SubscribeBit, const std::string&)
0x3ed9d8 movabs $0x100100000,%rsi
0x3ed9e5 je 0x3ed98b ; 否則測 bit
0x3ed9f8 call INNProtoCenter::OnPushTimeShare(uint64, optional<CSBrokerId>,
NN_SubscribeBit, const std::string&)
含意:0x1843(訂閱請求)與 0x2711(K 線 sub bit)唔在同一函數。
0x2711 出現在 PushKline(接收側分派),而 0x1843 在 DoSendSubReq(發送側)。
所以「改 0x2711 就會改訂閱」係錯的——你要改的是 DoSendSubReq 內 NNBiz_Qot_PushQot 的 +0x2e0 集合內容。
另 CQotSubBitMgr::IsSubBitHasProb2(0x2711) 在 0x406c80 只有一句 cmp/sete,
說明 0x2711 是唯一有 prob2 的 sub bit——即 K 線訂閱需要額外 prob 參數。
0x3d09a0 _ZN18INNBiz_Qot_PushQot16RegisterCallBackEv 0x3d09ab mov $0x1843,%edi 0x3d09b0 call INNProtoCenter::RegisterCallBack_OnReply(uint32, fn(uint32,uint32,NN_ProtoRet,const char*,uint64)) 0x3d09bc mov $0x1844,%edi ; ★ 0x1844 = 6212(回覆) 0x3d09c1 call INNProtoCenter::RegisterCallBack_OnPush(uint32, fn(uint32,const char*,uint64)) 0x3d09cd mov $0x18a0,%edi ; ★ 0x18a0 = 6304(ResubNotify) 0x3d09d6 jmp INNProtoCenter::RegisterCallBack_OnPush
含意:三個 ID 一次過註冊:0x1843 OnReply、0x1844 OnPush、0x18a0 OnPush。
若要驗「訂閱成功」,最直接是看 0x1844 回呼有無被觸發——比看 K 線推送更早、更準。
| 目標 | library | 符號 / 偏移 | 用途 |
|---|---|---|---|
| 攔發送 | libQotBase.so | IFTChannelProxy::SendCommand PLT 0x222210(呼叫點 0x3f206d) | 拿 cmd + payload bytes |
| 改 cmd | libQotBase.so | file offset 0x3f1f02,bytes be 43 18 00 00 | 唯一構造點,patch 後可改任何 cmd |
| 看回覆 | libQotBase.so | INNProtoCenter::RegisterCallBack_OnReply 已註冊 0x1843 | 最快確認 server 有無收貨 |
三個 offset 均在本次下載的 libQotBase.so(sha 8fba518f…)逐 byte 核對過。
換版本必定移位,不可跨版本沿用。
0x13 與 0x29)0x3ed910 cmp $0x13,%edx ; 0x13 = 19 0x3ed92c je 0x3ed9d8 ; → 走 timeshare 那組 bit 測試 0x3ed9c2 cmp $0x29,%edx ; 0x29 = 41 0x3ed9cb cmp $0x2711,%edx ; 10001 → K 線
即 PushKline 會按 quote.bit 值分三類:19、41、10001。
配合 SubscribeBit 枚舉(我在 A25_QOTBASE_QUOTE_SCHEMA.html 已列全 0–42 + 10001):
19 對應 SBIT_USOPT_LV2_ORDER、41 對應 SBIT_KLINE_180MINUTE、
10001 對應 SBIT_CUSTOM_KLINE。BTC 1m 屬於自訂週期 → 應走 10001。
| QuotePush | ||
| #1 | security_qta_list | repeated SecurityQuote |
| SecurityQuote | ||
| #1 | security_id | uint64 |
| #2 | bit_qta_list | repeated BitQuote |
| #3 | broker_id | int32 |
| BitQuote | ||
| #1 | bit | uint32 |
| #2 | data | bytes |
| #3 | prob | int64 |
| TickItem | ||
| #1 | tick_key | uint64 |
| #2 | type | int32 |
| #3 | exchange_data_time_ms | uint64 |
| #4 | price | int64 |
| #5 | volume | uint64 |
| #6 | trade_type | string |
| #7 | server_recv_from_exchange_time_ms | int64 |
| #8 | price_last_close | int64 |
| #9 | ticker_type | uint32 |
| #10 | exchange_name | string |
| #11 | ticker_flag | uint32 |
| #12 | cond_code | string |
| #13 | strategy | uint32 |
| #14 | order_type | uint64 |
| #16 | turnover | int64 |
| #22 | hp_volume | string |
| #23 | hp_turnover | string |
#6 trade_type 是 string、#11 ticker_flag 是 uint32——
若你要判斷主動買/主動賣,這兩個是協議層唯一線索;但 schema 沒有說明取值含義,我未證實任何一個值代表 BUY/SELL。
CRpcHead(srpc.proto, libCorePB) | ||
| #1 | origin_uid | uint64 |
| #2 | target_uid | uint64 |
| #3 | staff_name | string |
| #4 | session_id | uint64 |
| #5 | service_id | uint32 |
| #6 | method_id | uint32 |
| #7 | sequence | uint64 |
| #8 | client_ipv4 | uint32 |
| #9 | client_port | uint32 |
| #10 | client_type | uint32 |
| #11 | client_version | uint32 |
| #12 | client_lang | uint32 |
| #13 | client_seq | uint32 |
| #14 | result | int32 |
| #15 | result_msg | string |
| #16 | method_name | string |
| #17 | signature | CSignKey |
| #18 | device_id | string |
| #19 | prot_ver | uint32 |
| #20 | server_ip | uint32 |
| #21 | customized_data | bytes |
| #22 | user_agent | WebView |
| #23 | gray_flag | uint32 |
| #24 | trace_id | bytes |
| #25 | parent_id | bytes |
| #26 | span_id | bytes |
| #27 | sampled | bool |
| #28 | debug | bool |
| #29 | request_timestamp | uint64 |
關鍵欄位:#5 service_id、#6 method_id、#7 sequence、#17 signature(CSignKey)。
signature 存在 = 自行砌封包會被 server 拒;這就是為何建議 hook 既有 SendCommand 而不要自建 client。
| library | bytes | sha256 | 角色 |
|---|---|---|---|
libQotBase.so | 10,593,976 | 8fba518f8824ce39… | libQotBase.so |
libCorePB.so | 8,105,288 | 741fa92f3630d8d7… | libCorePB.so |
libCore.so | 7,189,656 | a90954c92ff519c2… | libCore.so |
CSProtoData 的 C++ 佈局:-0x110/-0xb0/-0xa8 三個 offset 是我由指令推的,未經 debugger 確認。0x2710(10000)語義:只知是 16-bit 常數,可能是 timeout、count 或 flags,我唔知。0x13/0x29/0x2711 的分派邏輯是否完整:我只見三個 cmp,可能有更多分支未列出。SBIT_CUSTOM_KLINE 名稱推的推測,非觀察。trade_type 取值表:schema 無 enum,字串常量亦未在庫內找到對照。