diff options
-rw-r--r-- | src/tools/connection_patcher/Patcher.cpp | 28 | ||||
-rw-r--r-- | src/tools/connection_patcher/Patches/Mac.hpp | 2 | ||||
-rw-r--r-- | src/tools/connection_patcher/Patterns/Mac.hpp | 2 | ||||
-rw-r--r-- | src/tools/connection_patcher/Program.cpp | 18 |
4 files changed, 34 insertions, 16 deletions
diff --git a/src/tools/connection_patcher/Patcher.cpp b/src/tools/connection_patcher/Patcher.cpp index 65cf1704472..92d9dacedf3 100644 --- a/src/tools/connection_patcher/Patcher.cpp +++ b/src/tools/connection_patcher/Patcher.cpp @@ -24,6 +24,7 @@ #include <fstream> #include <iostream> #include <iterator> +#include <set> #include <stdexcept> namespace @@ -50,17 +51,15 @@ namespace std::copy(data.begin(), data.end(), std::ostream_iterator<unsigned char>(ofs)); } - size_t SearchOffset (std::vector<unsigned char> const& binary, std::vector<unsigned char> const& pattern) + std::set<size_t> SearchOffset (std::vector<unsigned char> const& binary, std::vector<unsigned char> const& pattern) { - for (size_t i = 0; i < binary.size(); i++) + std::set<size_t> offsets; + for (size_t i = 0; (i + pattern.size()) < binary.size(); i++) { size_t matches = 0; for (size_t j = 0; j < pattern.size(); j++) { - if (pattern.size() > (binary.size() - i)) - throw std::runtime_error("unable to find pattern"); - if (pattern[j] == 0) { matches++; @@ -74,10 +73,13 @@ namespace } if (matches == pattern.size()) - return i; + { + offsets.insert(i); + i += matches; + } } - throw std::runtime_error("unable to find pattern"); + return offsets.empty() ? throw std::runtime_error("unable to find pattern") : offsets; } } @@ -96,12 +98,14 @@ namespace Connection_Patcher if (pattern.empty()) return; - size_t const offset(SearchOffset(binary, pattern)); - std::cout << "Found offset " << offset << std::endl; + for (size_t const offset : SearchOffset(binary, pattern)) + { + std::cout << "Found offset " << offset << std::endl; - if (offset != 0 && binary.size() >= bytes.size()) - for (size_t i = 0; i < bytes.size(); i++) - binary[offset + i] = bytes[i]; + if (offset != 0 && binary.size() >= bytes.size()) + for (size_t i = 0; i < bytes.size(); i++) + binary[offset + i] = bytes[i]; + } } void Patcher::Finish(boost::filesystem::path out) diff --git a/src/tools/connection_patcher/Patches/Mac.hpp b/src/tools/connection_patcher/Patches/Mac.hpp index b1e4853c64e..9fad02e3ec6 100644 --- a/src/tools/connection_patcher/Patches/Mac.hpp +++ b/src/tools/connection_patcher/Patches/Mac.hpp @@ -31,7 +31,7 @@ namespace Connection_Patcher { 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 { 0x45, 0x31, 0xED, 0x4D, 0x89, 0xFC, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xEB }; } + static const std::vector<unsigned char> Signature() { return { 0x41, 0xB6, 0x01, 0x41, 0xBF, 0x02, 0x00, 0x00, 0x00, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; } }; }; } diff --git a/src/tools/connection_patcher/Patterns/Mac.hpp b/src/tools/connection_patcher/Patterns/Mac.hpp index f55472b06f3..6f13cdda5c7 100644 --- a/src/tools/connection_patcher/Patterns/Mac.hpp +++ b/src/tools/connection_patcher/Patterns/Mac.hpp @@ -31,7 +31,7 @@ namespace Connection_Patcher { 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 { 0xE8, 0x00, 0x00, 0x00, 0x00, 0x45, 0x31, 0xED, 0x4D, 0x89, 0xFC, 0x84, 0xC0, 0x75 }; } + static const std::vector<unsigned char> Signature() { return { 0x45, 0x31, 0xF6, 0x31, 0xF6, 0x31, 0xD2, 0x4C, 0x89, 0xE7, 0xE8, 0x00, 0x00, 0x00, 0x00, 0x41, 0xBF, 0x04, 0x00, 0x00, 0x00 }; } }; }; } diff --git a/src/tools/connection_patcher/Program.cpp b/src/tools/connection_patcher/Program.cpp index a613485f839..56007232d20 100644 --- a/src/tools/connection_patcher/Program.cpp +++ b/src/tools/connection_patcher/Program.cpp @@ -48,7 +48,9 @@ namespace Connection_Patcher 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.binary) + ".auth"); @@ -58,7 +60,8 @@ namespace Connection_Patcher if (!fs::exists(modulePath)) fs::create_directories(modulePath); - fs::permissions(modulePath / moduleName, fs::add_perms | fs::others_write | fs::group_write | fs::owner_write); + if (fs::exists(modulePath / modulePath)) + 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); @@ -82,13 +85,24 @@ namespace Connection_Patcher void do_patches(Patcher* patcher, boost::filesystem::path output) { std::cout << "patching Portal\n"; + // '.logon.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 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()); + patcher->Finish(output); std::cout << "Patching done.\n"; @@ -180,7 +194,7 @@ int main(int argc, char** argv) do_patches<Patches::Mac::x64, Patterns::Mac::x64> (&patcher, renamed_binary_path); - do_module<Patches::Windows::x64, Patterns::Windows::x64> + do_module<Patches::Mac::x64, Patterns::Mac::x64> ( "97eeb2e28e9e56ed6a22d09f44e2ff43c93315e006bbad43bafc0defaa6f50ae.auth" , "/Users/Shared/Blizzard/Battle.net/Cache/" ); |