View Full Version : [Code] Camouflaging Lua Code
Diabolic
09-04-2013, 01:27 AM
It may be that someone wants to know how to do, here it is:
local script = string.dump(
function()
--Content
print("Camouflaging Done.")
end
)
buff=""
for v=1,string.len(script) do --Convert our string into a hex string.
buff=buff..'\\'..string.byte(script,v)
end
file=io.open('encrypted.txt','w') --Output our bytecode into ascii format to encrypted.txt
file:write(buff)
file:flush()
file:close()
Output of example:
\27\76\117\97\81\0\1\4\4\4\8\0\54\0\0\0\64\67\58\9 2\85\115\101\114\115\92\66\114\117\110\111\92\68\1 11\99\117\109\101\110\116\115\92\88\101\110\111\66 \111\116\92\83\99\114\105\112\116\115\92\101\110\9 9\114\121\112\116\46\108\117\97\0\2\0\0\0\5\0\0\0\ 0\0\0\2\4\0\0\0\5\0\0\0\65\64\0\0\28\64\0\1\30\0\1 28\0\2\0\0\0\4\6\0\0\0\112\114\105\110\116\0\4\19\ 0\0\0\67\97\109\111\117\102\108\97\103\105\110\103 \32\68\111\110\101\46\0\0\0\0\0\4\0\0\0\4\0\0\0\4\ 0\0\0\4\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0
How to load this ?
Example:
local code = '\27\76\117\97\81\0\1\4\4\4\8\0\54\0\0\0\64\67\58\ 92\85\115\101\114\115\92\66\114\117\110\111\92\68\ 111\99\117\109\101\110\116\115\92\88\101\110\111\6 6\111\116\92\83\99\114\105\112\116\115\92\101\110\ 99\114\121\112\116\46\108\117\97\0\2\0\0\0\5\0\0\0 \0\0\0\2\4\0\0\0\5\0\0\0\65\64\0\0\28\64\0\1\30\0\ 128\0\2\0\0\0\4\6\0\0\0\112\114\105\110\116\0\4\19 \0\0\0\67\97\109\111\117\102\108\97\103\105\110\10 3\32\68\111\110\101\46\0\0\0\0\0\4\0\0\0\4\0\0\0\4 \0\0\0\4\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0'
loadstring(code) ()
If anyone has any other way to do this and want to share with people, feel free :)
Att,
Diabolic
DarkstaR
09-04-2013, 01:05 PM
It's actually called "obfuscation". Also, anyone can replace the loadstring function with a function that will print out the raw code. It's a nice first step but you can take it much further by using obfuscation around the loader code as well, in ways other than bytecode generation.
Diabolic
09-04-2013, 03:52 PM
It's actually called "obfuscation". Also, anyone can replace the loadstring function with a function that will print out the raw code. It's a nice first step but you can take it much further by using obfuscation around the loader code as well, in ways other than bytecode generation.
You have any example to help ?
I only managed to get up this.
Tripkip
09-04-2013, 04:50 PM
Him putting in here how to do encode would be pretty much equal to explaining people how te decode it.
DarkstaR
09-04-2013, 05:16 PM
You have any example to help ?
I only managed to get up this.
Creativity and understanding of the language constructs.
Diabolic
09-04-2013, 08:27 PM
Him putting in here how to do encode would be pretty much equal to explaining people how te decode it.
to encode is not the same thing of decode
Creativity and understanding of the language constructs.
Ok, thank you bro :)
It's interesting. Thx mate
Syntax
09-04-2013, 11:58 PM
to encode is not the same thing of decode
Ok, thank you bro :)
1) You're not encoding. You're not even encrypting. You are obfuscating.
2) If you know the way you are obfuscating, you know how to de-obfuscate.
It's security through obscurity.
Ropiderz
09-05-2013, 01:02 AM
1) You're not encoding. You're not even encrypting. You are obfuscating.
2) If you know the way you are obfuscating, you know how to de-obfuscate.
It's security through obscurity.
I'm not an expert on it, so can I use the SciTE compiler like a method to encrypt my code ?
For example my lib looks like this when I use compile function:
http://i.imgur.com/wQ71xr7.png
But still can be loaded.
bum136
02-14-2014, 02:47 PM
And how to decrypt this code now?
Anyways, I think this doesn't really help the community. I always like to edit/change existing scripts to my needs. Adjusting the waits for the npc chats, using another dp spot sometimes when it has the old depositer, updating stuff and so on. Or I copy & learn from existing "hard parts" like going through tp's, using levers or anything else special. People can learn by looking on the code. This "obfuscation" which now some scripters use makes that impossible...
EverlasteR
05-31-2014, 04:11 PM
Could someone explain what should I put in these:
buff=""
for v=1,string.len(script) do --Convert our string into a hex string.
file=io.open('encrypted.txt','w') --Output our bytecode into ascii format to encrypted.txt
I am new and I do not understand it at all ;/ The only thing that I understand is that I have to paste my script where is "Content"
Spectrus
05-31-2014, 06:05 PM
Could someone explain what should I put in these:
buff=""
for v=1,string.len(script) do --Convert our string into a hex string.
file=io.open('encrypted.txt','w') --Output our bytecode into ascii format to encrypted.txt
I am new and I do not understand it at all ;/ The only thing that I understand is that I have to paste my script where is "Content"
If you read this thread you'd know that this method of obfuscation is rather weak, but anyways, you don't need to do anything with that bit, just run the script and it will output your obfuscated string.
EverlasteR
05-31-2014, 06:25 PM
If you read this thread you'd know that this method of obfuscation is rather weak, but anyways, you don't need to do anything with that bit, just run the script and it will output your obfuscated string.
I have read the thread and many others about this but this is the only one that is working. If you don't mind I would love if you helped me with encrypting/obfuscating/coding my scripts.
xto94
06-13-2014, 01:22 PM
Same here, still can't get it working :( I can get the bytecode from working script, but code after obfuscating isn't working
I'm getting something like that:
Error: attempt to call method 'isOpen' (a nil value)
It's the error when i'm trying to obfuscate script without obfuscating locals, when the script is fully obfuscated it works well? Any tips? I want to leave locals visible to be able configuring the script like backpack names etc.
ppgab
06-13-2014, 03:42 PM
Same here, still can't get it working :( I can get the bytecode from working script, but code after obfuscating isn't working
I'm getting something like that:
Error: attempt to call method 'isOpen' (a nil value)
It's the error when i'm trying to obfuscate script without obfuscating locals, when the script is fully obfuscated it works well? Any tips? I want to leave locals visible to be able configuring the script like backpack names etc.
you cant have mixed script like that, doesnt work
have a separate file for configuration and just dofile it on the main obfuscated file
and why would you want to obfuscate your labels funcs? if it were your library of custom functions it would be reasonable , but...
Flummer
08-10-2014, 02:00 PM
Someone should write a guide for this =) step by step , i'm really intrested.
I got it, soon i guess. I filled buff = "" with buff = "Derp.lua" and ran the script. I got a txt file starting with derp.lua then alot of numbers.
What should i do with it then? =) loadstring? and i got another script with Code= in beginning how does it work ?
7878952
05-19-2020, 10:26 PM
well excuse me but i am having error when i run the lua on the xenobot after encoding, does anyone help me?
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.