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:

    Faultless honesty is a sine qua non of business life. Not alone the honesty according to the moral code and the Bible. When I speak of honesty I refer to the small, hidden, evasive meannesses of our natures. I speak of the honesty of ourselves to ourselves.
    Alice Foote MacDougall (1867–1945)

    Freedom of religion, freedom of the press, and freedom of person under the protection of habeas corpus, and trial by juries impartially selected. These principles form the bright constellation which has gone before us, and guided our steps through an age of revolution and reformation.
    Thomas Jefferson (1743–1826)