Skip to content

Commit

Permalink
Offset changes, bug fixes, better memory management + more efficient,…
Browse files Browse the repository at this point in the history
… version checking, etc
  • Loading branch information
Riz-ve committed Sep 5, 2024
1 parent 5968193 commit d9478b8
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 12,776 deletions.
2 changes: 1 addition & 1 deletion Xeno/include/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ function Bridge:rconsole(_type, content)
local result = self:InternalRequest({
['c'] = "rc",
['t'] = _type,
['ct'] = content
['ct'] = base64.encode(content)
})
return result ~= nil
end
Expand Down
79 changes: 48 additions & 31 deletions Xeno/include/worker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,29 @@
namespace offsets {
// Instance
constexpr std::uintptr_t This = 0x8;
constexpr std::uintptr_t Name = 0x48;
constexpr std::uintptr_t Children = 0x50;
constexpr std::uintptr_t Parent = 0x60;
constexpr std::uintptr_t Name = 0x50;
constexpr std::uintptr_t Children = 0x58;
constexpr std::uintptr_t Parent = 0x68;

constexpr std::uintptr_t ClassDescriptor = 0x18;
constexpr std::uintptr_t ClassName = 0x8;

// Scripts
constexpr std::uintptr_t ModuleScriptEmbedded = 0x158;
constexpr std::uintptr_t IsCoreScript = 0x1a0;
constexpr std::uintptr_t ModuleScriptEmbedded = 0x160;
constexpr std::uintptr_t IsCoreScript = 0x1a8;
constexpr std::uintptr_t ModuleFlags = IsCoreScript - 0x4;
constexpr std::uintptr_t LocalScriptEmbedded = 0x1b8;
constexpr std::uintptr_t LocalScriptEmbedded = 0x1c0;

constexpr std::uintptr_t Bytecode = 0x10;
constexpr std::uintptr_t BytecodeSize = 0x20;

// Other
constexpr std::uintptr_t LocalPlayer = 0x100;
constexpr std::uintptr_t ObjectValue = 0xc0;
constexpr std::uintptr_t LocalPlayer = 0x108;
constexpr std::uintptr_t ObjectValue = 0xc8;
}

const std::string_view Xeno_Version = "1.0.2";

template<typename T>
T read_memory(std::uintptr_t address, HANDLE handle);

Expand Down Expand Up @@ -70,6 +72,7 @@ class Instance {
const std::uintptr_t _Self;
const ClassDescriptor classDescriptor;
HANDLE handle;

public:
Instance(std::uintptr_t address, HANDLE handle) :
handle(handle),
Expand All @@ -81,67 +84,71 @@ class Instance {
std::vector<std::uintptr_t> GetChildrenAddresses() const {
return functions::GetChildrenAddresses(_Self, handle);
}
std::vector<Instance*> GetChildren() const {

std::vector<std::unique_ptr<Instance>> GetChildren() const {
std::vector<std::uintptr_t> childAddresses = GetChildrenAddresses();
std::vector<Instance*> children;
std::vector<std::unique_ptr<Instance>> children;
for (std::uintptr_t address : childAddresses) {
children.push_back(new Instance(address, handle));
children.push_back(std::make_unique<Instance>(address, handle));
}
return children;
}

std::uintptr_t FindFirstChildAddress(const std::string& name) const {
std::uintptr_t FindFirstChildAddress(const std::string_view name) const {
std::vector<std::uintptr_t> childAddresses = GetChildrenAddresses();
for (std::uintptr_t address : childAddresses) {
if (functions::ReadRobloxString(read_memory<std::uintptr_t>(address + offsets::Name, handle), handle) == name)
return address;
}
return 0;
}
Instance* FindFirstChild(const std::string& name) const {

std::unique_ptr<Instance> FindFirstChild(const std::string_view name) const {
std::uintptr_t childAddress = FindFirstChildAddress(name);
if (childAddress != 0)
return new Instance(childAddress, handle);
return std::make_unique<Instance>(childAddress, handle);
return nullptr;
}

std::uintptr_t WaitForChildAddress(const std::string& name, int timeout=9e9) const {
std::uintptr_t WaitForChildAddress(const std::string_view name, int timeout = 9e9) const {
std::uintptr_t existing = FindFirstChildAddress(name);
if (existing != 0)
return existing;

std::chrono::steady_clock::time_point start_time = std::chrono::high_resolution_clock::now();
while (std::chrono::high_resolution_clock::now() - start_time <= std::chrono::seconds(timeout))
{
while (std::chrono::high_resolution_clock::now() - start_time <= std::chrono::seconds(timeout)) {
if (FindFirstChildAddress(name))
return FindFirstChildAddress(name);
Sleep(100);
}
return 0;
}
Instance* WaitForChild(const std::string& name, int timeout=9e9) const { // timeout: seconds

std::unique_ptr<Instance> WaitForChild(const std::string_view name, int timeout = 9e9) const {
std::uintptr_t childAddress = WaitForChildAddress(name, timeout);
if (childAddress != 0)
return new Instance(childAddress, handle);
return std::make_unique<Instance>(childAddress, handle);
return nullptr;
}

std::uintptr_t FindFirstChildOfClassAddress(const std::string& className) const {
std::uintptr_t FindFirstChildOfClassAddress(const std::string_view className) const {
std::vector<std::uintptr_t> childAddresses = GetChildrenAddresses();
for (std::uintptr_t address : childAddresses) {
if (functions::ReadRobloxString(read_memory<std::uintptr_t>(read_memory<std::uintptr_t>(address + offsets::ClassDescriptor, handle) + offsets::ClassName, handle), handle) == className)
return address;
}
return 0;
}
Instance* FindFirstChildOfClass(const std::string& className) const {

std::unique_ptr<Instance> FindFirstChildOfClass(const std::string_view className) const {
std::uintptr_t childAddress = FindFirstChildOfClassAddress(className);
if (childAddress != 0)
return new Instance(childAddress, handle);
return std::make_unique<Instance>(childAddress, handle);
return nullptr;
}

// Miscellaneous
bool SetBytecode(const std::string& compressedBytecode, bool revertBytecode=false) const {
bool SetBytecode(const std::string& compressedBytecode, bool revertBytecode = false) const {
if (ClassName() != "LocalScript" && ClassName() != "ModuleScript")
return false;

Expand Down Expand Up @@ -173,6 +180,7 @@ class Instance {
&& write_memory<std::uintptr_t>(embeddedPtr + offsets::Bytecode, reinterpret_cast<std::uintptr_t>(allocatedAddress), handle)
&& write_memory<std::uint64_t>(embeddedPtr + offsets::BytecodeSize, compressedBytecode.size(), handle);
}

std::string GetBytecode() const;

void UnlockModule() const {
Expand All @@ -186,12 +194,19 @@ class Instance {
inline std::uintptr_t Self() const {
return _Self;
}

inline std::string Name() const {
return functions::ReadRobloxString(read_memory<std::uintptr_t>(_Self + offsets::Name, handle), handle);
}
inline std::uintptr_t Parent() const {

inline std::uintptr_t ParentAddress() const {
return read_memory<std::uintptr_t>(_Self + offsets::Parent, handle);
}

inline std::unique_ptr<Instance> Parent() const {
return std::make_unique<Instance>(ParentAddress(), handle);
}

inline std::string ClassName() const {
return classDescriptor.Name;
}
Expand All @@ -203,6 +218,7 @@ class RBXClient {
std::uintptr_t RenderView{};
public:
std::string Username = "N/A";
std::string Version = "";
std::string GUID;
DWORD PID;

Expand All @@ -227,36 +243,37 @@ class RBXClient {
}

void execute(const std::string& source) const;
bool loadstring(const std::string& source, std::string& script_name, std::string& chunk_name) const;
bool loadstring(const std::string& source, const std::string& script_name, const std::string& chunk_name) const;

void UnlockModule(const std::string& objectval_name) const {
void UnlockModule(const std::string_view objectval_name) const {
std::uintptr_t scriptPtr = RBXClient::GetObjectValuePtr(objectval_name);
if (scriptPtr == 0)
return;

return Instance(scriptPtr, handle).UnlockModule();
}

std::string GetBytecode(const std::string& objectval_name) const {
std::string GetBytecode(const std::string_view objectval_name) const {
std::uintptr_t scriptPtr = RBXClient::GetObjectValuePtr(objectval_name);
if (scriptPtr == 0)
return "";

return Instance(scriptPtr, handle).GetBytecode();
}

void SpoofInstance(const std::string& objectval_name, std::uintptr_t new_address) const {
void SpoofInstance(const std::string_view objectval_name, std::uintptr_t new_address) const {
std::uintptr_t instancePtr = RBXClient::GetObjectValuePtr(objectval_name);
if (instancePtr == 0)
return;

write_memory<std::uintptr_t>(instancePtr + offsets::This, new_address, handle);
}

std::uintptr_t GetObjectValuePtr(const std::string& objectval_name) const;
std::uintptr_t GetObjectValuePtr(std::string_view objectval_name) const;
};

struct SimpleClient {
struct ClientInfo {
const char* Version;
const char* Username;
int ProcessID;
};
Expand All @@ -276,6 +293,6 @@ std::uintptr_t GetRV(HANDLE handle);

std::string compilable(const std::string& source, bool returnBytecode=false);
std::string Compile(const std::string& source);
std::string decompress(const std::string& compressed);
std::string decompress(const std::string_view compressed);

HWND GetHWNDFromPID(DWORD process_id);
8 changes: 4 additions & 4 deletions Xeno/src/Xeno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ static void init() {
}

extern "C" {
__declspec(dllexport) SimpleClient* GetClients() {
static std::vector<SimpleClient> simpleClients;
__declspec(dllexport) ClientInfo* GetClients() {
static std::vector<ClientInfo> simpleClients;
{
std::lock_guard<std::mutex> lock(clientsMtx);
simpleClients.clear();

for (const auto& client : Clients) {
simpleClients.push_back({ client->Username.c_str(), static_cast<int>(client->PID) });
simpleClients.push_back({client->Version.c_str() /*Version*/, client->Username.c_str() /*Username*/, static_cast<int>(client->PID) /*Process ID*/});
}

simpleClients.push_back({ nullptr, 0 });
simpleClients.push_back({ nullptr, nullptr, 0 });
}
return simpleClients.data();
}
Expand Down
Loading

0 comments on commit d9478b8

Please sign in to comment.