teesquared / flasturbate

A SWF obfuscator.
GNU General Public License v3.0
28 stars 7 forks source link

Feature request: Include/Exclude wildcard #2

Closed vpmedia closed 2 months ago

vpmedia commented 9 years ago

Hi!

It would be useful to have some basic wildcard parsing using the include/exclude text files:

*Suffix -> Matches FooSuffix , BarSuffix ..

Prefix* -> Matches PrefixFoo , PrefixBar ..

I've checked the source code but I didn't found any trivial parts where I can insert this logic in..

Thanks!

teesquared commented 9 years ago

In the function isObfuscatable the checks "name in excludes" and "name in includes" are where a straight lookup is done. So you'd need to group expressions maybe into another list and run through each one to check for a match. That sounds like a useful feature.

vpmedia commented 9 years ago

Thanks for the pointer.. I've checked this last year - now that I've gave another shot it looks more clear to me : )

In case of someone is interested, I've made two tiny helper methods to collect exclude data from given classes:

private var result:Vector.<String> = new Vector.<String>();

public function doCollect():void {
    getVars(MyClass); // MyClass is serialized with JSON data, do not flasturbate..
    getConsts(MyConstClas); // Get consts from class and exclude them also..
    result.push("myExcludeVarName"); // Some special exception to exclude
    result.sort(Array.CASEINSENSITIVE);
    trace(result.toString().split(",").join("\n"));
}

private function getVars(c:Class):void {
    var description:XML = describeType(c);
    var list:XMLList = description..variable;
    for each(var variable:XML in list) {
        var n:String = variable.@name;
        if (result.indexOf(n) == -1) {
            result.push(n);
        }
    }
}

private function getConsts(c:Class):void {
    var description:XML = describeType(c);
    var list:XMLList = description..constant;
    for each(var variable:XML in list) {
        var n:String = variable.@name;
        if (result.indexOf(n) == -1) {
            result.push(n);
        }
    }
}

The exclude list will be traced in flashlog..