From c4987fc8719a28cdca8922f3df72b4c5637a1ea3 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 21 Nov 2022 20:45:04 +0100 Subject: [PATCH] Generate guid through hardware identifiers --- src/client/component/auth.cpp | 107 +++++++++++++++++++++++++++ src/client/component/auth.hpp | 6 ++ src/client/steam/interfaces/user.cpp | 5 +- 3 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 src/client/component/auth.cpp create mode 100644 src/client/component/auth.hpp diff --git a/src/client/component/auth.cpp b/src/client/component/auth.cpp new file mode 100644 index 00000000..5513b7eb --- /dev/null +++ b/src/client/component/auth.cpp @@ -0,0 +1,107 @@ +#include +#include "loader/component_loader.hpp" + +#include "auth.hpp" + +#include + +#include +#include +#include +#include + +namespace auth +{ + namespace + { + std::string get_hdd_serial() + { + DWORD serial{}; + if (!GetVolumeInformationA("C:\\", nullptr, 0, &serial, nullptr, nullptr, nullptr, 0)) + { + return {}; + } + + return utils::string::va("%08X", serial); + } + + std::string get_hw_profile_guid() + { + HW_PROFILE_INFO info; + if (!GetCurrentHwProfileA(&info)) + { + return {}; + } + + return std::string{info.szHwProfileGuid, sizeof(info.szHwProfileGuid)}; + } + + std::string get_protected_data() + { + std::string input = "momo5502-boiii-auth"; + + DATA_BLOB data_in{}, data_out{}; + data_in.pbData = reinterpret_cast(input.data()); + data_in.cbData = static_cast(input.size()); + if (CryptProtectData(&data_in, nullptr, nullptr, nullptr, nullptr, CRYPTPROTECT_LOCAL_MACHINE, + &data_out) != TRUE) + { + return {}; + } + + const auto size = std::min(data_out.cbData, 52ul); + std::string result{reinterpret_cast(data_out.pbData), size}; + LocalFree(data_out.pbData); + + return result; + } + + std::string get_key_entropy() + { + std::string entropy{}; + entropy.append(utils::smbios::get_uuid()); + entropy.append(get_hw_profile_guid()); + entropy.append(get_protected_data()); + entropy.append(get_hdd_serial()); + + if (entropy.empty()) + { + entropy.resize(32); + utils::cryptography::random::get_data(entropy.data(), entropy.size()); + } + + return entropy; + } + + utils::cryptography::ecc::key& get_key() + { + static auto key = utils::cryptography::ecc::generate_key(512, get_key_entropy()); + return key; + } + } + + uint64_t get_guid() + { + /*if (game::environment::is_dedi()) + { + return 0x110000100000000 | (::utils::cryptography::random::get_integer() & ~0x80000000); + }*/ + + return get_key().get_hash(); + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + // Patch steam id bit check + utils::hook::jump(0x141E19D7D_g, 0x141E19DCB_g); + utils::hook::jump(0x141EB2D06_g, 0x141EB2D46_g); + utils::hook::jump(0x141EB2E3D_g, 0x141EB2E82_g); + utils::hook::jump(0x141EB3CC5_g, 0x141EB3D06_g); + } + }; +} + +REGISTER_COMPONENT(auth::component) diff --git a/src/client/component/auth.hpp b/src/client/component/auth.hpp new file mode 100644 index 00000000..3ee0c53a --- /dev/null +++ b/src/client/component/auth.hpp @@ -0,0 +1,6 @@ +#pragma once + +namespace auth +{ + uint64_t get_guid(); +} diff --git a/src/client/steam/interfaces/user.cpp b/src/client/steam/interfaces/user.cpp index e01e8c75..cda52612 100644 --- a/src/client/steam/interfaces/user.cpp +++ b/src/client/steam/interfaces/user.cpp @@ -1,5 +1,7 @@ #include + #include "../steam.hpp" +#include "../../component/auth.hpp" namespace steam @@ -11,7 +13,7 @@ namespace steam steam_id generate_steam_id() { steam_id id{}; - id.bits = 76561197960287930; + id.bits = auth::get_guid(); return id; } } @@ -86,7 +88,6 @@ namespace steam unsigned int user::GetAuthSessionTicket(void* pTicket, int cbMaxTicket, unsigned int* pcbTicket) { - static uint32_t ticket = 0; *pcbTicket = 1;