ActionScript - Code Protection

Code Protection

As with all intermediate language compiled code such as Flash and Microsoft .NET, once an SWF file is saved locally, it can be decompiled into its source code and assets. Some decompilers are capable of nearly full reconstruction of the original source file, down to the actual code that was used during creation (although results vary on a case-by-case basis).

In opposition to the decompilers, ActionScript obfuscators have been introduced to solve this problem, which transform code into a form that breaks decompiler output while preserving the functionality and structure of the program. Higher-quality obfuscators implement lexical transformations such as identifier renaming, control flow transformation, and data abstraction transformation which collectively make it harder for decompilers to generate output likely to be useful to a human. Less robust obfuscators insert traps for decompilers. Such obfuscators either cause the decompiler software to crash unexpectedly or to generate unintelligible source code.

The following is an example of ActionScript 3.0 code generated by a decompiler program, before and after obfuscation.

Code before obfuscation:

private function getNeighbours(i:int, j:int):Array{ var a:Array = new Array; for (var k = 0; k < 8; k++){ var ni = i + int(neighbour_map); var nj = j + int(neighbour_map) ; if (ni < 0 || ni >= xsize || nj < 0 || nj >= ysize) continue; a.push(Cell(cells)); } return a; }

Code after obfuscation:

private function getNeighbours(_arg1:int, _arg2:int):Array{ var _local3:Array = -(((null - !NULL!) % ~(undefined))); var _local4:*; var _local5:*; var _local6:*; _local3 = new Array; _local4 = 0; for (;//unresolved jump, _arg2 < 8;_local4++) { _local5 = (_arg1 + int(!NULL!)); _local6 = (_arg2 + int(!NULL!)); if (true){ _arg1 = (((//unresolved nextvalue or nextname << !NULL!) + !NULL!) << undefined); _arg1 = (!(!NULL!) ^ !NULL!); (!NULL! instanceof !NULL!); var _local1 = (((!NULL! as !NULL!) + !NULL!) == this); if (!(!NULL! == !NULL!)){ -((true << !NULL!)).push(Cell(cells)); } } if (!true){ (_local6 < 0); (_local6 < 0); (_local5 < 0); } } return (_local3); }

Read more about this topic:  ActionScript

Famous quotes containing the words code and/or protection:

    Acknowledge your will and speak to us all, “This alone is what I will to be!” Hang your own penal code up above you: we want to be its enforcers!
    Friedrich Nietzsche (1844–1900)

    What is marriage, is marriage protection or religion, is marriage renunciation or abundance, is marriage a stepping-stone or an end. What is marriage.
    Gertrude Stein (1874–1946)