Files
WoW-Hybrid-gateway/tools/local_fixture_recovery.cpp
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

86 lines
5.5 KiB
C++

// Local test setup only, never evidence of Forever gameplay compatibility.
// Reuse legitimate SRP/world authentication and the server's existing GM
// authorization. No credentials, session keys or arbitrary commands exported.
#include "gateway/legacy_client.hpp"
#include "gateway/object_updates.hpp"
#include <algorithm>
#include <chrono>
#include <iostream>
using namespace gateway;
namespace {
std::optional<std::string> system_text(const LegacyPacket& packet){
if(packet.opcode==0x2e6)throw Error("unsupported integrity request");
if(packet.opcode!=0x96)return {};
Reader r(packet.body);if(r.le(1)!=10)return {};
r.le(4);r.le(8);auto n=r.le(4);if(!n || n>4096)throw Error("system message bound");
auto text=r.take(n);r.le(1);r.end();if(text.back()!=0)throw Error("system terminator");
return std::string(text.begin(),text.end()-1);
}
void command(LegacySession& session,const char* text){
Bytes body;le(body,0,4);le(body,0,4);cstring(body,text);session.send(0x95,body);
}
template<class F>void wait(LegacySession& session,unsigned seconds,F accept){
auto end=std::chrono::steady_clock::now()+std::chrono::seconds(seconds);
while(std::chrono::steady_clock::now()<end){auto p=session.receive_for(50);if(p){if(p->opcode==0x2e6)throw Error("unsupported integrity request");if(accept(*p))return;}}
throw Error("bounded fixture observation expired");
}
}
int main(int argc,char** argv){
if(argc!=4 || std::string(argv[3])!="--allow-archived-praxiscopy-4518-fixture" || (std::string(argv[2])!="revive" && std::string(argv[2])!="die")){std::cerr<<"Archived developer fixture disabled by default. Require --allow-archived-praxiscopy-4518-fixture plus the authorized private directory and revive/die action. This fixed4518 tool is not for current user characters; username travels on stdin.\n";return 2;}
const char* stage="private-input";
try{
std::string username;std::getline(std::cin,username);
if(username.empty() || username.size()>32)throw Error("private account input bound");
std::string directory=argv[1];
stage="legitimate-authentication";
LegacySession session(3724,8090,username,directory+"/password.txt",directory+"/version-hash.bin",directory+"/addon-tail.bin",5875);
stage="owned-roster";
if(std::none_of(session.roster().begin(),session.roster().end(),[](const auto& c){return c.guid==4509 && c.name=="Gatewaytest";}))throw Error("fixture actor not owned");
stage="world-initialization";session.login(4509);wait(session,15,[](const auto& p){return p.opcode==0x236;});
stage="server-gm-read-permission";
command(session,".gps");
// Source SendSysMessage splits the authoritative multiline GPS template.
bool map=false,position=false;
wait(session,5,[&](const auto& p){auto t=system_text(p);if(t){map|=t->find("Map:")!=std::string::npos;position|=t->find("X:")!=std::string::npos;}return map&&position;});
std::cout<<"SERVER_GM_READ_PERMISSION_VERIFIED\n"<<std::flush;
if(std::string(argv[2])=="revive"){
stage="server-revive-response";
command(session,".revive Praxiscopy");std::cout<<"REVIVE_REQUESTED_ONCE\n"<<std::flush;
wait(session,5,[](const auto& p){auto t=system_text(p);return t && t->find("Praxiscopy")!=std::string::npos && t->find("reviv")!=std::string::npos;});
std::cout<<"SERVER_REVIVE_REPLY\n"<<std::flush;
}else{
// Pinned MiscHandler reads raw selection GUID64. HandleDieCommand
// requires nonzero selection, checks rank/Hardcore and never
// falls back to self for an absent selected player. No synthetic
// death response: the actual native client must observe the result.
stage="server-controlled-death-request";
Bytes selected;le(selected,4518,8);session.send(0x13d,selected);
command(session,".die");std::cout<<"CONTROLLED_DEATH_REQUESTED_ONCE\n"<<std::flush;
}
stage="source-logout";
auto request_logout=[&](){
unsigned reason=4;session.send(0x4b,{});
wait(session,5,[&](const auto& p){if(p.opcode!=0x4c)return false;Reader r(p.body);reason=unsigned(r.le(4));auto instant=r.le(1);r.end();if(reason>3 || instant>1)throw Error("source logout shape");return true;});
return reason;
};
auto reason=request_logout();
if(reason==1){
// Pinned MiscHandler rejects combat logout without starting a
// countdown. Wait for this actor's genuine IN_COMBAT clear before
// ONE new request; no guessed sleep or blind request replay.
std::cout<<"FIXTURE_LOGOUT_REJECTED_COMBAT\n"<<std::flush;
wait(session,10,[](const auto& p){
if(p.opcode!=0xa9 && p.opcode!=0x1f6)return false;
for(const auto& u:turtle_object_updates(p.opcode,p.body))if(u.guid==4509){
auto f=u.fields.find(46);if(f!=u.fields.end() && !(f->second&0x80000))return true;
}
return false;
});
std::cout<<"SERVER_FIXTURE_COMBAT_CLEARED\n"<<std::flush;reason=request_logout();
}
if(reason)throw Error("server rejected fixture logout");
wait(session,30,[](const auto& p){return p.opcode==0x4d;});
std::cout<<"FIXTURE_LOGGED_OUT\n";return 0;
}catch(const std::exception&){std::cerr<<"Local recovery fixture stopped at "<<stage<<"; private authentication/server text omitted. Inspect target state before any retry.\n";return 1;}
}