bvasiles / jsNaughty

JS reverse minifier based on statistical machine translation
21 stars 2 forks source link

Tool Should work successfully with different deobfuscators #2

Open caseycas opened 7 years ago

caseycas commented 7 years ago

Currently, we are using uglifyjs tool to build our corpus, but there are many other obfuscators people can use. If someone wants to test the web front end, then the most likely tool to use will be whatever interactive online tool comes up on google. While we should also handle as many obfuscators as possible, we can use this one as a test case: https://www.javascriptobfuscator.com/Javascript-Obfuscator.aspx

However, currently the tool is not renaming the variables correctly. I'm providing an example test case below:

var _0x2918=["\x53\x61\x79\x48\x65\x6C\x6C\x6F","\x47\x65\x74\x43\x6F\x75\x6E\x74","\x4D\x65\x73\x73\x61\x67\x65\x20\x3A\x20","\x59\x6F\x75\x20\x61\x72\x65\x20\x77\x65\x6C\x63\x6F\x6D\x65\x2E"];function NewObject(_0x6542x2){var _0x6542x3=0;this[_0x2918[0]]= function(_0x6542x4){_0x6542x3++;alert(_0x6542x2+ _0x6542x4)};this[_0x2918[1]]= function(){return _0x6542x3}}var obj= new NewObject(_0x2918[2]);obj.SayHello(_0x2918[3])

and the original code:


function NewObject(prefix)
{
    var count=0;
    this.SayHello=function(msg)
    {
          count++;
          alert(prefix+msg);
    }
    this.GetCount=function()
    {
          return count;
    }
}
var obj=new NewObject("Message : ");
obj.SayHello("You are welcome.");

Whereas the webtool currently outputs:


Total Process Time: 1.46080899239
Preprocess Time: 1.09557294846
Rename Time (Subset of Preprocess): 0.524235963821
Moses Time: 0.0865499973297
Postprocess Time: 0.276820898056
var _0x2918 = [ "SayHello", "GetCount", "Message : ", "You are welcome." ];

function NewObject(_0x6542x2) {
    var _0x6542x3 = 0;
    this[_0x2918[0]] = function(_0x6542x4) {
        _0x6542x3++;
        alert(_0x6542x2 + _0x6542x4);
    };
    this[_0x2918[1]] = function() {
        return _0x6542x3;
    };
}

var obj = new NewObject(_0x2918[2]);

obj.SayHello(_0x2918[3]);
dorian-marchal commented 5 years ago

Up