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

 
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: 338

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

PostPosted: Fri Oct 07, 2016 4:15 pm    Post subject: Hiding your script with encodeFunction/decodeFunction 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.
Back to top
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 148

Joined: 07 Nov 2008
Posts: 4155
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
Newbie cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 16

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: 148

Joined: 07 Nov 2008
Posts: 4155
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
Newbie cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 16

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: 148

Joined: 07 Nov 2008
Posts: 4155
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










Edit:
for example, byte code of decoded function (last layer) from first post:


We still do not know the password. But, we can see there is stringToMD5String, it finds md5 sum of password, then it compares md5 with number (or numbers) converted to hex string (there is string.format and %X).

If equal: prints "yay!", if not: prints "Deleting c:\"


MD5Sum of password is fc0586aca6e42cffade83252446d0613

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

Joined: 24 Jun 2015
Posts: 16

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: 148

Joined: 07 Nov 2008
Posts: 4155
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
Newbie cheater
Reputation: 0

Joined: 24 Jun 2015
Posts: 16

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
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