Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


CE Lua + Cloud API: Remote Control Center

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
AylinCE
Grandmaster Cheater Supreme
Reputation: 36

Joined: 16 Feb 2017
Posts: 1511

PostPosted: Tue Jun 24, 2025 5:26 pm    Post subject: CE Lua + Cloud API: Remote Control Center Reply with quote

━━━━━━━━━━━━━━━━━━━━ ⚠️ Terms of Use & Disclaimer ⚠️ ━━━━━━━━━━━━━━━━━━━━

The codes, configurations, and explanations presented in this document are provided solely for educational and technical reference purposes. By using this system, the user is deemed to have read, understood, and accepted the following conditions:

The developer(s) of this script and the author of this documentation bear no responsibility for any consequences such as data loss, unauthorized use, functionality disruption, or unethical application arising from its use.

Integrating this code with Cheat Engine or related tools does not place any liability on the Cheat Engine developers, forums, or associated platforms.

Cheat Engine is merely a host application; the logic, server interactions, and registry operations described herein are the sole responsibility of the user.

Code samples may interact with third-party services (e.g., Google Apps Script, system-level registry entries, PowerShell commands). It is the user’s responsibility to assess the legality, privacy implications, and policy compliance of such integrations.

By using any part of this system, the user acknowledges and agrees to this disclaimer in full.

━━━━━━━━━━━━━━━━━━━━ ⚠️ Terms of Use & Disclaimer ⚠️ ━━━━━━━━━━━━━━━━━━━━




Modern Cheat Engine Trainers are no longer confined to static tables or locally triggered scripts.
This article introduces a dynamic system that allows CE Lua scripts to securely communicate with the cloud;
Enabling real-time registration, login verification, remote messaging, and form handling via Google Apps Script.

The system is flexible enough to function as a simple register-login utility, but scalable enough to grow into a full control hub:
From user tracking and chat push to remote script loading or cloud-triggered trainer features.
Whether you're building a public trainer with access tiers, or a private tool with tight validation, this infrastructure is designed to serve both.

Using a centralized structure (ce_cloud) within Lua and Google-hosted Apps Script endpoints, each feature of the system can be extended, replaced, or upgraded — without repackaging the trainer itself.

••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
🔧 What It Can Do (Current Functionalities)

    The current implementation already supports:

    User Registration with Validation

    Accepts nickname and password

    Checks if the user ID is authorized

    Prevents duplicate nickname or ID reuse

    Login Authentication

    Compares nickname + password combo

    Confirms registered status from cloud

    Greets user by name (via admin label from server)

••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
Cloud-Based Messaging

    Sends multi-line data to server with custom error/success messages

    Receives dynamic responses based on server logic

    Dynamic Error/Success Messaging

    Error and success texts fully customizable from CE side

    Embedded admin/user references in success message

    Google Apps Script Communication

    Secure POST calls from CE to Apps Script endpoint

    Uses plain text files stored in Google Drive as databases

    Parses line-separated user records (ID → Nick → Password)


••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

☁️ Cloud Session Management with Google Apps Script

    Registration code:


Code:
function doPost(e) {
  console.log(`[${new Date().toLocaleString()}] Incoming registration request...`);

  let responseStatus = "success";
  let responseMessage = "Registration successful.";

  try {
    const note = (e && e.parameter && e.parameter.note) ? e.parameter.note.trim() : null;
    if (!note) throw new Error("Missing 'note' parameter.");

    const lines = note.split('\n').map(l => l.trim());
    if (lines.length < 6) throw new Error("Expected 6 lines: ID, Nick, Password, unauthorizedMsg, nameUsedMsg, successMsg.");

    const [userId, nick, password, unauthorizedMsg, nameUsedMsg, successMsg] = lines;

    // Step 1: Check if userId exists in drive-usr.txt
    const usrFile = getOrCreateFile("drive-usr.txt");
    const usrLines = usrFile.getBlob().getDataAsString('utf8').split('\n').map(l => l.trim());

    if (!usrLines.includes(userId)) {
      responseStatus = "error";
      responseMessage = unauthorizedMsg;
      console.warn("Unauthorized ID:", userId);
    } else {
      // Get admin name from the line above the matched ID
      const userIndex = usrLines.indexOf(userId);
      const adminName = userIndex > 0 ? usrLines[userIndex - 1] : "(unknown)";

      // Step 2: Check if userId or nick already registered in drive-regs.txt
      const regFile = getOrCreateFile("drive-regs.txt");
      const regLines = regFile.getBlob().getDataAsString('utf8').split('\n').map(l => l.trim());

      let idExists = false;
      let nickExists = false;

      for (let i = 0; i < regLines.length - 2; i += 3) {
        const existingId = regLines[i];
        const existingNick = regLines[i + 1];
        if (existingId === userId) idExists = true;
        if (existingNick === nick) nickExists = true;
      }

      if (idExists) {
        responseStatus = "error";
        responseMessage = "This ID is already registered.";
        console.warn("Duplicate ID:", userId);
      } else if (nickExists) {
        responseStatus = "error";
        responseMessage = nameUsedMsg;
        console.warn("Nickname already used:", nick);
      } else {
        // Step 3: Proceed with registration
        const newEntry = `${userId}\n${nick}\n${password}`;
        const updatedContent = regLines.join('\n') + '\n' + newEntry;
        regFile.setContent(updatedContent);
        responseMessage = `${successMsg} @${adminName}@`;
        console.log("New registration saved:", newEntry);
      }
    }

  } catch (err) {
    responseStatus = "error";
    responseMessage = "Error: " + err.message;
    console.error("Exception caught:", err);
  }

  return ContentService.createTextOutput(JSON.stringify({
    status: responseStatus,
    message: responseMessage
  })).setMimeType(ContentService.MimeType.JSON);
}

// Utility function to get or create a file by name
function getOrCreateFile(fileName) {
  const files = DriveApp.getFilesByName(fileName);
  return files.hasNext() ? files.next() : DriveApp.createFile(fileName, "");
}



    Login code:


Code:
function doPost(e) {
  const note = (e && e.parameter && e.parameter.note) ? e.parameter.note.trim() : null;
  if (!note) return errorResponse("Veri eksik.");

  const lines = note.split('\n');
  if (lines.length < 5) return errorResponse("Geηersiz giriş formatı. 5 satır bekleniyor.");

  const [userId, username, password, errorMsg, successMsg] = lines.map(l => l.trim());

  // drive-regs.txt iηeriğini oku
  const regFile = getOrCreateFile("drive-regs.txt");
  const regLines = regFile.getBlob().getDataAsString('utf8').split('\n').map(l => l.trim());

  let loginSuccess = false;
  for (let i = 0; i < regLines.length - 2; i += 3) {
    if (
      regLines[i] === userId &&
      regLines[i + 1] === username &&
      regLines[i + 2] === password
    ) {
      loginSuccess = true;
      break;
    }
  }

  if (!loginSuccess) return errorResponse(errorMsg);

  // Başarılı giriş → admin adı alınacak
  let adminName = " ";
  const usrFile = getOrCreateFile("drive-usr.txt");
  const usrLines = usrFile.getBlob().getDataAsString('utf8').split('\n').map(l => l.trim());

  for (let i = 0; i < usrLines.length - 1; i++) {
    if (usrLines[i] === userId) {
      adminName = usrLines[i - 1];
      break;
    }
  }

  const messageWithAdmin = `${successMsg} @@${adminName}@@`;
  return ContentService.createTextOutput(JSON.stringify({ status: "success", message: messageWithAdmin }))
                       .setMimeType(ContentService.MimeType.JSON);
}

// Yardımcı hata yanıtı
function errorResponse(msg) {
  return ContentService.createTextOutput(JSON.stringify({ status: "error", message: msg }))
                       .setMimeType(ContentService.MimeType.JSON);
}

// Yardımcı: Dosya varsa getir, yoksa oluştur
function getOrCreateFile(name) {
  const files = DriveApp.getFilesByName(name);
  return files.hasNext() ? files.next() : DriveApp.createFile(name, "");
}

••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

How to create and use Google Apps Script:

( Note: I recommend that you start this topic with a new Google account, as some special permissions must be granted to interact with the code.)

    Start a Google Apps Script: https://script.google.com/home (Click on the New Project + icon.)
    Delete the "myFunction" function completely, clean the script and paste the new code.
    Click on "Untitled project", give it a new name, click "rename" and confirm.
    Click the "Deploy" button in the top right and select "New deployment."
    In the window that opens, click on the settings icon next to "Select type" and select "Web application".
    Add a new description and enter the name you gave the script.
    Then click the "Access to" box and select "Everyone" and click the "Deploy" button to confirm.


    Now, in the "Authorization" window, click the "Grant access" button and start the access grant procedure.
    In the login window that opens, select your new Google account and confirm.
    In the "Google hasn't verified this app" warning window, click "Advanced" and click where it starts with "Go to.."
    In the last window that opens, scroll down to the bottom and click the "Allow" button to complete the permission process.


Run the script once by clicking the "Run" icon and the code is ready to use.

If you did not receive the sharing link for the script at the end of the permission procedure, follow these steps:
Deploy and get the URL of the script:
    Click the "Deploy" button in the top right and select "New deployment."
    In the window that opens, click on the settings icon next to "Select type" and select "Web application".
    Add a new description and enter the name you gave the script.
    Then click the "Access to" box and select "Everyone" and click the "Deploy" button to confirm.
    In the window that opens, click on the "Copy" icon of the link under "Web application" and press the "Done" button to get the code usage link.


Note: For every change you make to the script, you need to re-approve it and get its new link.
To do this, repeat the "Deploy and get the URL of the script:" procedure.


••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

CE Lua Script-Trainer, usage and access:

🧱 Lua – ce_cloud Table Structure
Code:
--======================================================================--
--======================================================================--

ce_cloud = {
  -- ce_cloud identity
  name = "CE Cloud Server ",
  author = "AylinCE",
  version = "1.0.0",

-- User ID Genarator (Create-Save-Load):
function ce_cloud.generateKey(len)
local capital_letters = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
local low_letters = {"M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
local numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
math.randomseed(os.time())
local length, pass, choice = 10, "", 0
  for _ = 1, len do
      choice = math.random(1,3)
      if choice == 1 then
         pass = pass .. capital_letters[math.random(1,#capital_letters)] -- Low letters
      elseif choice == 2 then
         pass = pass .. low_letters[math.random(1,#low_letters)] -- Numbers
      else
         pass = pass .. numbers[math.random(1,#numbers)]
      end
  end
  return string.upper(pass)
end

function ce_cloud.getOrCreatePrivateKey(k,p,n)
  local regPath = "HKCU\\SOFTWARE\\"..p
  local regName = n
  local commandRead = 'reg query "'..regPath..'" /v '..regName
  local result = runCommand(commandRead)

  local key = result:match("REG_SZ%s+(.-)%s*$")
  if key and key ~= "" then
    return key
  end
  -- Key doesn't exist, create one
  local newKey = ce_cloud.generateKey(k)
  local commandWrite = 'reg add "'..regPath..'" /v '..regName..' /t REG_SZ /d "'..newKey..'" /f'
  runCommand(commandWrite)

  return newKey
end

function ce_cloud.getUserIdentifier()
  local tempFile = os.getenv("TEMP").."\\ce_idtmp.txt"
  local uuid = nil

  -- Try BIOS UUID first
  local ps1 = [[powershell -Command "(Get-WmiObject Win32_ComputerSystemProduct).UUID | Out-File -Encoding ASCII ']]..tempFile..[['"]]
  runCommand(ps1)

  local f = io.open(tempFile, "r")
  if f then
    local content = f:read("*a")
    f:close()
    uuid = content:match("(%w+%-%w+%-%w+%-%w+%-%w+)")
    os.remove(tempFile)
  end
  -- If BIOS UUID failed, try MachineGuid
  if not uuid then
    local ps2 = [[powershell -Command "(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Cryptography').MachineGuid | Out-File -Encoding ASCII ']]..tempFile..[['"]]
    runCommand(ps2)

    local f2 = io.open(tempFile, "r")
    if f2 then
      local content2 = f2:read("*a")
      f2:close()
      uuid = content2:match("[a-fA-F0-9%-]+")
      os.remove(tempFile)
    end
  end

  if uuid then
    local onlyDigits = uuid:gsub("%D", "")
    return onlyDigits
  else
    return nil -- no valid ID found
  end
end

--===================================================================--

  -- URLs
  endpoints = {
    register = "https://script.google.com/macros/s/Your_Script_ID/exec",
    login    = "https://script.google.com/macros/s/Your_Script_ID/exec",
  },

  -- UI Text Labels / Errors .. ("@" = "\n")
  messages = {
    unauthorized = "You are not an authorized user. @Please contact the admin!",
    nicknameUsed = "This nickname is already taken! @Please try again with a different nickname.",
    loginFailed  = "Wrong username or password!",
    successReg   = "Registration successful. Hello again:",
    successLogin = "Login successful. Welcome:",
  },

  -- Reusable send method
  postNote = function(url, payload)
    local internet = getInternet()
    local result = internet.postURL(url, "note="..payload)
    internet.Destroy()
    return result
  end,

  -- Response parser
  parseResponse = function(response)
    if response:match('"error"') or response:match("Kritik hatalar") then
      local err = response:match('message%"%:%"(.-)%"%}'):gsub("@", "\n")
      return false, err or "Unknown error"
    else
      local msg, usr = response:match('message%"%:%"(.-) @(.-)@')
      return true, (msg or ""), (usr or "")
    end
  end
}

--========================================================--
--========================================================--


••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
Usage: Get User ID.
(If it exists, it will bring it, if not, it will create and save it)
Edit the path and name and make it your own.
Code:
local rgpath = "ce_cloud"
local rgname = "UserKey"
local keylen = 10

function ce_cloud.userID()
local myKey = ce_cloud.getOrCreatePrivateKey(keylen,rgpath,rgname)
local id = ce_cloud.getUserIdentifier()
local newID = ""
  if id then
     newID = myKey.."-"..id
  end
return newID
end

print("User ID: "..ce_cloud.userID())


••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

🔄 Example Usage (Register)

Code:

-- example edit message (Language!):
local lang = 1
  if lang==1 then
     ce_cloud.messages.unauthorized = "You are not an authorized user. @Please contact the admin!"
  elseif lang==2 then
     ce_cloud.messages.unauthorized = [[Sie sind kein autorisierter Benutzer. @Bitte kontaktieren Sie den Administrator!]]
  elseif lang==3 then
     --- Italiano?
  end

local data = table.concat({
  userID,
  "@@"..nickname,
  password,
  ce_cloud.messages.unauthorized,
  ce_cloud.messages.nicknameUsed,
  ce_cloud.messages.successReg
}, "\n")

-- example edit:
ce_cloud.endpoints.register = [[Your_apps_register_script_URL]]
local response = ce_cloud.postNote(ce_cloud.endpoints.register, data)
local ok, msg, usr = ce_cloud.parseResponse(response)

if ok then
  showMessage(msg.."\n"..usr)
else
  showMessage("Error:\n"..msg)
end


••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

🧪 Example Usage (Login)

Code:
local data = table.concat({
  userID,
  "@@"..nickname,
  password,
  ce_cloud.messages.loginFailed,
  ce_cloud.messages.successLogin
}, "\n")

local response = ce_cloud.postNote(ce_cloud.endpoints.login, data)
local ok, msg, usr = ce_cloud.parseResponse(response)

if ok then
  showMessage(msg.."\n"..usr)
else
  showMessage("Error:\n"..msg)
end

••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

🚀 What It Can Be Expanded To

    This system is designed as a Swiss army knife (yes, properly this time! 😄) — and can evolve into a robust control hub:

    Per-user form customization Load different CE forms based on user ID or group.

    Token-based session auth Allow time-limited access to forms, scripts, or trainer features.

    Remote command execution Send commands from cloud to Trainer ("force reload", "disable feature", etc.).

    Dynamic chat or feedback logger Push comments/feedback directly to Google Docs or logs.

    Form update system Auto-load new CE forms from Apps Script based on version check.

    License verification or purchase validation Tie entries to activation codes, expiration dates, or license groups.

    Access tier system Allow different features depending on user’s assigned group.

    Modular endpoint design Add more routes like /send, /log, /getProfile etc.

    Encrypted loader with CE obfuscation Pull script chunks from server as encoded blobs and decode only on matching ID/token.


••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
Thank you to those who clicked the thumbs up icon under my profile picture and sent me reputation.
This is a completely free interaction.

Until I see you in another crazier article and line of code, enjoy it! Wink
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites