HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Code Obfuscation - How to protect your map from pirates

09-20-2002, 02:31 AM#1
FM_TertiaryEye
Hey, i wanted to start this thread in order to provide people with the information necessary to obtain additional security when releasing their tediously created maps. Obfuscation means clouding or hiding, and when used with zephyrs brilliant map lock it also provides a helluva determent that will defeat all but the most determined thieves.

The purpose of obfuscation is to reduce the morale of the enemy (and people who mod your maps without your permission are indeed your enemy, worthy of bloody, screaming and, painful death by your machete you keep next to your computer... or.. ummm... well something like that) worldedit user who willfully wishes to take your design and exploit it by copying your map and triggers to give his sorry butt undue credit.

Accomplishing this task is tedious, and demanding, however it also guarantees that your map (at least not in its entirety) will not wind up in the hands of a 12 year old from phoenix who wants to run your dialog through a leet speek converter to impress his friends in middle school. Only the most bullheaded script kiddy will take the time necessary to dig through the great mess you can easily create with your code.

However you should know that obfuscation has one obvious side effect, and that is that your code is basically impossible to manage once you implement it to its fullest. You will find just changing simple things to be extremely difficult, so when you obfuscate your code, make sure that it’s either a final release, or that you only obfuscate a copy of your map. If you can easily change your obfuscated code, then so can your enemy.

Now here is where we begin:

1) Before you begin

Ensure that you are now ready to destroy all semblance of order within your map! You should now have a copy of it saved somewhere, for the love of god make sure that you have a clean spare copy! I don’t want to be responsible for any legit mappers injuring their own maps!

2) Obfuscating Triggers and Variables

Now chaos takes over! Start with your variables! Rename every last variable and trigger in your map to a random combination of consonants and vowels, numbers and a liberal use of the underscore.

Make these variables and triggers as long as humanly possible, just in case the enemy tries to copy down your variables on the off chance that he actually discovers the meaning of one. The longer your variables are, the worse it will be for the invader to copy them down.

Remove all categories of triggers, lump every trigger into one category by dragging them to one of them. Now as for naming: A good convention to follow is to name your variables in a very similar fashion for instance....

x12_gl_8cg_oh_ij__pcn3bq_tt1_o
x12_gl_8cg_oh_ij_ppcn3bq_tt1_o

....is a fairly nasty combination, without looking at it closely its not easy to tell the difference.

Now a smart invader might work around this and god forbid, discover the intention of your variable by using a text editor to search around and find the locations in which that symbol was used. This is where you pull out the simple but nasty letter naming convention, as shown in this paragraph from how to write unmaintainable code.

Single Letter Variable Names: If you call your variables a, b, c, then it will be impossible to search for instances of them using a simple text editor. Further, nobody will be able to guess what they are for. (Canadian Mind Products, 2002 Names, Tip#3).

3) Dummy Variables

Now once you have made your variables an impediment to understanding, you make about 20 more of them! A good rule for dummy variables is to have over 5 times the amount that you do of variables you actually use (hehe). Warcraft is a big boy, it can take the extra data ;) Be sure to follow the exact same naming conventions for your standard variables, and to also have them express a similar ratio of data types to your used variables. Someone would get suspicious if you had 50 region variables and only one region on the map.

4) Dummy Paths and multiplying your triggers

How convincing would your dummy variables be if you didn’t use them? Have at least 3 extra events to parallel your legit events, do random things with your dummy variables, in fact you may even want to actually copy your standard events and act upon the variables with the new data!

But first split your triggers, there is a trigger limit! Be aware of the limit for the current version of the worldeditor! Ensure that you have as many triggers as possible and that each trigger doesn’t do a whole lot (wouldn’t want to clue someone into the value of a trigger would we :P)

Have your dummy triggers call your other dummy triggers and even your legit triggers! So if someone attempts to delete and execution path there’s a good chance that they might actually delete one necessary for the proper execution of your program!

Spend a lot of time on this, for this alone will ensure much disorder!

5) Map Bombing!

Ohhh yes, now we have the malicious of the malicious! Heres how to properly implement a map bomb.

A) Create a symbol of yourself as the true author of your map. This can be (like some brilliant mappers i have come to understand often use) a peasant with your name on it, or a blatantly spelled out group of circles of power! Be creative on this, have fun, (Im considering having a group of wisps come out and take the form of an F, and then move to the form of an M to represent my clan for my maps ;).

B) Create a trigger copy it, and blend it in well with your other triggers. When your identification be it a peon, a group of wisps, or whatever, is positioned in a place that it cant be seen immediately upon the start of the game (ie within the current screen bounds on map initialization of player x), then you have your choice of things to do.

C) Crash the game! This is done easily by setting a variable x (or “xPg2_dpe_gpi” hehe) to 0, and then performing ANY action where you need to get a player from index Such as Player – Set Property Player(x). Do this subtly, don’t blatantly set your variable to zero right in front of the action for the enemy to see, put it in a preceding trigger on your twisted loop of code ;)

So if you take one of your init triggers and place this condition within that trigger, it’s just a matter of waiting on another timed trigger or something else to happen before you end all the fun for Mr. Script Kiddy.

Your enemy will think that he messed up your map somehow while he was changing things. And this will be his downfall.

If you don’t wish to blatantly end the map, you can use alternative methods of destruction, for instance you can have a loop (or 5 haha) to calmly remind the users that “THIS MAP HAS BEEN WRONGFULLY MODIFIED, DOWNLOAD THE REAL VERSION AT: www.yourwebsite.com.”

The nag message will be just as bad as crashing the game, if not even worse, because it constantly advertises the author as a phony. If you use this approach make the message display about 10-15 minutes into the game on the off chance that the author will actually overlook it during testing and publish it flaws in all ;)

The third malicious act you may impart on your enemy can be described in just one line : For each (integer a) from 0 to x (where x is a variable that’s been carefully multiplied by a large number, lets say, oh 40-50 times) create x footmen for player 1 at position p.

Yes, my friends, you have guess right if you just realized that the preceding line will certainly make your perpetrator wish he hadn’t toyed with your hard-labored creation ;)

6) And now to top it all off!

Take every trigger, convert it to custom text, and paste it all in one trigger called DOEverything! Yes! Yes! It will work! Heres all you have to do… Each trigger has 2 functions, the trigger function which checks the conditions, and the triggeraction function which performs the actions if the conditions are true.

Now, as long as the function that calls triggeractions is AFTER the triggeractions function then you can put as many of them in one single trigger as you want! As long as you obey the rule that the triggeraction function should come after its associated trigger function, then you can do whatever you like to make your enemies life a living hell. ;)

DO NOT DELETE THE TRIGGERS YOU COPIED THE CUSTOM TEXT FROM!
I’m trying to find a way around this but for now, no trigger will work if you remove the trigger in the editor that you copied it from.

Now you are done!

[size=3]6) Some closing thoughts:[SIZE] One final tip, remember, this is not going to make your map completely undecipherable. But what it will do is make your enemies have to work to steal and change your map. And how is this effective? Because your enemies are LAZY! Why else would they steal your map? Make them work, and you will GREATLY reduce the chances of anyone stealing your map in its entirety.

Ethical Issues: Remember! You do not completely own your maps! They are created in blizzards scripting language with their map editing environment, you certainly can’t sell them. However, you DO have a right to protect all of your hard work, and no part of your license agreement with blizzard denies that!

Now this is not intended to prevent new users from learning things from your map, or legitimate people from extending your map with your permission! To do so you can just unlock your map, or send the questioning user an email with a description of how you solved a particular problem.

Liberal map creators might object to the concept of this article, and to you all I need to say is that you do not have to implement it ;). I will gladly divulge any solution to any problem I have solved in my current, and future maps. Id rather answer questions than find my beloved map one day on battlenet under the name of another author.

I’ve only been using this system for a couple of weeks now so if anyone has any other obfuscation ideas, then please feel free to post them here. Thank you for reading this article and I hope it was helpful.

Sincerely,
Jason F. Mclauchlin
FM_TertiaryEye

For an amusing read and more ideas, check out the article on how to write unmaintainable code at http://mindprod.com/unmain.html.
09-20-2002, 02:39 AM#2
Guest
At first I thought this was just something stupid, but right when I read "Becase they are LAZY" I realized this would work! Of course they are lazy! Lazier than crap! Nice suggestions there. Some are a little overboard, but others are good (like converting to custom txt)
09-20-2002, 02:46 AM#3
weaaddar
How exactly do you propose detecting if the map is stolen I have a few tricks of my own, (the music trick by zepir is currently one of the best so far).
09-20-2002, 02:47 AM#4
Guest
Quote:
Originally posted by weaaddar
How exactly do you propose detecting if the map is stolen I have a few tricks of my own, (the music trick by zepir is currently one of the best so far).

Music Trick?
Eh? Enlighten me please.
09-20-2002, 04:41 AM#5
Guest
well let me guess .
after the start of the game , play a sound and say ur name ?? =)

well i think the converting to custom text is the best way =) .

how many can use custom text here ?? well in bnet i bet there arent more than 1000 so you reduce the amount of ppl copying and editing ur map
then mess up the custom text =) add in some string to confuse the editor =)
those who just learn custom text like jass , may be confuse . therefore reducing the no. further =)

well then add in extra variable =) well using custom text dun need variable =) confusing huh ?? well thats the way it is

lastly add it sound that are funny and unit dun have a model .
you see , unit that dont have a model appear invisible , TOTALLY invisible in everywhere(game and WE) =). this mean that the person cannot noe where the unit is or watever =)
add a trig like jason check for that unit and den if that person deletes it , well firstly say " this map is FAKE and i mean FAKE AND TOTALLY FAKE"
den create 10000000000000 footman anywhere . well best way =)
to make it worse , do this several time in the game , once at the start , once at the middle or worse , do it when a quest is complete( or a level ) well. LAzy map stealer will stop . so that reducess to bout 100 left , who are more hardworkingg =)
well to the final movement =)

change the name of region your name like HNO3(1) HNO3(2) and all region is ur name. link the checking tri to important triger =) and lastly protect it =)

protected map are hard to open but its possible wif experience ppl who program..

now who fit this description

able to open protected map
hardworking enuf to check every trigger and region
able to use Jass and other programming
Lazy enuf to make their map


well if any1 fix into this description , pls reply =)
09-20-2002, 02:36 PM#6
FM_TertiaryEye
You are right on the money guys!

This is not intended to make your map completely foolproof however it WILL dissuade all but the most dedicated of enemies.

Zephyrs music idea is perfect, it would be very easy to hide a trigger in obfuscated code to place a map bomb based upon music.

Some other suggestions i thought of to protect the map were using destructible doodads as tripwires for your mapbomb.

You can compare the locations of trees using the Destructible Doodad - position of destructable. And then use the x value of it or something. What you then do is go into the editor and enter the exact location of the tree somewhere esle. And if they dont match up, you just send everything to a wanton and random series of disaster s ;)

Oh, heres how to create a random disaster btw:
set IntegerRandomx = math.randomNumber between 0 and 10
if IntegerRandomx <= 2 then do "reference player index at 0"
if IntegerRandomx <= 4 and IntegerRandomx > 2 then do "run nag message trigger"
if IntegerRandomx <= 6 and IntegerRandomx > 4 then do "create 5 billion footmen hehe"

etc. if you have more than 10, just adjust your random choice accordingly (of coursse the smart way is to just have the math function pick a random number between 1 and the number of nasties you have. (duh jason :P)

FM_TertiaryEye
09-20-2002, 02:53 PM#7
Bl4ck1E
When u dislike people stealing your map, why not just protect the map? :o
09-20-2002, 03:49 PM#8
Guest
all protections can be cracked.
09-20-2002, 05:27 PM#9
FM_TertiaryEye
Thats exactly right, like i said at the very beginning of my post, code obfuscation should be used in CONJUNCTION with zephyrs awesome map locking system.
09-20-2002, 06:54 PM#10
weaaddar
um the trick is truly genious basically you add a sound to your map. (not import). Then you use the custom trigger to find out the length of the sound.

Now for the tirkk if the sound is still != to that value it is stolen which then you use your hidden trigger (zepir tought me how to hide code) and it will display a dialog of a crash (the less harsh way to do it) or set your player color to a non exsistant player number instant crash of war3.

Eh Honestly custom text isn't hard. Obsfucation is stupid. Protection is much beter.
09-20-2002, 07:16 PM#11
Athifos
Does anyone have a map with Zepir's music thing?...I wanna check it out
09-20-2002, 07:32 PM#12
weaaddar
Unfortuantly I already saved over my version PM zepir he has devised even beter tricks for his readonly protection..
09-20-2002, 07:41 PM#13
FM_TertiaryEye
Quote:

um the trick is truly genious basically you add a sound to your map. (not import). Then you use the custom trigger to find out the length of the sound.

Now for the tirkk if the sound is still != to that value it is stolen which then you use your hidden trigger (zepir tought me how to hide code) and it will display a dialog of a crash (the less harsh way to do it) or set your player color to a non exsistant player number instant crash of war3.

Eh Honestly custom text isn't hard. Obsfucation is stupid. Protection is much beter.


Dude, what you just described is obfuscation. You are hiding a trigger by adding it manually so the editor cant see it right? Thats obfuscation, hiding code! Thats the purpose of this entire tutorial, to hide code so you can implement your own map bombs, like i described earlier, creating a bazillion units, or referencing a player out of bounds of the player range, like i said earlier and you just said now.

The only difference in what we are saying is that you are talking about hiding triggers by manually adding them to the decompiled map files right? Well i dont know about you but im a student and I dont have time to dig through binary files with a hex editor manually adding triggers with no reference.

This tutorial is a way of hiding your own "map bomb" like you just described, without digging through a bunch of hexidecimal.

9 / 10's of protection is bluffing guys, and an obfuscated trigger archive is one helluva bluff, even if it doesnt contain a map bomb. Remember you can only deter the enemy, you cant prevent him from stealing your map, no matter how hard you try.

jason
09-20-2002, 07:54 PM#14
weaaddar
No I'm saying make the damn thing. But hide it by editing the wtg file and changing the identifier from User trigger to Map trigger (not shown in worldedit).

But the other things you suggested like naming variables is plain retarded if you really wanna make it hard do what I do just use the ones found in blizzard.j I only have 3 array variables in my bag demo I use 6 though..:)
Bullshit triggers are dumb. Any level of protection will stop joe smoe mapper right off the bat. Which is why I suggest my map protector over zepirs as currently it adds to much bulk to a map. Also Zepirs can be broken Just wait for the 7 million regions or what not to load and walah your editing the map (saving maybe a different story).

side note you'll be able to find variables if you named them a easily as Worldedit adds the udg identifier to variables.
09-20-2002, 09:28 PM#15
FM_TertiaryEye
First bro, you have to find a better argument to convince people of something besides saying things are "plain retarded".

Secondly, if you know how to hide a trigger, then its pretty much given that someone else will know how to unhide it, and they can do that a lot easier than they can pick though clouded code.

Thirdly, im pretty sure you didnt read this so i will point it out again. YOU DO NOT OBFUSCATE YOUR WORKING VERSION OF YOUR MAP! Ive made this very clear in section 1 of my post. So this means that you ARENT waiting for all of your extra triggers and regions and what not to load because you arent opening that map in the editor.

Fouth, Obfuscation is more than fun and paranioa, its viable in the real world. Compiled programs are not that protected, anyone can download a c++ decompiler, and short of having to determine the symbols, they can do what they need to discover how your program works. Obfuscators make that much more difficult by using overloaded operators and all sorts of long - lost arcane syntax.

Fifth, IM NOT SAYING PROTECTION IS BAD! Once again, i am not denying the value of protection i stack zephyrs map protection with my obfuscation, (in fact you gave me a great idea with the trigger hiding, thx), im just offering this as a supplement to protection.

Protections can be broken a lot faster than an obfuscated map can be understood. You just said so yourself that you can break zephyrs lock, and obviously your own. But how long will it take you to look at a completely garbled map and determine its meaning? How long would it take someone reading this post to unpack the wtg file and discover the trigger you were trying to hide?

Im not asking you to agree with me weaaddar, im just asking you to not call an idea "stupid" without a good reaon. But thank you for offering the trigger hiding technique, i believe it will be really valuable in the future.

jason