How to make remote code execution

BEFORE REPLICATING THIS TUTORIAL MAKE SURE HTTPSERVICE IS ENABLED ON YOUR GAME

Hello,

I have just made a crude way of remotely executing code from a third party. And unlike others who found out how to do this, I am deciding to show the world. Hope you find it useful! :wink:

So, what is this all about then?

Well, remote code execution is like executing code from a third-party/website. This can be useful when you want to for example kick a player without being in-game, running commands in all servers without remote events, messing around just for the fun of it, and MUCH MUCH more.

Understanding how this works

Most methods of remote code execution use HTTPService, and mine does too. This is due to HTTP service being the best and pretty much the only way to access data outside of Roblox. You need either your own website or a GitHub project. Due to this using .json files.

Let's get to coding!

First of all, make sure the Lua code is in a SCRIPT, LocalScripts’ can’t interact with HTTPService.

Onto the JSON

The first thing you want to do is create a new file in your GitHub project/website called script.json.
Then in your script.json file, you should put something like this:

{"scriptinfo":[{"script":"script here"}]}

Make sure you put your script inside of the “script here” part. And also make sure to replace any quotes with ‘’ inside of your script. You can save the .json file and change it at any time, it will update.
This is my script:

{"scriptinfo":[{"script":"print('Works!')"}]}

LUA

Ok so, now let’s get onto the Lua part.

As mentioned before, put this inside of a SCRIPT.

Last = ""
	while wait() do
	local data = game:GetService("HttpService"):JSONDecode(game:GetService("HttpService"):GetAsync("YOURPROJECT-OR-WEBSITE/script.json"))
local scriptinfo = data.scriptinfo[1].script
if scriptinfo == Last then
else
       require(6148031666)(scriptinfo)()
     end
Last = scriptinfo
end

Basically, that gets the script from the website and makes decodes it into something Roblox Lua can understand. And the last part is just so the script doesn’t spam too much. The require(6144721384) part is what actually EXECUTES the script.

Summary

I know this tutorial may not make very much sense to some, but this is my first one lol. But if you did follow it correctly then, good for you! You just made remote code execution.

2 Likes

(Sorry if I forgot to mention, but this updates live.)‌‌‌‌‌

I don’t understand the JSON code part. Could you provide a real example? Also, isn’t it better to use an event for listening to the website instead of an infinite while loop?

https://www.roblox.com/library/6148031666/execute

Looks like the model is owned by yourself, you should probably include its source if you want anyone to use it.

You should put the code in actual code Blocks for readability.

I use a while loop because it’s simpler and easier for people to understand, and also if you want an example of JSON, it’s on my website. https://mainframescripts.com/remote-execution/script.json (I don’t know why I bought a website just for remote execution lol) all you basically have to do is copy {“scriptinfo”:[{“script”:“script here”}]} and replace “script here” with the script you want to execute. Please contact me if you still do not understand.

1 Like

It’s actually a common module used to execute scripts NOT made by me, I just converted it into a require because previously you had to parent it to your script for it to work.