De-obfuscate Javascript code to make it readable again

前端 未结 6 1590
小蘑菇
小蘑菇 2020-11-29 23:22

I hate to bring this here, while doing the learning of obfuscating the JS code, I encoded my code and then over wrote the orginal one without any backup :) Following is my o

相关标签:
6条回答
  • 2020-11-29 23:51

    Here's a new automated tool, JSNice, to try to deobfuscate/deminify it. The tool even tries to guess the variable names, which is unbelievably cool. (It mines Javascript on github for this purpose.)

    http://www.jsnice.org

    0 讨论(0)
  • 2020-11-29 23:51

    Probably tools get outdated as time goes by, but I found https://lelinhtinh.github.io/de4js/ and it works great.

    Your code becomes:

    function call_func(_0x41dcx2) {
        var _0x41dcx3 = eval('(' + _0x41dcx2 + ')');
        var _0x41dcx4 = document.createElement('div');
        var _0x41dcx5 = _0x41dcx3.id;
        var _0x41dcx6 = _0x41dcx3.Student_name;
        var _0x41dcx7 = _0x41dcx3.student_dob;
        var _0x41dcx8 = '<b>ID:</b>';
        _0x41dcx8 += '<a href="/learningyii/index.php?r=student/view&amp; id=' + _0x41dcx5 + '">' + _0x41dcx5 + '</a>';
        _0x41dcx8 += '<br/>';
        _0x41dcx8 += '<b>Student Name:</b>';
        _0x41dcx8 += _0x41dcx6;
        _0x41dcx8 += '<br/>';
        _0x41dcx8 += '<b>Student DOB:</b>';
        _0x41dcx8 += _0x41dcx7;
        _0x41dcx8 += '<br/>';
        _0x41dcx4.innerHTML = _0x41dcx8;
        _0x41dcx4.setAttribute('class', 'view');
        $('#StudentGridViewId').find('.items').prepend(_0x41dcx4);
    };
    

    Kudos to the dev!

    0 讨论(0)
  • 2020-11-30 00:01

    Here it is:

    function call_func(input) {
        var evaled = eval('(' + input + ')');
        var newDiv = document.createElement('div');
        var id = evaled.id;
        var name = evaled.Student_name;
        var dob = evaled.student_dob;
        var html = '<b>ID:</b>';
        html += '<a href="/learningyii/index.php?r=student/view&amp; id=' + id + '">' + id + '</a>';
        html += '<br/>';
        html += '<b>Student Name:</b>';
        html += name;
        html += '<br/>';
        html += '<b>Student DOB:</b>';
        html += dob;
        html += '<br/>';
        newDiv.innerHTML = html;
        newDiv.setAttribute('class', 'view');
        $('#StudentGridViewId').find('.items').prepend(newDiv);
    };
    
    0 讨论(0)
  • 2020-11-30 00:13

    I have tried both of online jsbeautifier(jsbeautifier, jsnice), these tools gave me beautiful js code,

    but couldn't copy for very large js (must be bug, when i copy, copied buffer contains only one character '-').

    I found that only working solution was prettyjs:

    http://www.thaoh.net/prettyjs/

    0 讨论(0)
  • Try this: http://jsbeautifier.org/

    I tested with your code and worked as good as possible. =D

    0 讨论(0)
  • 2020-11-30 00:16

    From the first link on google;

    function call_func(_0x41dcx2) {
     var _0x41dcx3 = eval('(' + _0x41dcx2 + ')');
     var _0x41dcx4 = document['createElement']('div');
     var _0x41dcx5 = _0x41dcx3['id'];
     var _0x41dcx6 = _0x41dcx3['Student_name'];
     var _0x41dcx7 = _0x41dcx3['student_dob'];
     var _0x41dcx8 = '<b>ID:</b>';
     _0x41dcx8 += '<a href="/learningyii/index.php?r=student/view&amp; id=' + _0x41dcx5 + '">' + _0x41dcx5 + '</a>';
     _0x41dcx8 += '<br/>';
     _0x41dcx8 += '<b>Student Name:</b>';
     _0x41dcx8 += _0x41dcx6;
     _0x41dcx8 += '<br/>';
     _0x41dcx8 += '<b>Student DOB:</b>';
     _0x41dcx8 += _0x41dcx7;
     _0x41dcx8 += '<br/>';
     _0x41dcx4['innerHTML'] = _0x41dcx8;
     _0x41dcx4['setAttribute']('class', 'view');
     $('#StudentGridViewId')['find']('.items')['prepend'](_0x41dcx4);
    };
    

    It won't get you all the way back to source, and that's not really possible, but it'll get you out of a hole.

    0 讨论(0)
提交回复
热议问题