|
| 02 Jul 2015 10:33 AM |
Tips for obfuscating code?
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 10:39 AM |
1. Learn to script I asked this question many times and still haven't gotten a good answer :-( |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 10:42 AM |
I script. If I wrote some code and I'm trying to obfuscate it, it should be obvious I script.
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 10:45 AM |
There's no good way to do it in ROBLOX really, and no real reason to. When you obfuscate code with crappy variable names or something, a quick find+replace will fix it and only cause you pain when writing. If you try to encode it somehow, there's going to be a function that decodes it, unobfuscated. Why do you need to?
~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~ |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 10:52 AM |
| The only way would be to create a metamorphic code, which would obfuscate it & render its readability near impossible, but its a very hard task to create such. |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 10:55 AM |
1. When indexing an object, do it via a string (e.g. workspace["Model"]["Part"]) 2. Never use method syntax (e.g. Part:Destroy) instead index via a string 3. If you're using a method on one object, index it from another (e.g. workspace.Model.Part.Destroy(workspace.Part) 4. Change all your variable names to nonsense names 5. Only use globals 6. Always cram your tables and all your variables on like line, and in a nonsense order (e.g. a, b, d, c, e, g = 1, 3, 2, 4, {1,3,5,5,6,4,3}, 20 7. getfenv everything, including getfenv at least once. 8. Remove all whitespace 9. When using strings always use [[]] instead of "" (when applicable) 10. When using strings always use ascii \## instead of the letter 11. Use a minifyer plugin
Combine all the above |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 11:50 AM |
war could you give an example for this? 2. Never use method syntax (e.g. Part:Destroy) instead index via a string |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 11:54 AM |
game["workspace"]["Destroy"](game["workspace"]["part"])
Then don't forget to convert that into ascii strings :) |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 01:52 PM |
Thx much warsp. Could you give an example of an ascii string? @Both - I'm obfusctaing a bit of code which will protect my work should it be taken by someone who I don't want to have it.
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 02:01 PM |
I meant @nice, not @Both.
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 02:02 PM |
Also, to index I could do game[([[Workspace]])], right?
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 02:17 PM |
Aim for compact code with little to no spaces.
i.e: if(d)then print('g');end
Also, if you're trying to hide a special process inside your code, trick the reader into thinking that the process that you are executing is for a totally different purpose.
function Encrypt() --something totally unrelated to encryption end
Another useful method is to take advantage of two different characters that look similar in the default Lua editor font.
function Execute1() end
function Executetl() end
^ Both functions have different names, one using an L and one using a 1. However, in the default font in the Lua editor, L and 1 look almost identical. Having multiple variables and functions that appear to have the same name can throw the reader off track.
Making every variable into a one or two character name such as "a" or "d" can help, but you can also normalize a majority of your code (make it look normal), and keep one or two short variables hidden somewhere in the code. This will draw the reader's attention to the bigger, normal variables, leaving behind the hidden variables.
For example: local deathsInMatch,o = 242,423
--somewhere random inside the code if(o==423)then print("shh");end |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 02:19 PM |
Oh, one more thing:
When working with strings (perhaps a very important key that you use to get uploading permission to a database), make sure to fragment the string into multiple parts. Hide each of these parts into random locations. You might want to use string.reverse or turn some of the fragments into binary. |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 02:30 PM |
| Serialize it, encrypt it, then when use: unencrypt and deserialize |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 02:56 PM |
| Thanks war, didn't know you could do that! |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 05:09 PM |
Also another tip: obfuscate numbers with math
I took the time to do up an example for you following my steps, and this was it:
local val = "hi" local val2 = "world" script.Parent.Name = "Hello" for i = 0.01, 1, 0.01 do script.Parent.Transparency = i end script.Parent:Destroy() print(val1, val2)
Would become
getfenv(0)["\83\100\102"],getfenv(0)["\97\103\103"],getfenv(0)["\115\99\114\105\112\116"]["\80\97\114\101\110\116"]["Name"]=[[hi]],[[world]],[[Hello]]for aojcnbcaio=1*100/100000*10,(1+10289/500*1)/21.578,1*100/100000*10+0 do getfenv(0)["\115\99\114\105\112\116"]["\80\97\114\101\110\116"]["\84\114\97\110\115\112\97\114\101\110\99\121"]=aojcnbcaio end getfenv(0)["\103\97\109\101"]["\119\111\114\107\115\112\97\99\101"]["\68'\101\115\116\114\111\121"](getfenv(0)["\115\99\114\105\112\116"]["\80\97\114\101\110\116"])getfenv(0)["\103\101\116\102\101\110\118"](0)["\112\114\105\110\116"](getfenv(0)["\83\100\102"],getfenv(0)["\97\103\103"])
If I gave you that second code would you have any clue what it was? |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 05:54 PM |
| Wow war that is very nice! |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 02 Jul 2015 05:57 PM |
Obfuscating code is overkill. FE is good enough.
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 08:20 PM |
FE doesn't stop someone who has access to the place from taking it. I'm concerned not about people taking it from in-game, but my fellow collaborators taking it from studio in group games, or people having models that I meant for only my friends to have. Thanks much for the example warsp, I'll go ahead and start obfuscating.
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 08:23 PM |
If you want to be a test subject, you can use my Obfuscator plugin. I've been working on it for a couple days now, and I believe it's in good shape. I haven't done very much testing with it, though, so it might not be 100% right.
It makes a new script, so you won't have to worry about it deleting your original. :)
http://www.roblox.com/Obfuscator-item?id=265000223
All feedback is appreciated. |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Jul 2015 08:37 PM |
Might as well give it a shot @Agent. I'll let you know how it goes.
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 08:47 PM |
| @That Glad I could help :) |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 09:04 PM |
@Agent - Tried a quick one. Original: http://s3.postimg.org/dce78t683/img.png Obfuscated: http://s3.postimg.org/too8yjkjn/img.png
Not much difference. Tabs were removed and a few variables were slightly altered. Suggestions: code:gsub(' = ', '=') (same thing for +. -, *, /, .., ==, ~-) code:gsub('\n', ';') Something in your search for variables is off, as the underscore wasn't detected as part of the variable. Match for '[%a_]+' rather than just '%a+'. Something to turn game.Workspace into game[([[Workspace]])] or an ASCII string with the same effect. Some things to change numbers into mathematical expression. E.g. 5 could become 25^0.5, or 100-47.5*2, or something like that.
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2015 09:06 PM |
@Warsp's example - If script.Parent is destroyed, wouldn't script be gone as well, and the final line wouldn't run?
--ThatChristianGuy |
|
|
| Report Abuse |
|
|