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 


Code Protection Questions...

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Bit Byte
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 62

PostPosted: Thu Aug 24, 2023 4:54 am    Post subject: Code Protection Questions... Reply with quote

Say i have a bunch of different functions written out in the Cheat Table Lua Script for checkboxes, buttons, trackbar, timers, labels..etc etc for a trainer

First Question:
If i wanted to encode all of them at one go would I put all of them inside my made function and then put that function in encodeFunction()
How would that work for the trainer?

Second Question:
My trainer also has some tables, how would i encode/Obfuscate/hide them?

Third Question:
Is there any self destruct or self delete method that can be added?
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1522

PostPosted: Thu Aug 24, 2023 7:45 am    Post subject: Reply with quote

1) Yes all Trainer code can be executed in one function.
However, all references created within the main function cannot be used in encodings after the function end line.

The following failed attempt:
Code:
function allScript()
 function printer(s)
  s1=tonumber(s) +10
  return s1
 end
end

allScript()
aa = printer(25)
print(aa)


It could be:

Code:
local scriptTbl = {}
function allScript()
 function scriptTbl.printer(s)
  s1=tonumber(s) +10
  return s1
 end
end

allScript()
aa = scriptTbl.printer(25)
print(aa)


2) This is a topic that @atom0s constantly mentions and reminds.
Here is the final opinion:
"You can make the obfuscation code more complex, but not obscure enough.
Someone who knows what they're doing will decipher and read the entire code.
Because every hidden code contains the solution characters (Decode) to be read and applied by the Trainer.
If the Trainer can see it, the thief can too.
Hide more complex.
What is "enough" for you becomes "challenging" for the thief.

3) "item" = yourDeleteFunc
item.Destroy()
item=nil

_________________
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
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4703

PostPosted: Thu Aug 24, 2023 9:33 am    Post subject: Reply with quote

1: encodeFunction / decodeFunction:
https://forum.cheatengine.org/viewtopic.php?t=595142

One alternative is to try streams and table files. celua.txt:
Code:
CEForm Class: (Inheritance: Form->ScrollingWinControl->CustomControl->WinControl->Control->Component->Object)

createFormFromStream(stream): Returns the generated CEform
methods
  saveToStream(s): Saves the userdefined form to the given stream

...
Stream Class

methods
  copyFrom(stream, count) - Copies count bytes from the given stream to this stream

...

TableFile class (Inheritance: Object)
findTableFile(filename): Returns the TableFile class object for the saved file
createTableFile(filename, filepath OPTIONAL): TableFile - Add a new file to your table. If no filepath is specified, it will create a blank file. Otherwise, it will read the contents from disk.

properties
  Name: string
  Stream: MemoryStream

2: Several cheat tables, or do you mean Lua tables? You could just put everything in encodeFunction / decodeFunction.

3: You need to be more specific.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Bit Byte
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 62

PostPosted: Sat Aug 26, 2023 5:16 am    Post subject: Reply with quote

1. I was able to encodeFunction / decodeFunction:
https://forum.cheatengine.org/viewtopic.php?t=595142

I haven't understood how "streams and table files. celua.txt" working.

2.The tables like in ones I have circled in the image I have attached

3. Say I have distributed a Trainer.exe to some people A, B, C, D, E.
C has misused the Trainer.exe in regards to agreed usage agreement.
Now I will Ban/DeRegister him by removing his ID as shown by AylinCE here:
https://forum.cheatengine.org/viewtopic.php?t=613418.

I want the Trainer.exe I gave him also to self delete as like we press shift+delete to delete a file so that the file will no longer be on his HardDisk.
Is it possible to have this happen by code? The logic is something like this:

If UserId == Banned then
Shift+Delete->Trainer.exe
end



Tables.jpg
 Description:
 Filesize:  97.86 KB
 Viewed:  1767 Time(s)

Tables.jpg


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4703

PostPosted: Sat Aug 26, 2023 11:31 am    Post subject: Reply with quote

Those things you have circled are memory records, not tables. The table is the file you save to disk. It contains the address list / memory records, Lua script, and other bits of information that get saved.

"streams and table files" would be something like this:
(save your work and back it up before trying this)
Code:
function packageTable()
  local ms = createMemoryStream()
  saveTable(ms)
  ms.Position = 0
  -- maybe obfuscate table data here (e.g. stream cipher)

  local ss = createStringStream[[<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="45">
  <CheatEntries/>
  <UserdefinedSymbols/>
</CheatTable>
]]
  loadTable(ss, false)

  local tf = createTableFile'tabledata.bin'
  tf.Stream.copyFrom(ms, ms.Size)

  local enc_loadtable = encodeFunction(function()
    -- authenticate user here
    --assert(isUserAuthenticated, 'Not a valid user!')

    showMessage'User Authenticated!'

    local tf = assert(findTableFile'tabledata.bin')
    -- maybe deobfuscate table data here
    assert(loadTable(tf.Stream, false))
  end)
  local mr = AddressList.createMemoryRecord()
  mr.Type = vtAutoAssembler
  mr.Description = '<- Authenticate Trainer'
  mr.Script = ([[
[ENABLE]
{$lua}
if syntaxcheck then return end

decodeFunction'%s'()

{$asm}
[DISABLE]
]]):format(enc_loadtable)
end
This isn't complete. Anyone with half a brain can look at the CT and realize the real CT is in the table file. You should obfuscate the data somehow- e.g. a stream cipher.

As for that auto-delete... that's not going to work. You can't stop people from copying files or restoring files from a backup.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Bit Byte
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 62

PostPosted: Sat Aug 26, 2023 12:30 pm    Post subject: Reply with quote

I'll look into if I can get this method to work for me.

Copying or Restoring files from a backup should still end up in the copied or restored file still being auto deleted...
As the user id would be checked against file online for validity so
Original, copied or restored this logic would still be run inside the trainer code:
If UserId == Banned then
Shift+Delete->Trainer.exe
end
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4703

PostPosted: Sat Aug 26, 2023 1:29 pm    Post subject: Reply with quote

What's the point of deleting it? That won't help protect anything. All that does is have a chance at making it mildly annoying once. After it deletes itself, the user will restore a copy and analyze that using some other method. The user can analyze the table without needing to execute any code. Open up any .CT in a text editor and you'll see what I mean.

Regardless, I don't think there's any straightforward way of doing this. There's a `deleteFile` function that deletes a file, but there's no documented way of getting the path of the table that was last opened.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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 can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites