Skip to content

Commit

Permalink
add executor stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
softbf395 authored Oct 21, 2024
1 parent a3cb10f commit 437ee11
Show file tree
Hide file tree
Showing 96 changed files with 40,088 additions and 0 deletions.
97 changes: 97 additions & 0 deletions source/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.18.1)

# Declares and names the project.

project("mobileblox" CXX)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
mobileblox

# Sets the library as a shared library.
SHARED

# Provides a relative path to your source file(s).
native-lib.cpp
luau/lapi.cpp
luau/laux.cpp
luau/lbaselib.cpp
luau/lbitlib.cpp
luau/lbuiltins.cpp
luau/lcorolib.cpp
luau/ldblib.cpp
luau/ldebug.cpp
luau/ldo.cpp
luau/lfunc.cpp
luau/lgc.cpp
luau/lgcdebug.cpp
luau/linit.cpp
luau/lmathlib.cpp
luau/lmem.cpp
luau/lnumprint.cpp
luau/lobject.cpp
luau/loslib.cpp
luau/lperf.cpp
luau/lstate.cpp
luau/lstring.cpp
luau/lstrlib.cpp
luau/ltable.cpp
luau/ltablib.cpp
luau/ltm.cpp
luau/ludata.cpp
luau/lutf8lib.cpp
luau/lvmexecute.cpp
luau/lvmload.cpp
luau/lvmutils.cpp
luau/Ast.cpp
luau/BuiltinFolding.cpp
luau/Builtins.cpp
luau/BytecodeBuilder.cpp
luau/Compiler.cpp
luau/Confusables.cpp
luau/ConstantFolding.cpp
luau/CostModel.cpp
luau/lcode.cpp
luau/Lexer.cpp
luau/Location.cpp
luau/Parser.cpp
luau/StringUtils.cpp
luau/TableShape.cpp
luau/TimeTrace.cpp
luau/ValueTracking.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
log-lib

# Specifies the name of the NDK library that
# you want CMake to locate.
log)
find_package(Dobby REQUIRED CONFIG)

include_directories(prefab/modules/dobby/include)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
mobileblox
dobby::dobby

# Links the target library to the log library
# included in the NDK.
${log-lib})
134 changes: 134 additions & 0 deletions source/cpp/LuaUI.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#pragma once

#include <string>

// Lua UI we execute
std::string LuaUI = R"(
-- Gui to Lua
-- Version: 3.2
-- Instances:
local MobileBlox = Instance.new('ScreenGui')
local Main = Instance.new('Frame')
local TextBox = Instance.new('TextBox')
local Clear = Instance.new('TextButton')
local Execute = Instance.new('TextButton')
--Properties:
MobileBlox.Name = "MobileBlox"
MobileBlox.Parent = game:WaitForChild('CoreGui')
Main.Name = "Main"
Main.Parent = MobileBlox
Main.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
Main.Position = UDim2.new(0.318584085, 0, 0.197959185, 0)
Main.Size = UDim2.new(0, 492, 0, 282)
TextBox.Parent = Main
TextBox.BackgroundColor3 = Color3.fromRGB(33, 33, 33)
TextBox.Position = UDim2.new(0.0375582054, 0, 0.0874655992, 0)
TextBox.Size = UDim2.new(0, 450, 0, 195)
TextBox.ClearTextOnFocus = false
TextBox.Font = Enum.Font.Ubuntu
TextBox.MultiLine = true
TextBox.Text = ""
TextBox.TextColor3 = Color3.fromRGB(186, 186, 186)
TextBox.TextSize = 14.000
TextBox.TextXAlignment = Enum.TextXAlignment.Left
TextBox.TextYAlignment = Enum.TextYAlignment.Top
Clear.Name = "Clear"
Clear.Parent = Main
Clear.BackgroundColor3 = Color3.fromRGB(144, 0, 0)
Clear.Position = UDim2.new(0.544715464, 0, 0.822695017, 0)
Clear.Size = UDim2.new(0, 200, 0, 50)
Clear.Font = Enum.Font.SourceSans
Clear.Text = "Clear"
Clear.TextColor3 = Color3.fromRGB(0, 0, 0)
Clear.TextScaled = true
Clear.TextSize = 14.000
Clear.TextWrapped = true
Execute.Name = "Execute"
Execute.Parent = Main
Execute.BackgroundColor3 = Color3.fromRGB(63, 190, 93)
Execute.Position = UDim2.new(0.0365853645, 0, 0.822695017, 0)
Execute.Size = UDim2.new(0, 200, 0, 50)
Execute.Font = Enum.Font.SourceSans
Execute.Text = "Execute"
Execute.TextColor3 = Color3.fromRGB(0, 0, 0)
Execute.TextScaled = true
Execute.TextSize = 14.000
Execute.TextWrapped = true
-- Scripts:
local function BGWS_fake_script() -- Main.DragScript
local script = Instance.new('LocalScript', Main)
--Not made by me, check out this video: https://www.youtube.com/watch?v=z25nyNBG7Js&t=22s
--Put this inside of your Frame and configure the speed if you would like.
--Enjoy! Credits go to: https://www.youtube.com/watch?v=z25nyNBG7Js&t=22s
local UIS = game:GetService('UserInputService')
local frame = script.Parent
local dragToggle = nil
local dragSpeed = 0.25
local dragStart = nil
local startPos = nil
local function updateInput(input)
local delta = input.Position - dragStart
local position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X,
startPos.Y.Scale, startPos.Y.Offset + delta.Y)
game:GetService('TweenService'):Create(frame, TweenInfo.new(dragSpeed), {Position = position}):Play()
end
frame.InputBegan:Connect(function(input)
if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) then
dragToggle = true
dragStart = input.Position
startPos = frame.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragToggle = false
end
end)
end
end)
UIS.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
if dragToggle then
updateInput(input)
end
end
end)
end
coroutine.wrap(BGWS_fake_script)()
local function NBUT_fake_script() -- Clear.LocalScript
local script = Instance.new('LocalScript', Clear)
local box = script.Parent.Parent.TextBox
local btn = script.Parent
btn.MouseButton1Click:Connect(function()
box.Text = "";
end)
end
coroutine.wrap(NBUT_fake_script)()
local function OBDPHLQ_fake_script() -- Execute.LocalScript
local script = Instance.new('LocalScript', Execute)
local box = script.Parent.Parent.TextBox
local btn = script.Parent
btn.MouseButton1Click:Connect(function()
loadstring(box.Text)()
end)
end
coroutine.wrap(OBDPHLQ_fake_script)()
)";
35 changes: 35 additions & 0 deletions source/cpp/exec/funcs.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <string>
#include "../globals.hpp"
#include "../memory/mem.hpp"

#include "../luau/lua.h"
#include "../luau/lstate.h"
#include "../luau/Luau/Compiler.h"
#include "../luau/Luau/BytecodeBuilder.h"

class bytecode_encoder_t : public Luau::BytecodeEncoder {
std::uint8_t encodeOp(const std::uint8_t Opcode) override
{ return Opcode * 227; }
};

lua_State* (*rlua_getmainstate)(std::uintptr_t scriptcontext, std::uintptr_t identity, std::uintptr_t script);
lua_State* (*rlua_newthread)(lua_State* rL);
int (*rluau_load)(lua_State* rL, const char* chunkname, const char* code, size_t codesize, int env);
int (*rspawn)(lua_State* rL);

void initfuncs(){
rlua_getmainstate = reinterpret_cast<lua_State*(*)(std::uintptr_t,std::uintptr_t,std::uintptr_t)>(getAddress(getstate_addy));
rlua_newthread = reinterpret_cast<lua_State*(*)(lua_State*)>(getAddress(newthread_addy));
rluau_load = reinterpret_cast<int(*)(lua_State*,const char*,const char*,size_t,int)>(getAddress(luauload_addy));
rspawn = reinterpret_cast<int(*)(lua_State*)>(getAddress(spawn_addy));
}

void executescript(lua_State* ls,const std::string& script){
bytecode_encoder_t encoder;
auto bc = Luau::compile(script,{},{},&encoder);

rluau_load(ls,"",bc.c_str(),bc.size(),0);
rspawn(ls);
}
34 changes: 34 additions & 0 deletions source/cpp/exec/impls.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include "funcs.hpp"

// i chose this way of organization as i think its a bit more readable
// but of course its not the best one, find a better way
// all thanks to android studio not letting me use .cpp files

static int loadstring(lua_State* ls);

void regImpls(lua_State* thread){
// Should wrap this into a registerfunction kind of macro or func
lua_pushcclosure(thread,loadstring,"loadstring",0);
lua_setfield(thread,-10002,"loadstring");
}

int loadstring(lua_State* ls){
const char* s = lua_tostring(ls,1);

bytecode_encoder_t encoder;
auto bc = Luau::compile(s,{},{},&encoder);

const char* chunkname{};
if (lua_gettop(ls) == 2) chunkname = lua_tostring(ls, 2);
else chunkname = "insertrandomgeneratedstring";

if (rluau_load(ls, chunkname, bc.c_str(), bc.size(), 0))
{
lua_pushnil(ls);
lua_pushstring(ls, lua_tostring(ls, -2));
return 2;
}
return 1;
}
17 changes: 17 additions & 0 deletions source/cpp/globals.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <cstdint>
#include "luau/lua.h"
#include "luau/lstate.h"

static std::uintptr_t ScriptContext{};// Roblox's scriptcontext
static lua_State* rL{}; // Roblox's lstate
static lua_State* eL{}; // didn't know what to namethis but its the exploits lstate

// addresses, easy to update if in here
// due to a stack issue related to thumb in 32 bits roblox you need to add a 1 to function addresses
static constexpr int startscript_addy = 0x12C993D;
static constexpr int getstate_addy = 0x12B495D;
static constexpr int newthread_addy = 0x27A68F1;
static constexpr int luauload_addy = 0x27BEBB1;
static constexpr int spawn_addy = 0x12B66E9;
37 changes: 37 additions & 0 deletions source/cpp/hooks/hooks.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <cstdint>
#include "../globals.hpp"
#include "../exec/funcs.hpp"
#include "../exec/impls.hpp"
#include "../LuaUI.hpp"
#include "../luau/lualib.h"

// have to keep everything in a header else a crash occurs
int (*origstartscript)(std::uintptr_t thiz, std::uintptr_t script);
int hkstartscript(std::uintptr_t thiz, std::uintptr_t rscript){
// Lazy way of checking if the game changed
if (ScriptContext != thiz){
ScriptContext = thiz;

int id[2] = {8,0};
int script[] = { NULL,NULL };

rL = rlua_getmainstate(thiz, reinterpret_cast<uintptr_t>(id),reinterpret_cast<uintptr_t>(script));
eL = rlua_newthread(rL);

luaL_sandboxthread(eL); // sandbox our globals
// We set our identity/level to 8 by changing the value of eL->userdata->contextidentity
*reinterpret_cast<std::uintptr_t*>(*reinterpret_cast<std::uintptr_t*>((std::uintptr_t)(eL) + 72) + 24) = 8;

// Make the _G Table
lua_createtable(eL, 0,0);
lua_setfield(eL, -10002, "_G");

// register our implementations
regImpls(eL);

// Execute a Lua UI
executescript(eL, LuaUI);
}

return origstartscript(thiz,rscript);
}
Loading

0 comments on commit 437ee11

Please sign in to comment.