Skip to content

Commit

Permalink
feat: rename SetRequestFingerprintPacket into HttpConfigurationPacket…
Browse files Browse the repository at this point in the history
…. HWID can now be set to a custom one, if left empty it will use the Systems' HWID. Fix TypeDefintion for RBX::Lua::WeakThreadRef::detail.
  • Loading branch information
SecondNewtonLaw committed Sep 13, 2024
1 parent 889d75b commit 88522d6
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 53 deletions.
28 changes: 24 additions & 4 deletions Communication/Communication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#include "PacketSerdes.hpp"
#include "Packets/DataModelUpdatePacket.hpp"
#include "Packets/HelloPacket.hpp"
#include "Packets/HttpConfigurationPacket.hpp"
#include "Packets/ResponseStatusPacket.hpp"
#include "Packets/ScheduleLuauPacket.hpp"
#include "Packets/SetExecutionDataModelPacket.hpp"
#include "Packets/SetFastVariablePacket.hpp"
#include "Packets/SetFunctionBlockStatePacket.hpp"
#include "Packets/SetNativeCodeGenPacket.hpp"
#include "Packets/SetRequestFingerprintPacket.hpp"
#include "Packets/SetSafeModePacket.hpp"
#include "Packets/SetScriptSourceAccessPacket.hpp"
#include "RobloxManager.hpp"
Expand All @@ -29,6 +29,13 @@ std::shared_ptr<Communication> Communication::pInstance;

static std::mutex __get_singleton_lock{};

Communication::Communication() {
if (const auto hwid = Utilities::GetHwid(); hwid.has_value())
this->m_szHardwareId = hwid.value();
else
this->m_szHardwareId = "8F3A2C1BE9D70F4";
}

std::shared_ptr<Communication> Communication::GetSingleton() {
std::scoped_lock lock{__get_singleton_lock};
if (Communication::pInstance == nullptr)
Expand Down Expand Up @@ -88,6 +95,7 @@ const RBX::DataModelType Communication::GetExecutionDataModel() { return this->l
bool Communication::IsCodeGenerationEnabled() const { return this->m_bEnableCodeGen; }
void Communication::SetCodeGenerationEnabled(const bool enableCodeGen) { this->m_bEnableCodeGen = enableCodeGen; }
bool Communication::CanAccessScriptSource() const { return this->m_bAllowScriptSourceAccess; }
std::string Communication::GetHardwareId() { return this->m_szHardwareId; }

[[noreturn]] void Communication::NewCommunication(const std::string &szRemoteHost) {
const auto logger = Logger::GetSingleton();
Expand Down Expand Up @@ -245,11 +253,23 @@ bool Communication::CanAccessScriptSource() const { return this->m_bAllowScriptS
break;
}

case RbxStu::WebSocketCommunication::SetRequestFingerprintPacket: {
if (const auto packet =
serializer->DeserializeFromJson<SetRequestFingerprintPacket>(message->str);
case RbxStu::WebSocketCommunication::HttpConfigurationPacket: {
if (const auto packet = serializer->DeserializeFromJson<HttpConfigurationPacket>(message->str);
packet.has_value()) {
communication->m_szFingerprintHeader = std::string(packet->szNewFingerprint);
if (packet->szNewHwid.empty()) {
logger->PrintWarning(RbxStu::Communication,
"HttpConfigurationPacket provided no new HardwareID. "
"Automatically using the DEFAULT system hardware ID.");
if (const auto hwid = Utilities::GetHwid(); hwid.has_value())
communication->m_szHardwareId = hwid.value();
else
logger->PrintError(RbxStu::Communication,
"Hardware ID not changed! There has been an error obtaining "
"your PC's Hardware ID!");
} else {
communication->m_szHardwareId = std::string(packet->szNewHwid);
}
wasSuccess = true;
} else {
logger->PrintWarning(
Expand Down
6 changes: 5 additions & 1 deletion Communication/Communication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ class Communication final {
RBX::DataModelType lCurrentExecutionDataModel = RBX::DataModelType_PlayClient;

std::string m_szFingerprintHeader = "RbxStu-Fingerprint";

std::string m_szHardwareId = "";

public:
Communication();

static std::shared_ptr<Communication> GetSingleton();

/// @brief Defines if the DLL should run in UNSAFE mode, turning off all protections, leaving raw execution.
Expand Down Expand Up @@ -66,6 +68,8 @@ class Communication final {
bool IsCodeGenerationEnabled() const;
void SetCodeGenerationEnabled(bool enableCodeGen);
bool CanAccessScriptSource() const;
std::string GetHardwareId();
;

/// @brief Swiftly handles the WebSocket used for advanced communication with RbxStu V2.
/// @param szRemoteHost The remote host that will handle the communication.
Expand Down
37 changes: 37 additions & 0 deletions Communication/Packets/HttpConfigurationPacket.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Created by Dottik on 30/8/2024.
//

#pragma once
#include <cstring>


#include "PacketBase.hpp"

struct HttpConfigurationPacket final : public PacketBase {
std::string szNewFingerprint;
std::string szNewHwid;

HttpConfigurationPacket() { this->ulPacketId = RbxStu::WebSocketCommunication::HttpConfigurationPacket; }

static nlohmann::json Serialize(const HttpConfigurationPacket &packet) {
return {
{"packet_id", packet.ulPacketId},
{"packet_flags", packet.ullPacketFlags},
{"new_http_fingerprint", packet.szNewFingerprint},
{"new_hwid", packet.szNewHwid},
};
}


static HttpConfigurationPacket Deserialize(nlohmann::json json) {
auto result = HttpConfigurationPacket{};

json.at("packet_id").get_to(result.ulPacketId);
json.at("packet_flags").get_to(result.ullPacketFlags);
json.at("new_http_fingerprint").get_to(result.szNewFingerprint);
if (json.contains("new_hwid"))
json.at("new_hwid").get_to(result.szNewHwid);
return result;
}
};
2 changes: 1 addition & 1 deletion Communication/Packets/PacketBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace RbxStu::WebSocketCommunication {

/// @brief Sets the Fingerprint used on the HTTP header for game:HttpGet, httpget, and
/// request/http_request/http.request.
SetRequestFingerprintPacket = 0x4,
HttpConfigurationPacket = 0x4,

/// @brief Sets the safe mode for RbxStu V2. This will toggle all built-in security, beware.
SetSafeModePacket = 0x5,
Expand Down
32 changes: 0 additions & 32 deletions Communication/Packets/SetRequestFingerprintPacket.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion Environment/Libraries/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace RbxStu {
}

int gethwid(lua_State *L) {
lua_pushstring(L, Utilities::GetHwid()->c_str());
lua_pushstring(L, Communication::GetSingleton()->GetHardwareId().c_str());
return 1;
}

Expand Down
15 changes: 4 additions & 11 deletions Environment/Libraries/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,8 @@ namespace RbxStu {
auto Headers = std::map<std::string, std::string, cpr::CaseInsensitiveCompare>();
Headers["User-Agent"] = "Roblox/WinInet";

if (const auto optionalHardwareId = Utilities::GetHwid(); !optionalHardwareId.has_value())
Headers[Communication::GetSingleton()->GetFingerprintHeaderName()] =
"8F3A2C1BE9D70F4"; // Stub value if GetHwid fails.
else
Headers[Communication::GetSingleton()->GetFingerprintHeaderName()] =
optionalHardwareId.value();
auto communication = Communication::GetSingleton();
Headers[communication->GetFingerprintHeaderName()] = communication->GetHardwareId();

const auto response = cpr::Get(cpr::Url{url}, cpr::Header{Headers});

Expand Down Expand Up @@ -288,11 +284,8 @@ namespace RbxStu {
auto Headers = std::map<std::string, std::string, cpr::CaseInsensitiveCompare>();
Headers["User-Agent"] = "Roblox/WinInet";

if (const auto optionalHardwareId = Utilities::GetHwid(); !optionalHardwareId.has_value())
Headers[Communication::GetSingleton()->GetFingerprintHeaderName()] =
"8F3A2C1BE9D70F4"; // Stub value if GetHwid fails.
else
Headers[Communication::GetSingleton()->GetFingerprintHeaderName()] = optionalHardwareId.value();
auto communication = Communication::GetSingleton();
Headers[communication->GetFingerprintHeaderName()] = communication->GetHardwareId();

lua_getfield(L, 1, "Headers");
if (!lua_isnil(L, -1)) {
Expand Down
2 changes: 1 addition & 1 deletion Roblox/TypeDefinitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ namespace RBX {

namespace Lua {
struct WeakThreadRef {
std::atomic_int32_t _Refs;
std::atomic<int> _Refs;
lua_State *thread;
int32_t thread_ref;
int32_t objectId;
Expand Down
2 changes: 1 addition & 1 deletion Scanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Scanner final {
/// calculate the base address of the returned void pointers.
/// @return A vector containing all the addresses that matched, translated from the buffers address into the
/// BaseAddress provided by memoryInformation.
static std::vector<void *> ScanInternal(_In_ const unsigned char *buffer, _In_ const std::size_t bufferSize,
static std::vector<void *> ScanInternal(_In_ const unsigned char *buffer, _In_ std::size_t bufferSize,
_In_ const Signature &signature,
_In_ const MEMORY_BASIC_INFORMATION &memoryInformation);

Expand Down
2 changes: 1 addition & 1 deletion Security.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace RBX::Lua {
char _70[8];
std::weak_ptr<RBX::Script> script;
char _88[8];
bool globalActorState;
bool isActorState;
enum RBX::Luau::TaskState taskStatus;
};

Expand Down

0 comments on commit 88522d6

Please sign in to comment.