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:

    Many people will say to working mothers, in effect, “I don’t think you can have it all.” The phrase for “have it all” is code for “have your cake and eat it too.” What these people really mean is that achievement in the workplace has always come at a price—usually a significant personal price; conversely, women who stayed home with their children were seen as having sacrificed a great deal of their own ambition for their families.
    Anne C. Weisberg (20th century)

    The best protection parents can have against the nightmare of a daycare arrangement where someone might hurt their child is to choose a place that encourages parents to drop in at any time and that facilitates communication among parents using the program. If parents are free to drop in and if they exercise this right, it is not likely that adults in that place are behaving in ways that harm children.
    Gwen Morgan (20th century)