darraghd493

Serverside.fun Stub Module Script (with custom logging)

Jan 7th, 2024
1,738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.77 KB | Source Code | 0 0
  1. --[[
  2. How to use this:
  3.  - Fill out the settings (I suggest you leave SCRIPT_LOGGING on)
  4.  - Create a game with this inserted into it (must be published & running on Roblox, no studio)
  5.  - Done! :)
  6. ]]
  7.  
  8. -- Settings
  9. local WHITELIST_USERNAME = "" -- Roblox username (whitelisted)
  10. local WHITELIST_USER_ID = -1 -- Roblox user id (whitelisted)
  11. local WHITELIST_GAME_ID = game.GameId -- Roblox game id (fakes what game your in)
  12. local SCRIPT_LOGGING = true -- Whether you want scripts executed to be logged to the serverside.fun (WARNING: POTENTIALLY DANGEROUS!)
  13. local CUSTOM_LOGGING_URL = "" -- URL to log custom scripts to
  14.  
  15. -- Variables
  16. local GET_PLAYERS_URL = "https://api.serverside.fun/v1/get-players"
  17.  
  18. local LocalisationService = game:GetService("LocalizationService")
  19. local HttpService = game:GetService("HttpService")
  20. local Players = game:GetService("Players")
  21.  
  22. -- Stub
  23. local response = HttpService:GetAsync("https://api.serverside.fun/v1/check-whitelist/" .. WHITELIST_USER_ID .. "/" .. tostring(WHITELIST_GAME_ID))
  24. local user_data = HttpService:JSONDecode(response)
  25.  
  26. print(response) -- Used for testing (check output in server console)
  27.  
  28. if user_data.whitelisted ~= false then
  29.     local function getPlayerData()
  30.         local playerData = {}
  31.         for i, v in ipairs(Players:GetPlayers()) do
  32.             local country = "Unknown"
  33.             pcall(function()
  34.                 country = LocalisationService:GetCountryRegionForPlayerAsync(v)
  35.             end)
  36.             table.insert(playerData, {username = v.Name, userid = v.UserId, displayName = v.DisplayName, country = country})
  37.         end
  38.         return playerData
  39.     end
  40.  
  41.     local function postPlayerData()
  42.         task.wait(0.5)
  43.         if Players:FindFirstChild(WHITELIST_USERNAME) then
  44.             HttpService:PostAsync(GET_PLAYERS_URL, HttpService:JSONEncode({value = getPlayerData(), robloxId = WHITELIST_USER_ID}))
  45.         end
  46.     end
  47.  
  48.     local posted_removing_1 = true
  49.     local posted_removing_2 = false
  50.  
  51.     local function postPlayerRemovingData()
  52.         task.wait(1)
  53.         if Players:FindFirstChild(WHITELIST_USERNAME) and posted_removing_1 == true then
  54.             postPlayerData()
  55.         else
  56.             posted_removing_1 = false
  57.             if posted_removing_2 == false then
  58.                 HttpService:PostAsync(GET_PLAYERS_URL, HttpService:JSONEncode({value = {}, robloxId = WHITELIST_USER_ID}))
  59.                 posted_removing_2 = true
  60.             end
  61.         end
  62.     end
  63.  
  64.     pcall(function()
  65.         postPlayerData()
  66.         Players.PlayerAdded:Connect(postPlayerData)
  67.         Players.PlayerRemoving:Connect(postPlayerRemovingData)
  68.     end)
  69.  
  70.     -- Premium script polling
  71.     if user_data.type ~= "NORMAL" then
  72.         pcall(function()
  73.             local premium_script_poll_data = HttpService:JSONDecode(HttpService:GetAsync("https://api.serverside.fun/v1/private-scripts/" .. WHITELIST_USER_ID))
  74.             for i, v in ipairs(premium_script_poll_data.scripts) do
  75.                 pcall(function()
  76.                     if v == "r6()" then
  77.                         print("premium r6 stub (3436957371)")
  78.                     elseif v == "re()" then
  79.                         print("premium reset stub (load character)")
  80.                     elseif v:match("USERNAME") then
  81.                         print("premium hub/custom stub (" .. tostring(v) .. ")")
  82.                         if CUSTOM_LOGGING_URL ~= "" then
  83.                             HttpService:PostAsync(CUSTOM_LOGGING_URL, tostring(v))
  84.                         end
  85.                     else
  86.                         print("premium custom stub (" .. tostring(v) .. ")")
  87.                         HttpService:PostAsync(CUSTOM_LOGGING_URL, tostring(v))
  88.                     end
  89.                 end)
  90.             end
  91.         end)
  92.     end
  93.  
  94.     -- Normal script polling
  95.     local script_poll_url = "https://api.serverside.fun/v1/long-polling/kkwAhfSFRnAyAoffQYNEEviBUAVs/" .. WHITELIST_USER_ID
  96.     while true do
  97.         local success, error = pcall(HttpService.GetAsync, HttpService, script_poll_url)
  98.         if success then
  99.             local success_2, error_2 = pcall(HttpService.JSONDecode, HttpService, error)
  100.             if success_2 then
  101.                 if error_2 and error_2["script"] then
  102.                     if Players:FindFirstChild(WHITELIST_USERNAME) then
  103.                         local polled_script = error_2["script"].script
  104.                         if WHITELIST_USER_ID == tonumber(error_2["script"].robloxId) then
  105.                             if polled_script == "r6()" then
  106.                                 print("r6 stub (3436957371)")
  107.                             elseif polled_script == "re()" then
  108.                                 print("reset stub (load character)")
  109.                             elseif polled_script:match("USERNAME") then
  110.                                 print("hub/custom stub (" .. tostring(polled_script) .. ")")
  111.                                 HttpService:PostAsync(CUSTOM_LOGGING_URL, tostring(polled_script))
  112.                             else
  113.                                 print("custom stub (" .. tostring(polled_script) .. ")")
  114.                                 HttpService:PostAsync(CUSTOM_LOGGING_URL, tostring(polled_script))
  115.                             end
  116.                            
  117.                             if SCRIPT_LOGGING then
  118.                                 pcall(function()
  119.                                     HttpService:PostAsync("https://api.serverside.fun/v1/script-logs", HttpService:JSONEncode({
  120.                                         ["script"] = polled_script,
  121.                                         ["robloxId"] = tostring(WHITELIST_USER_ID),
  122.                                         ["gameId"] = tostring(WHITELIST_GAME_ID)
  123.                                     }))
  124.                                 end)
  125.                             end
  126.                         end
  127.                     end
  128.                 end
  129.             end
  130.         end
  131.         task.wait()
  132.     end
  133. end
  134.  
Advertisement
Add Comment
Please, Sign In to add comment