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:

    Wise Draco comes, deep in the midnight roll
    Of black artillery; he comes, though late;
    In code corroborating Calvin’s creed
    And cynic tyrannies of honest kings;
    He comes, nor parlies; and the Town, redeemed,
    Gives thanks devout; nor, being thankful, heeds
    The grimy slur on the Republic’s faith implied,
    Which holds that Man is naturally good,
    And—more—is Nature’s Roman, never to be
    scourged.
    Herman Melville (1819–1891)

    A strong egoism is a protection against disease, but in the last resort we must begin to love in order that we may not fall ill, and must fall ill if, in consequence of frustration, we cannot love.
    Sigmund Freud (1856–1939)