? Obfuscation discussion (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
💀

Obfuscation discussion

1 2
  • #1 ✎ 86 Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Does anyone have experience with making an obfuscator? I'd like to try making one, because if successful, people would be able to compress and rename all variables and functions in their code automatically, and make it nearly impossible to understand This would be a really nice program for SmileBASIC My thoughts on how it might get done:
    1. Tokenize everything into an array
    2. Find the beginning and end of every scope (functions)
    3. In the global scope, detect every variable name and assign it a new name (a,b,c,...,aa,ab,ac,...,ba,bb,bc,...) (This will be done by converting from base-10 to base-26)
    4. Then go through each scope and continue finding variable names, but this time undo everything upon leaving the scope
    5. Keep track of every index of every variable name replacing at the end, or replace as we go?
    Should it be recursive? Does anybody have experience with this? Would anybody like to help? I'm new to this field, and see this as one of the necessary things SmileBASIC needs, but doesn't seem to have, and I've been waiting for someone else to make one for a few years now, but nobody seems to have Questions, comments, concerns? Comment below
    Posted
  • #2 ✎ 904 Y_ack Head Admin "but why?" Yeah, it would be a fun toy project for someone learning... but it almost sounds like you intend to use it in production. Posted
  • #3 ✎ 480 ToadIsTheBest Video Games I like to play video games! Hobbies Drawing I like to draw! Hobbies Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength
    "but why?" Yeah, it would be a fun toy project for someone learning... but it almost sounds like you intend to use it in production.
    yeah i agree. WHY, SIMEON WOULD YOU USE IT IN PRODUCTION
    Posted Edited by ToadIsTheBest
  • #4 ✎ 124 amihart
    "but why?" Yeah, it would be a fun toy project for someone learning... but it almost sounds like you intend to use it in production.
    yeah i agree. WHY, SIMEON WOULD YOU USE IT IN PRODUCTION
    My guess would be to release code that you don't want people to copy. Given SmileBASIC's policy it's not that surprising. Obfuscation with JavaScript is pretty popular as well. You could also build your obfuscator to heavily compress your code, which has its own benefits.
    Posted
  • #5 ✎ 904 Y_ack Head Admin
    "but why?" -snip-
    My guess would be to release code that you don't want people to copy. Given SmileBASIC's policy it's not that surprising. Obfuscation with JavaScript is pretty popular as well. You could also build your obfuscator to heavily compress your code, which has its own benefits.
    Is the answer I expect, but I was hoping Simeon would answer. "don't want people to copy" --again, why? Keep in mind this [more easily] deters modification than actual distribution. Edit: I'll point out again that I don't think this is a bad project for learning e.g. parsing or SmileBASIC's quirks, but actually intending to use it is another matter. Why do you want to protect code that you're not selling?
    Posted Edited by Y_ack
  • #6 ✎ 900 snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself One of the few things I can think of is minification, but that isn't quite the same thing. Posted
  • #7 ✎ 95 niconii Video Games I like to play video games! Hobbies Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Drawing I like to draw! Hobbies Personally, I think the openness of SmileBASIC as a platform is one of its greatest strengths. A big part of SmileBASIC is that people are able to learn from your code, take it and improve on it, or use it to make something new, and you can see that in SmileBoom's policies. From that point of view, I don't think SmileBASIC needs an obfuscator at all. On the contrary, I think it would ultimately be harmful. Posted
  • #8 ✎ 61 ninjagnu Lumage, How would this project not be a good one? There are many good reasons to do this one being to learn a bit about parsing and variable scopes. Posted
  • #9 ✎ 900 snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself
    Lumage, How would this project not be a good one? There are many good reasons to do this one being to learn a bit about parsing and variable scopes.
    Edit: I'll point out again that I don't think this is a bad project for learning e.g. parsing or SmileBASIC's quirks, but actually intending to use it is another matter. Why do you want to protect code that you're not selling?
    Posted
  • #10 ✎ 86 Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Okok, so, it could be harmful for SmileBASIC, if it gets used commonly The bad side
    1. SmileBASIC may be less beginner friendly
    2. Curious programmers can't be curious anymore
    On the other hand
    1. Automatic code minification
    2. Non-editable games to prevent cheating
    3. I get to learn how to parse better
    Posted
  • #11 ✎ 396 kenchic OSP Contest 1 Contest Participant I participated in the first SmileBASIC Source OSP Contest! Second Year My account is over 2 years old Website Good Page Hidden Achievements
    1. Non-editable games to prevent cheating
    I think that editing games is basically a right by now. The only people that would use the obfuscator would be people who want to protect their code— either arrogant beginners or arrogant experts. The problem with noobs obfuscating their code is that they often have unseen bugs that break gameplay like a minute in, while the problem with pros obfuscating their code is that they have things we can learn from, and they’re hiding it from us lowly plebeians.
    Posted
  • #12 ✎ 95 niconii Video Games I like to play video games! Hobbies Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Drawing I like to draw! Hobbies
    1. Automatic code minification
    Graphics size is bound to be an issue far sooner than code size, since a GRP file is 512 KB and the project upload size limit is only 4 MB (20 MB if you have a gold account). However, in the event code size still needs to be reduced, you could just compress the code rather than minify it. This has the benefit of being reversible, and may even result in a smaller file size than minification would, due to redundancy in things like keywords and repeated names.
    1. I get to learn how to parse better
    You don't have to publish the obfuscator or obfuscated projects to do that.
    Posted
  • #13 ✎ 86 Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Good points good points Posted
  • #14 ✎ 284 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength What's the difference between encrypting a project and obfuscating a project? Posted Edited by spaceturtles
  • #15 ✎ 421 MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Second Year My account is over 2 years old Website osu! Is Awesome! I love osu! Express Yourself
    What's the difference between encrypting a project and obfuscating a project?
    Encryption is a 2 way process. You encrypt your code to protect it from checks by SmileBOOM, and the user decrypts it before use. Obfuscation is a 1 way process. You obfuscate your code to protect it from modifications by making the code hard to follow but still valid, and the user runs it as is.
    Posted
  • #16 ✎ 172 MZ952 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Drawing I like to draw! Hobbies Reading I like to read books! Hobbies I was actually surprised to see some debate over the—er—ethics of such a program. Here are my thoughts. The program seems to utilize multiple functions. Miniaturization of the code, and confusion of the code. For the first function, I think a code miniaturizer would come useful to some people who want to cut their file sizes. A miniaturizer could do thinks like cut out comments, remove unnecessary spaces and indents, and condense function and variable names, perhaps even constants as well (ex. "0.0"->".", "10000000"->"1E7"). Users have the choice of making their code readable, and when it comes to this kind of open platform, we kind of have to accept that users will make responsible decisions when doing so. A code obfuscator would not break SmileBASIC, I doubt anyone but a few would use it anyway. When it comes to the confusion aspect of it's functionality, I have a couple ideas. If you decide you don't care about filesize, you could do more than miniaturizer on to confuse people. SmileBASIC likes to move the parsing cursor to the right and down, and that makes it easy for people to follow the code. But what if instead when the cursor reaches an endline, it doesn't move down, but to some random place in the code where the next corresponding line is. There would have to be a kind of GOTO @LOCATION token replacing the endline that would direct it to the next line of code. This could possibly be implemented using actual GOTO's, kind of like . . . @39 BEEP 34 [email protected] @67 SPDEF 0,0 [email protected] @254 X1=X0 [email protected] I'm not sure SmileBASIC would like this so much. Pretty sure it would break FOR and WHILE loops. DEF blocks would be handled internally. There might be other ways to handle it, especially for those loops. I don't have my 3ds atm, so I can't test it, but it's an idea. Developing a SmileBASIC parser is a good idea. If built into a multipurpose engine, it would have a variety of uses in programs like custom IDEs and whatnot. Posted
  • #17 ✎ 480 ToadIsTheBest Video Games I like to play video games! Hobbies Drawing I like to draw! Hobbies Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength
    -SNIP-Pretty sure it would break FOR and WHILE loops. -The legend of SNIP:ocarina of time-
    At least the REPEAT UNTIL loops are safe!
    Posted Edited by ToadIsTheBest
  • #18 ✎ 284 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength What about def loops? DEF A B END DEF B A END A Posted
  • #19 ✎ 1560 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website Code files are so tiny compared to GRPs that there's really no point in minifying them. A single GRP file is about 524 KB, and a code file of that size would need over 20 thousand lines of 20 characters each. Minifying the code might reduce the size to around 1/2 to 1/3, but there are better ways to reduce file size and it's also just annoying to anyone reading your code. Plus, it increases the risk that the original program might be lost, which has happened before with compiled lowerdash projects. And any argument about preventing people from stealing code is pretty much pointless because you're not making money off of it, so it really doesn't matter, as well as the fact that it's very easy to prove someone has stolen code. Posted
  • #20 ✎ 61 ninjagnu
    What about def loops? DEF A B END DEF B A END A
    That's just called recursion.
    Posted
1 2