View previous topic :: View next topic |
Author |
Message |
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Thu Jun 22, 2017 2:43 pm Post subject: encodeTable() |
|
|
More a proof of concept.
this code will add the encodeTable() function to CE which you can use to encode your lua scripts.
It currently doesn't encode auto assembler scripts, but I guess you could change aa scripts into {$lua} sections that just return the original aa script as a string. (perhaps add some encryption to it yourself or something)
Code: |
function getTableLuaScript()
local i
for i=1,getFormCount()-1 do
local f=getForm(i)
if (f.ClassName=='TfrmAutoInject') and (f.AssembleScreen.Highlighter.ClassName=='TSynLuaSyn') then
return f.AssembleScreen.Lines.Text
end
end
end
function setTableLuaScript(script)
local i
for i=1,getFormCount()-1 do
local f=getForm(i)
if (f.ClassName=='TfrmAutoInject') and (f.AssembleScreen.Highlighter.ClassName=='TSynLuaSyn') then
f.AssembleScreen.Lines.Text=script
end
end
end
function encodeLuaScript(script)
--converts the given script into lua bytecode and returns code you can use to execute it
local f,err=loadstring(script)
if f==nil then return script end --fail
return 'decodeFunction("'..encodeFunction(f)..'")()'
end
function encodeTable()
local originalscript=createStringlist()
originalscript.Text=getTableLuaScript()
local encodestart=0
if (originalscript.Count>=1) and (originalscript[0]=='--versioncheck--') then
--find the code after the versioncheck and encode that
local i
for i=1,originalscript.Count-1 do
if originalscript[i]=='--!versioncheck!--' then
encodestart=i+1
end
end
end
local toencode=createStringlist()
while originalscript.Count>encodestart do
toencode.add(originalscript[encodestart])
originalscript.delete(encodestart)
end
originalscript.add(encodeLuaScript(toencode.text))
local versioncheck
if encodestart==0 then
if cheatEngineIs64Bit() then
versioncheck=[[--versioncheck--
if cheatEngineIs64Bit()==false messageDialog("This script requires the 64-bit version of Cheat Engine", mtError, mbOK)
closeCE()
return
--!versioncheck!--
]]
else
versioncheck=[[--versioncheck--
if cheatEngineIs64Bit() messageDialog("This script requires the 32-bit version of Cheat Engine", mtError, mbOK)
closeCE()
return
--!versioncheck!--
]]
end
originalscript.insert(0,versioncheck)
end
setTableLuaScript(originalscript.text)
--scan through the memory records for scripts with {$LUA} and encode those blocks as well
local i
for i=0, AddressList.Count-1 do
if AddressList[i].Type==vtAutoAssembler then
local oldscript=createStringlist()
oldscript.Text=AddressList[i].Script
local newscript=createStringlist()
local tempscript=createStringlist()
local j
local inluasection=false
local currentluascript
for j=0, oldscript.Count-1 do
local ln=oldscript[j]:gsub("^%s*(.-)%s*$", "%1")
local lnl=ln:lower()
if inluasection==false then
newscript.add(ln)
if lnl=='{$lua}' then
--lua section
tempscript.clear()
inluasection=true
end
else
--inside a lua section
if (lnl=='{$asm}') or --{$asm} statement reached
(lnl=='[disable]') or --[disable] statement reached
(lnl=='[enable]') or --[enable] statement reached (for those bastards that put disable before enable)
(j==oldscript.Count-1) then --end of the script reached
--encode temp and write it to the new script
if (j==oldscript.Count-1) then
tempscript.add(ln)
end
newscript.add(encodeLuaScript(tempscript.text))
if (j<oldscript.Count-1) then
newscript.add(ln)
end
inluasection=false
else
--add this line to the tempscript
tempscript.add(ln)
end
end
end
AddressList[i].Script=newscript.Text
newscript.destroy()
oldscript.destroy()
tempscript.destroy()
end
end
end
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1587
|
Posted: Thu Jun 22, 2017 2:51 pm Post subject: |
|
|
is it for trainers? so no one de-compile your trainer and steal your script?
_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote: | i am a sweetheart. |
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
|
Posted: Thu Jun 22, 2017 2:57 pm Post subject: |
|
|
OldCheatEngineUser wrote: | is it for trainers? so no one de-compile your trainer and steal your script? |
It helps deter newbs from getting things easily, but since the decode function is needed to convert back, it is still fairly easy to get the encoded data back to its original form.
_________________
- Retired. |
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1587
|
Posted: Thu Jun 22, 2017 3:03 pm Post subject: |
|
|
atom0s wrote: | It helps deter newbs from getting things easily, but since the decode function is needed to convert back, it is still fairly easy to get the encoded data back to its original form. |
isnt possible to protect it with password? for decoding?
_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote: | i am a sweetheart. |
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Thu Jun 22, 2017 3:13 pm Post subject: |
|
|
the decoded data is in lua byteform (no text) , so will take a little more effort (you can not get it back to the original form)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
|
Posted: Thu Jun 22, 2017 3:59 pm Post subject: |
|
|
Dark Byte wrote: | the decoded data is in lua byteform (no text) , so will take a little more effort (you can not get it back to the original form) |
Decompilers exist for Lua's byte code.
_________________
- Retired. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Thu Jun 22, 2017 4:09 pm Post subject: |
|
|
sure, but comments will be gone, and it's still a bigger hurdle than someone just scanning for the xml header of the table
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Fri Jul 07, 2017 5:10 pm Post subject: |
|
|
you just run it before you save your table. It only protects lua scripts though, your asm scripts are still text
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
sxymac How do I cheat? Reputation: 0
Joined: 09 Mar 2016 Posts: 3
|
Posted: Wed Nov 01, 2017 6:01 pm Post subject: |
|
|
OldCheatEngineUser wrote: | is it for trainers? so no one de-compile your trainer and steal your script? |
You actually dont need to decompile the trainer to see the script, you can do a simple memory browse and see it fully.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Wed Nov 01, 2017 6:46 pm Post subject: |
|
|
Nope, the script will not be visible in memory
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
|