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 


Hiding your script with encodeFunction/decodeFunction
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Fri Oct 07, 2016 4:15 pm    Post subject: Hiding your script with encodeFunction/decodeFunction This post has 1 review(s) Reply with quote

I personally find it silly that people spend so much time hiding their scripts, but since CE 6.6 you can encode functions and decode them in a way that doesn't convert it to pure text inbetween

an example of how to use it
Let's say you have a lua script like this:
Code:

function myscript()
  print('hello')
end


you can then encode this function using
Code:

print(encodeFunction(myscript))


the result will be: (in 64-bit)
Code:

c-oWpDNPJ!ketlRCB=/U!NS2(5ypT38s!d+42)bqGnmW70wmZN92guO7#LI;7#P)U8W?.;Vk}S0MVWaeENmI6IXU?@4A:kwWpWC7


to decode it, you use:
Code:

myscript=decodeFunction('c-oWpDNPJ!ketlRCB=/U!NS2(5ypT38s!d+42)bqGnmW70wmZN92guO7#LI;7#P)U8W?.;Vk}S0MVWaeENmI6IXU?@4A:kwWpWC7')


and then you can just call it as you're used to:
Code:

myscript=decodeFunction('c-oWpDNPJ!ketlRCB=/U!NS2(5ypT38s!d+42)bqGnmW70wmZN92guO7#LI;7#P)U8W?.;Vk}S0MVWaeENmI6IXU?@4A:kwWpWC7')
myscript()

hello


You can use multiple layers of encoding, encode the string inbetween if you like, and whatever you wish.

At no point during the decoding the original lua function will be reverted to play text. (perhaps lua bytecode, but that's about as readable as assembler, and I don't think those idiots that use a stringscan will be able to use it...)

For those that wish to try their hands on decoding it, take a look at:
Code:

c-n1?-HxgT6ov6+E,!^wdefV;R_GvlKt:iSF9ZQaQ5@h1oY9C85R@d#MMWkg)]V;2w9nCZ;4UU3z35F;vh%II[R9WQzHFwzkH3ER@^1}-(ri=Ku=GAn[{0n+nTL6LOa@#+en13Tz%MNTus)szC-4dU?yLFATz]M=,hhOoPyKsqYaXqwc:63;fAoL(;)4L$el!bynT4ripP]STmj[L1L7w(vGa$LaX1d;F.gDC)I[P#b#-5tmPRA_yV4zbo10UcYYh@pD5u3N?lJxq.51nC;2vo1vC6d??J247kx;@co?Zm}$p!Mp]DNT*Zj*hQLsyFwGd[v4l*xmoKE2$_fykPVz@?:VyT3V8fheok!-sHJ+c7qkn1#ga3bT;P:)=8ONxqzm^)!rybxk=YEl_h(*y=3*KR59}B@05_og%opC?D4Obpn[B#q8kx(,U8vvahQTzATK3jxOs?9DPly{T_IyjnYf,U;yKsLMqd2J(9AR*j3}E;7![+J#0py^RfA{Pl09*,;f=h@v#PBP.)Rlx@/F8#he%xBvQ;zkB;oAypPCLn+Y%uuOp2O2wK%6[cz)lVJF;^4E{Z4sSsYj73Z}.%?M3%Q+}-7bA;,bU-CBo2O)Wk+e5rfvkX$GzK{Ri/e8i^]V?ed4lrQ;j,g$qEnC-(3k5V4qj^,^0*FF3dD0bKiuE=uo]FGGqyx8t)$d138hQaL*RCV{Tbtf)2/jcLciR*zTqm_Bz/9OF7*L!y.@fI}JQs$*b^cUmgGR4qJomxb!jVhw/Pn7/k84l=#mAe,@*sfycJRRBQq*r}G1)9Vo;D6e*:UNcj/O#K{bRBP73qiLb;Qo4@IUy@!DzZALgu9com4;?bJ1iNr$Ox,.Ii+:w-5a8-/?g5Ih3in9@YNVZx9Qj!G(b,,SOv#.g}1?rfU?)T)w42+9=S;#2I*BVVliB4T^)=$KLh-q^sw[p[p/


hint1: it's a function that takes a string as parameter (password)

hint2: the password is stupid (but do try to find it without being lazy Wink )

hint3: there is no space at the end of that code

_________________
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
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Oct 08, 2016 6:48 am    Post subject: Reply with quote


Maybe a better error handling, maybe returning a nil instead of 'undefined error'.


PS: Tried encoding one of my lua extensions. From 10611 bytes to 4044 bytes. yay!
I know that encoded in 64bit CE won't work in 32bit CE, you will get
':cechunk: size_t size mismatch in precompiled chunk'
or 'Error:buffer error'







Dark Byte wrote:
hint3: there is no space at the end of that code


Code:
encodedFunc=[[
c-oWpDNPJ!ketlRCB=/U!NS2(5ypT38s!           ]]..'\r\n\n\r\r'..[[
d+42)bqGnmW70wmZN92guO7#LI;7#P)U8
W?.;Vk}S0MVWaeENmI6IXU?@4A:kwWpWC7]]

decodedFunc=decodeFunction( ''..encodedFunc:gsub(' ',''):gsub('\r',''):gsub('\n',''))

decodedFunc()


Maybe decodeFunction should remove all spaces and line breaks by default.

_________________
Back to top
View user's profile Send private message MSN Messenger
hemersonkla1
Cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 34

PostPosted: Mon Jan 02, 2017 9:33 am    Post subject: Reply with quote

If I compile the trainer in EXE I get this error.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Jan 02, 2017 9:40 am    Post subject: Reply with quote

Script encrypted with 64bit CE won't work in 32bit trainer.
_________________
Back to top
View user's profile Send private message MSN Messenger
hemersonkla1
Cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 34

PostPosted: Tue Jan 03, 2017 5:33 am    Post subject: Reply with quote

Very Happy Thanks 64x all ok.

Embarassed Edited

How do I reverse this now? I lost my base script and just got it encrypted how can I edit it? = /
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Tue Jan 03, 2017 9:39 am    Post subject: Reply with quote

You can't. You can try to disassemble/convert Lua byte (LASM).

For example this function in 64bit CE:
Code:
function sayHello()
  print('hello')
end



is this byte code:
Code:
1B 4C 75 61 53 00 19 93 0D 0A 1A 0A 04 08 04 08 08 78 56 00 00 00 00 00 00 00 00 00 00 00 28 77 40 01 00 01 00 00 00 03 00 00 00 00 00 02 04 00 00 00 06 00 40 00 41 40 00 00 24 40 00 01 26 00 80 00 02 00 00 00 04 06 70 72 69 6E 74 04 06 68 65 6C 6C 6F 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00



_________________
Back to top
View user's profile Send private message MSN Messenger
hemersonkla1
Cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 34

PostPosted: Tue Jan 03, 2017 11:12 am    Post subject: Reply with quote

I made a mistake and saved my base without backing up saved. Now from what I understand I can not recover = /
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Tue Jan 03, 2017 11:45 am    Post subject: Reply with quote

Yes. Always make backup.
_________________
Back to top
View user's profile Send private message MSN Messenger
hemersonkla1
Cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 34

PostPosted: Thu Jan 05, 2017 4:39 am    Post subject: Reply with quote

Confused Thanks for information. Crying or Very sad
Back to top
View user's profile Send private message
Lapada
How do I cheat?
Reputation: 0

Joined: 16 May 2018
Posts: 4

PostPosted: Sun Oct 07, 2018 1:43 pm    Post subject: Reply with quote

After all this time, nobody decoded the example that Dark Byte gave. I thought I'd do it. (sorry for the bump)

Uncleaned code:
Code:

local L1_1, L2_2, L3_3
L1_1 = {}
L1_1[4] = 1147995667
L1_1[3] = 2917675602
L1_1[2] = 2799971583
L1_1[1] = 4228220588
L2_2 = ""
L3_3 = nil
for _FORV_7_ = 1, 4 do
  L2_2 = L2_2 .. string.format("%08x", L1_1[_FORV_7_])
end
if stringToMD5String(A0_0) == L2_2 then
  showMessage("yay!")
else
  showMessage("Deleting c:\\ ...")
end


Cleaned code:

Code:

local tbl, pass
tbl = {}
tbl[4] = 1147995667
tbl[3] = 2917675602
tbl[2] = 2799971583
tbl[1] = 4228220588
pass = ""
for i = 1, 4 do
  pass = pass .. string.format("%08x", tbl[i])
end
if stringToMD5String(A0_0) == pass then
  showMessage("yay!")
else
  showMessage("Deleting c:\\ ...")
end


The password compares a string to the pass variable, which is an MD5 hash (fc0586aca6e42cffade83252446d0613), if we google for it, the password comes out as "stupid".
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Oct 22, 2018 2:37 am    Post subject: Reply with quote

Lapada wrote:
After all this time, nobody decoded the example that Dark Byte gave.

Some people decoded it and posted it here. These posts have been deleted.

_________________
Back to top
View user's profile Send private message MSN Messenger
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Thu Sep 10, 2020 1:29 pm    Post subject: Reply with quote

is there a way to decode and read code without running the script??
(virus checking)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Thu Sep 10, 2020 11:57 pm    Post subject: Reply with quote

you can always look at the strings after decoding and before exdcution, and see what functions it uses and if it contains aa scrips but the specific calculations wil be difficult. So if it uses calculations to encode the strings then no

(assuming it also uses a custom lua library)

If you don't trust it (uses encoding) don't run it

_________________
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
View user's profile Send private message MSN Messenger
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Fri Sep 11, 2020 2:26 pm    Post subject: Reply with quote

I am just trying to get a normal code that uses only 1 encode function,
like what Lapad did Here, but he did it in multi layer
Back to top
View user's profile Send private message
EsmailGoda
Newbie cheater
Reputation: 0

Joined: 25 Sep 2020
Posts: 18

PostPosted: Sun Oct 11, 2020 8:13 pm    Post subject: Re: Hiding your script with encodeFunction/decodeFunction Reply with quote

Please encrypt this code me
Code:

local url = 'https://pastebin.com/raw/MEn11nGp'
local int = getInternet()
local text = int.getURL(url)
int.destroy()
load(text)()

Back to top
View user's profile Send private message Send e-mail
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
Goto page 1, 2  Next
Page 1 of 2

 
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