Categories > Exploiting > Tutorials >

[Lua C] How to replicate R/Lua Methods

Posts: 975

Threads: 34

Joined: Dec, 2016

Reputation: 108

Posted

[Disclaimer] : These are not actually Lua methods. They are just functions I put together that perform similarly to the real method.

 

Honestly, I am not the best at explaining, nor am I the best at teaching. Though I do want to help out and share my ideas in hopes of improving your exploit related content. I'm sure that a lot of you learn well through examples(Your math class probably teaches you this way), so I will try to do so and then explain them as far and as concise as I can.

 

Below is some pre-made code example for yall to use or check out(No credits are expected, though it would be nice). You can apply the ideas below to other R/RLua methods. This can definitely aid in the process of creating a super basic limited Lua executor

 


 

Out of all of the leaked sources I have checked out, I haven't seen anything like this. Usually when I see FindFirstChild being used, its just getfield("FindFirstChild"); this may be practical when all you need to do is lead yourself to the object you know exists, but what if this object doesn't exist? Continuing to add to the stack will often crash the game. Maybe you need to actually check if the instance exists.

 

To replicate the FindFirstChild method, we can do this by looping through the children of the instance at the top of the stack, and for each iterated object, we check its name. For the first child we find, we return it.

 

bool FindFirstChild(std::string Name) {
	std::string childsName;
	std::string test;
	getfield(-1, "GetChildren");
	pushvalue(-2);
	pcall(1, 1, 0);
	pushnil();
	while (next(-2) != 0) {
		getfield(-1, "Name");
		if (std::string(tostring(-1)) == Name) {
			pop(1);
			return true;
		}
		pop(2);
	}
	pop(1);
	return false;
}

C++ usage version:

getglobal ("game");
getfield ("Workspace");
if(FindFirstChild("GroupOfParts")){ //execute code }

Lua Version: 

if game.Workspace:FindFirstChild("GroupOfParts") then
	--execute code; 
end

 


 

Maybe we want to replicate the IsA Method. We can do this by checking the objects ClassName property and comparing to see if its what we want. 

bool IsA(std::string ClassName) {
	std::string classType;
	getfield(-1, "ClassName");
	classType = std::string(tostring(-1));
	if (classType == ClassName) {
		pop(1); //Return to original stack top
		return true; //Leaves object at the top of the stack 
	}
	pop(2); //Return to original stack top
	return false;
}

 

C++ usage version:

getglobal ("game");
getfield ("Workspace");
getfield ("GroupOfParts");
if(IsA("Model")){ //execute code }

Lua Version: 

if game.Workspace.GroupOfParts:IsA["Model"] then
	--execute code
end

 


 

We can even do this for functions as basic as RemoveAccessories which returns nothing. This may not be practical, but my point here is to show that you can pretty much replicate most of RLua/Lua's methods.

 

void RemoveAccessories(){
	getfield("RemoveAccessories ");
	pushvalue(-2)
	pcall(1, 0, 0);
}

C++ usage version:

getglobal("game");
getfield("Workspace");
getfield("Player");
getfield("Humanoid");

Lua Version: 

game.Workspace.Player.Humanoid:RemoveAccessories()

Comments

Xero 108 Reputation

Commented

Reuploaded my 2017 post from V3rmillion to WRD

  • 3

  • 9

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )