diff options
-rw-r--r-- | src/tools/connection_patcher/Patches/Common.hpp | 17 | ||||
-rw-r--r-- | src/tools/connection_patcher/Patches/Mac.hpp | 5 | ||||
-rw-r--r-- | src/tools/connection_patcher/Patches/Windows.hpp | 10 | ||||
-rw-r--r-- | src/tools/connection_patcher/Patterns/Common.hpp | 3 | ||||
-rw-r--r-- | src/tools/connection_patcher/Patterns/Mac.hpp | 5 | ||||
-rw-r--r-- | src/tools/connection_patcher/Patterns/Windows.hpp | 10 | ||||
-rw-r--r-- | src/tools/connection_patcher/Program.cpp | 121 |
7 files changed, 55 insertions, 116 deletions
diff --git a/src/tools/connection_patcher/Patches/Common.hpp b/src/tools/connection_patcher/Patches/Common.hpp index 328c4671674..22e22beedcd 100644 --- a/src/tools/connection_patcher/Patches/Common.hpp +++ b/src/tools/connection_patcher/Patches/Common.hpp @@ -51,6 +51,23 @@ namespace Connection_Patcher }; } static const std::string VersionsFile() { return "trinity6.github.io/%s/%s/build/versi"; }; + static const std::vector<unsigned char> CertFileName() { return{ 't', 'c', '_', 'b', 'u', 'n', 'd', 'l', 'e', '.', 't', 'x', 't', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; } + static const std::string CertificateBundle() + { + return +R"({ + "Created": 1455065214, + "Certificates": [ + { "Uri": "*.*", "ShaHashPublicKeyInfo": "B1241D831999D4A67B0C6F9A687331C87FBA9B2CDC4CAC3694ADAD622F01952B" } + ], + "PublicKeys": [ + { "Uri": "*.*", "ShaHashPublicKeyInfo": "B1241D831999D4A67B0C6F9A687331C87FBA9B2CDC4CAC3694ADAD622F01952B" } + ], + "SigningCertificates": [ + { "RawData": "-----BEGIN CERTIFICATE-----MIIF5DCCA8ygAwIBAgIJAIgLslwk40XzMA0GCSqGSIb3DQEBCwUAMH8xCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtUcmluaXR5Q29yZTEqMCgGA1UECwwhVHJpbml0eUNvcmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MS4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HEc7rBOqHJEfNkzGv3MwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAFzCJkcDCPVMal+Thlip26LPkszZ4zWTsNsbUYmSe7h0kmMWt4x3mmZITfwb/eysYCnHThBVTjXj9VWBGfbECZ/xdyXC2ur+qp0Mm7xH2Wuswf7yfPC+USNO6+/tFS282FO/nM0quaKVknOC8ioCoASsBICB9lwRoYRKNBwRn3pkJplHepGahaJez4eedujO3dzxDdD32zy2/AfdeFXTxhWY8PTjMBKC2zpUQD7Kdvl+D8SfIsq73b8a9XmhdNX7qTc6MjecCD7WHAP2rrK7epjTaVJp4+PYlw7qfix/NT1fNkq2Mb2E77h2eToUG1mjs/mvG/4WfVCfMaBHOKaw6fyZULf366Jbx02r8K05P5ouvS1Z0De1mZJuUEUYhTRSs2POIdrmVrn9R83Y4l7TKNPJelq2uyEc4r+/fRrerIlT4HVlLPTC3SdW8ytYSUZXx+1NfJfQimieveIyIaTOV3SfC4EfeXtPtUpcVJvmFXqVbnXOO7bQU63bfFuuVSeU6OXWjoFRVkdHNYTGUGb5xg4hgWqlLWvWg0WPgLLabMbetrP6c5/Qhml/l07nJHeLoVxlFuwsL8HGeu0JWqnmwamp4/mmblRC9UfyrIQeDS8gsx8q/t2zdzT4bBph0nqYkZSyiIoQzlMrYdrWxeJm3sReR0G3FluL+03TGJypGfhr-----END CERTIFICATE-----" } + ] +};inserting_dummy_signature_inserting_dummy_signature_inserting_dummy_signature_inserting_dummy_signature_inserting_dummy_signature_inserting_dummy_signature_inserting_dummy_signature_inserting_dummy_signature_inserting_dummy_signature_inserting_dummy_signature)"; + } }; } } diff --git a/src/tools/connection_patcher/Patches/Mac.hpp b/src/tools/connection_patcher/Patches/Mac.hpp index 3a12533d449..8a5c25955ea 100644 --- a/src/tools/connection_patcher/Patches/Mac.hpp +++ b/src/tools/connection_patcher/Patches/Mac.hpp @@ -29,9 +29,8 @@ namespace Connection_Patcher { struct x64 { - static const std::vector<unsigned char> BNet () { return { 0xB8, 0xD5, 0xF8, 0x7F, 0x82, 0x89, 0x47, 0x0C, 0x5D, 0xC3, 0x90, 0x90, 0x90 }; } - static const std::vector<unsigned char> Password () { return { 0x0F, 0x85 }; } - static const std::vector<unsigned char> Signature() { return { 0x41, 0xBC, 0x02, 0x00, 0x00, 0x00, 0x41, 0xB6, 0x01, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; } + static const std::vector<unsigned char> CertBundleCASCLocalFile() { return{ 0x48, 0x8D, 0x55, 0xC4, 0x31, 0xDB, 0xB1, 0x01 }; } + static const std::vector<unsigned char> CertBundleSignatureCheck() { return{ 0x45, 0x84, 0xED, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; } }; }; } diff --git a/src/tools/connection_patcher/Patches/Windows.hpp b/src/tools/connection_patcher/Patches/Windows.hpp index ff053c8aef9..5a12edb1588 100644 --- a/src/tools/connection_patcher/Patches/Windows.hpp +++ b/src/tools/connection_patcher/Patches/Windows.hpp @@ -29,16 +29,14 @@ namespace Connection_Patcher { struct x86 { - static const std::vector<unsigned char> BNet () { return { 0xC7, 0x40, 0x0C, 0xD5, 0xF8, 0x7F, 0x82 }; } - static const std::vector<unsigned char> Password () { return { 0x75 }; } - static const std::vector<unsigned char> Signature() { return { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xEB }; } + static const std::vector<unsigned char> CertBundleCASCLocalFile() { return{ 0x6A, 0x01 }; } + static const std::vector<unsigned char> CertBundleSignatureCheck() { return{ 0x59, 0x59, 0x84, 0xC0, 0xEB }; } }; struct x64 { - static const std::vector<unsigned char> BNet () { return { 0xB8, 0xD5, 0xF8, 0x7F, 0x82, 0x89, 0x41, 0x0C, 0x48, 0x8B, 0xC1, 0xC3 }; } - static const std::vector<unsigned char> Password () { return { 0x75 }; } - static const std::vector<unsigned char> Signature() { return { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xE9 }; } + static const std::vector<unsigned char> CertBundleCASCLocalFile() { return{ 0x41, 0xB1, 0x01 }; } + static const std::vector<unsigned char> CertBundleSignatureCheck() { return{ 0xEB }; } }; }; } diff --git a/src/tools/connection_patcher/Patterns/Common.hpp b/src/tools/connection_patcher/Patterns/Common.hpp index 1c68b2f41ab..1eac4338936 100644 --- a/src/tools/connection_patcher/Patterns/Common.hpp +++ b/src/tools/connection_patcher/Patterns/Common.hpp @@ -27,10 +27,11 @@ namespace Connection_Patcher { struct Common { - static const std::vector<unsigned char> Portal() { return { '.', 'l', 'o', 'g', 'o', 'n', '.', 'b', 'a', 't', 't', 'l', 'e', '.', 'n', 'e', 't', 0x00 }; } + static const std::vector<unsigned char> Portal() { return { '.', 'a', 'c', 't', 'u', 'a' , 'l', '.', 'b', 'a', 't', 't', 'l', 'e', '.', 'n', 'e', 't', 0x00 }; } static const std::vector<unsigned char> Modulus() { return { 0x91, 0xD5, 0x9B, 0xB7, 0xD4, 0xE1, 0x83, 0xA5 }; } static const std::vector<unsigned char> BinaryVersion() { return{ 0x3C, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3E }; } static const std::vector<unsigned char> VersionsFile() { return { '%', 's', '.', 'p', 'a', 't', 'c', 'h', '.', 'b', 'a', 't', 't', 'l', 'e', '.', 'n', 'e', 't', ':', '1', '1', '1', '9', '/', '%', 's', '/', 'v', 'e', 'r', 's', 'i', 'o', 'n', 's' }; } + static const std::vector<unsigned char> CertFileName() { return { 'c', 'a', '_', 'b', 'u', 'n', 'd', 'l', 'e', '.', 't', 'x', 't', '.', 's', 'i', 'g', 'n', 'e', 'd', 0x00 }; } }; } } diff --git a/src/tools/connection_patcher/Patterns/Mac.hpp b/src/tools/connection_patcher/Patterns/Mac.hpp index 695981be37d..6c6f58cab32 100644 --- a/src/tools/connection_patcher/Patterns/Mac.hpp +++ b/src/tools/connection_patcher/Patterns/Mac.hpp @@ -29,9 +29,8 @@ namespace Connection_Patcher { struct x64 { - static const std::vector<unsigned char> BNet () { return { 0x8B, 0x06, 0x89, 0x47, 0x0C, 0x5D, 0xC3 }; } - static const std::vector<unsigned char> Password () { return { 0x0F, 0x84, 0x00, 0xFF, 0xFF, 0xFF, 0x49, 0x8B, 0x45, 0x00, 0xB9, 0x40 }; } - static const std::vector<unsigned char> Signature() { return { 0x45, 0x31, 0xF6, 0x31, 0xF6, 0x31, 0xD2, 0x48, 0x89, 0xDF, 0xE8, 0x00, 0x00, 0x00, 0x00, 0x41, 0xBC, 0x04, 0x00, 0x00, 0x00 }; } + static const std::vector<unsigned char> CertBundleCASCLocalFile() { return{ 0x48, 0x8D, 0x55, 0xC4, 0x31, 0xDB, 0x31, 0xC9 }; } + static const std::vector<unsigned char> CertBundleSignatureCheck() { return{ 0x45, 0x84, 0xED, 0x0F, 0x84, 0x00, 0x00, 0x00, 0x00, 0xE9 }; } }; }; } diff --git a/src/tools/connection_patcher/Patterns/Windows.hpp b/src/tools/connection_patcher/Patterns/Windows.hpp index fb724114a90..5b2de204a7b 100644 --- a/src/tools/connection_patcher/Patterns/Windows.hpp +++ b/src/tools/connection_patcher/Patterns/Windows.hpp @@ -29,16 +29,14 @@ namespace Connection_Patcher { struct x86 { - static const std::vector<unsigned char> BNet () { return { 0x8B, 0x75, 0x08, 0x8D, 0x78, 0x0C }; } - static const std::vector<unsigned char> Password () { return { 0x74, 0x89, 0x8B, 0x16, 0x8B, 0x42, 0x04 }; } - static const std::vector<unsigned char> Signature() { return { 0xE8, 0x00, 0x00, 0x00, 0x00, 0x84, 0xC0, 0x75, 0x5F, 0x33, 0xC0 }; } + static const std::vector<unsigned char> CertBundleCASCLocalFile() { return{ 0x6A, 0x00, 0x8D, 0x45, 0xFC, 0x50, 0x8D, 0x45, 0xF8, 0x50, 0x68 }; } + static const std::vector<unsigned char> CertBundleSignatureCheck() { return{ 0x59, 0x59, 0x84, 0xC0, 0x75, 0x08, 0x47, 0x83, 0xFF, 0x02 }; } }; struct x64 { - static const std::vector<unsigned char> BNet () { return { 0x8B, 0x02, 0x89, 0x41, 0x0C, 0x48, 0x8B, 0xC1, 0xC3 }; } - static const std::vector<unsigned char> Password () { return { 0x74, 0x84, 0x48, 0x8B, 0x03 }; } - static const std::vector<unsigned char> Signature() { return { 0xE8, 0x00, 0x00, 0x00, 0x00, 0x84, 0xC0, 0x0F, 0x85, 0x88, 0x00, 0x00, 0x00, 0x45, 0x33, 0xC0 }; } + static const std::vector<unsigned char> CertBundleCASCLocalFile() { return{ 0x45, 0x33, 0xC9, 0x48, 0x89, 0x45, 0x90 }; } + static const std::vector<unsigned char> CertBundleSignatureCheck() { return{ 0x75, 0x19, 0x48, 0xFF, 0xC3, 0x48, 0x83, 0xFB, 0x02 }; } }; }; } diff --git a/src/tools/connection_patcher/Program.cpp b/src/tools/connection_patcher/Program.cpp index 209815db60a..0f2a829d71b 100644 --- a/src/tools/connection_patcher/Program.cpp +++ b/src/tools/connection_patcher/Program.cpp @@ -45,77 +45,27 @@ namespace Connection_Patcher namespace { template<typename PATCH, typename PATTERN> - void PatchModule(boost::filesystem::path file, boost::filesystem::path path) - { - namespace fs = boost::filesystem; - - std::cout << "Patching module...\n"; - - Patcher patcher(file); - - std::cout << "patching Password\n"; - // if (Authentication::ServerSignature::ClientValidateProof(x)) to if (true) - patcher.Patch(PATCH::Password(), PATTERN::Password()); - - std::string const moduleName(Helper::GetFileChecksum(patcher.GetBinary()) + ".auth"); - fs::path const modulePath - (path / std::string(&moduleName[0], 2) / std::string(&moduleName[2], 2)); - - if (!fs::exists(modulePath)) - fs::create_directories(modulePath); - - if (fs::exists(modulePath / moduleName)) - fs::permissions(modulePath / moduleName, fs::add_perms | fs::others_write | fs::group_write | fs::owner_write); - patcher.Finish(modulePath / moduleName); - fs::permissions(modulePath / moduleName, fs::remove_perms | fs::others_write | fs::group_write | fs::owner_write); - - std::cout << "Patching module finished.\n"; - } - - template<typename PATCH, typename PATTERN> - void do_module(const std::string& moduleName, const boost::filesystem::path& path) - { - boost::filesystem::path const modulePath - (path / std::string(&moduleName[0], 2) / std::string(&moduleName[2], 2)); - boost::filesystem::path const module(modulePath / moduleName); - - if (!boost::filesystem::exists(module)) - { - std::cout << "Base module doesn't exist, downloading it...\n"; - - if (!boost::filesystem::exists(modulePath)) - boost::filesystem::create_directories(modulePath); - - std::ofstream outFile(module.string(), std::ofstream::out | std::ofstream::binary); - Helper::DownloadFile("xx.depot.battle.net", 1119, "/" + moduleName, outFile); - outFile.close(); - std::cout << "Done.\n"; - } - - PatchModule<PATCH, PATTERN>(module, path); - } - - template<typename PATCH, typename PATTERN> void do_patches(Patcher* patcher, boost::filesystem::path output, uint32_t buildNumber) { std::cout << "patching Portal\n"; - // '.logon.battle.net' -> '' to allow for set portal 'host' + // '.actual.battle.net' -> '' to allow for set portal 'host' patcher->Patch(Patches::Common::Portal(), Patterns::Common::Portal()); std::cout << "patching redirect RSA Modulus\n"; // public component of connection signing key to use known key pair patcher->Patch(Patches::Common::Modulus(), Patterns::Common::Modulus()); - std::cout << "patching BNet\n"; - // hardcode 213.248.127.130 in IP6::Address::Address(IP4::Address::Address const&) - // used in Creep::Layer::Authentication::Online(), which overwrites GameStream::Connection::GetAddressRemote() - // to avoid CRYPT_SERVER_ADDRESS_IPV6 check in module - patcher->Patch(PATCH::BNet(), PATTERN::BNet()); + std::cout << "patching BNet certificate file location\n"; + // replace name of the file with certificates + patcher->Patch(Patches::Common::CertFileName(), Patterns::Common::CertFileName()); + + std::cout << "patching BNet certificate file to load from local path instead of CASC\n"; + // force loading tc_bundle.txt from local directory instead of CASC + patcher->Patch(PATCH::CertBundleCASCLocalFile(), PATTERN::CertBundleCASCLocalFile()); - std::cout << "patching Signature\n"; - // if (Authentication::ModuleSignature::Validator::IsValid(x)) to if (true) in - // Creep::Instance::LoadModule() to allow for unsigned auth module - patcher->Patch(PATCH::Signature(), PATTERN::Signature()); + std::cout << "patching BNet certificate file signature check\n"; + // remove signature check from certificate bundle + patcher->Patch(PATCH::CertBundleSignatureCheck(), PATTERN::CertBundleSignatureCheck()); std::cout << "patching Versions\n"; // sever the connection to blizzard's versions file to stop it from updating and replace with custom version @@ -132,6 +82,15 @@ namespace Connection_Patcher std::cout << "Patching done.\n"; } + + void WriteCertificateBundle(boost::filesystem::path const& dest) + { + std::ofstream ofs(dest.string(), std::ofstream::binary); + if (!ofs) + throw std::runtime_error("could not open " + dest.string()); + + ofs << std::noskipws << Patches::Common::CertificateBundle(); + } } po::variables_map GetConsoleArguments(int argc, char** argv) @@ -140,7 +99,6 @@ namespace Connection_Patcher all.add_options() ("help,h", "print usage message") ("path", po::value<std::string>()->required(), "Path to the Wow.exe") - ("modulePath,m", po::value<std::string>(), "Path to the Battle.net module download destination.") ; po::positional_options_description pos; @@ -184,22 +142,6 @@ int main(int argc, char** argv) std::string const binary_path(std::move(vm["path"].as<std::string>())); std::string renamed_binary_path(binary_path); - std::wstring appDataPath; - -#if PLATFORM == PLATFORM_WINDOWS - wchar_t* tempPath(nullptr); - SHGetKnownFolderPath(FOLDERID_ProgramData, 0, NULL, &tempPath); - appDataPath = std::wstring(tempPath); -#elif PLATFORM == PLATFORM_UNIX - char* tempPath(nullptr); - if ((tempPath = getenv("HOME")) == nullptr) - tempPath = getpwuid(getuid())->pw_dir; - std::string tempPathStr(tempPath); - appDataPath.assign(tempPathStr.begin(), tempPathStr.end()); - appDataPath += std::wstring(L"/.wine/drive_c/users/Public/Application Data"); -#endif - if (vm.count("modulePath")) - appDataPath.assign(vm["modulePath"].as<std::string>().begin(), vm["modulePath"].as<std::string>().end()); std::cout << "Creating patched binary..." << std::endl; @@ -222,12 +164,7 @@ int main(int argc, char** argv) boost::algorithm::replace_all(renamed_binary_path, ".exe", "_Patched.exe"); do_patches<Patches::Windows::x86, Patterns::Windows::x86> (&patcher, renamed_binary_path, wowBuild); - - do_module<Patches::Windows::x86, Patterns::Windows::x86> - ( "8f52906a2c85b416a595702251570f96d3522f39237603115f2f1ab24962043c.auth" - , std::wstring(appDataPath) + std::wstring(L"/Blizzard Entertainment/Battle.net/Cache/") - ); - + WriteCertificateBundle(boost::filesystem::path(binary_path).remove_filename() / "tc_bundle.txt"); break; case Constants::BinaryTypes::Pe64: std::cout << "Win64 client...\n"; @@ -235,17 +172,12 @@ int main(int argc, char** argv) boost::algorithm::replace_all(renamed_binary_path, ".exe", "_Patched.exe"); do_patches<Patches::Windows::x64, Patterns::Windows::x64> (&patcher, renamed_binary_path, wowBuild); - - do_module<Patches::Windows::x64, Patterns::Windows::x64> - ( "0a3afee2cade3a0e8b458c4b4660104cac7fc50e2ca9bef0d708942e77f15c1d.auth" - , std::wstring(appDataPath) + std::wstring(L"/Blizzard Entertainment/Battle.net/Cache/") - ); - + WriteCertificateBundle(boost::filesystem::path(binary_path).remove_filename() / "tc_bundle.txt"); break; case Constants::BinaryTypes::Mach64: std::cout << "Mac client...\n"; - boost::algorithm::replace_all (renamed_binary_path, ".app", " Patched.app"); + boost::algorithm::replace_all(renamed_binary_path, ".app", " Patched.app"); Helper::CopyDir(boost::filesystem::path(binary_path).parent_path()/*MacOS*/.parent_path()/*Contents*/.parent_path() , boost::filesystem::path(renamed_binary_path).parent_path()/*MacOS*/.parent_path()/*Contents*/.parent_path() ); @@ -257,12 +189,7 @@ int main(int argc, char** argv) namespace fs = boost::filesystem; fs::permissions(renamed_binary_path, fs::add_perms | fs::others_exe | fs::group_exe | fs::owner_exe); } - - do_module<Patches::Mac::x64, Patterns::Mac::x64> - ( "97eeb2e28e9e56ed6a22d09f44e2ff43c93315e006bbad43bafc0defaa6f50ae.auth" - , "/Users/Shared/Blizzard/Battle.net/Cache/" - ); - + WriteCertificateBundle(boost::filesystem::path(binary_path).parent_path()/*MacOS*/.parent_path()/*Contents*/.parent_path()/*World of Warcraft.app*/.parent_path() / "tc_bundle.txt"); break; default: throw std::runtime_error("Type: " + std::to_string(static_cast<uint32_t>(patcher.GetType())) + " not supported!"); |