HTMLeando: para desarrolladores Web

Pregunta


¿Cómo desofuscar un código Javascript? 

Responder esta pregunta por maikel el 2009-02-06
El caso es que estoy estudiando algunos códigos JavaScript, o sea haciendo algo así como ingeniería inversa y algunos de ellos están ofuscados, es decir, no hay una nueva línea luego del ";" ni indentación alguna, es un paquete de código compacto . Pero entender algo así es muy complicado de interpretar y se me hace muy lento. ¿Conocen de alguna herramienta que me ayude a hacer el proceso inverso a la ofuscación?

Respuestas

Thumb_up
Thumb_down

0%
0%
super buenisimo, gracias...
por Anónimo el 2009-10-01

Thumb_up
Thumb_down

0%
0%
Embellecer código Javascript con Beautify en sección de herramientas.
http://www.htmleando.com/herramientas/embellecer-codigo-javascript
por dudin el 2010-02-01

Thumb_up
Thumb_down

0%
0%
He encontrado una herramienta llamada "Beautify Javascript" para desofuscar códigos Javascript que de verdad es hermosa. http://elfz.laacz.lv/beautify/ escrita por Einars Lielmanis. Por si fuera poco puedes tener tu propia herramienta sin necesidad de conexión, descargándola desde http://github.com/einars/js-beautify. Por otro lado encontré otra que permite también "embellecer" PHP, Java, C++, C, Perl, JavaScript, CSS http://prettyprinter.de Los pongo el siguiente ejemplo:
if(typeof SNAP_COM=="undefined"){SNAP_COM={}
}SNAP_COM.get_js_src=function(){var D,C,E=null;var B=/\/(snap_preview_anywhere|snap_shots).js/;var A=document.getElementsByTagName("script");C=A.length;for(D=0;D<C;D++){if(A[D].src.search(B)!=-1){if(!E||(E&&A[D].src.search(/plugin=1/))){E=A[D].src
}}}return E};SNAP_COM.timer_obj=function(){var A={events:{},on:false,logged:false,el:null,id:null,reset:function(){this.events={}},set_id:function(B){this.id=B},enabled:function(B){this.on=B?true:false
},mark:function(B){if(!this.on){return }this.events[B]=(new Date()).getTime()},sequence:function(){var E,B,H,F=[],D={};if(!this.on){return undefined}for(E in this.events){if(this.events.hasOwnProperty(E)){F.push(E)
}}var C=this.events;function G(J,I){return C[J]-C[I]}F.sort(G);H=this.events[F[0]];B=F.length;for(E=0;E<B;E++){D[F[E]]=(this.events[F[E]]-H)}return D},log:function(E){var D,I,H,C;if(!this.on||this.logged||!this.events.show){return 
}var F={mouseover:"a",mouseout:"b",show:"c",hide:"d",doubleclick_start:"e",doubleclick_end:"f",preview_start:"g",preview_end:"h",rss_check_start:"i",rss_check_end:"j",shot_iframe_start:"k",shot_iframe_end:"l",marea_start:"m",marea_end:"n",shotsense_start:"o",shotsense_end:"p",click:"q"};
var B=this.sequence();var G="";for(D in F){if(F.hasOwnProperty(D)&&B[D]!==undefined){G+=F[D]+B[D]}}H=E.cfg.prefix.image+"snip/tmr/"+G+"/"+this.id+"/"+E.cfg.key+"/"+E.dfs()+"/tmr";I="snap_com_shot_tmr_img";
C=document.getElementById(I);if(!C){C=document.createElement("img");C.id=I;C.style.position="absolute";C.style.visiblility="hidden";C.style.zIndex="0";C.src=H;E.div.main.insertBefore(C,null)}else{C.src=H
}this.logged=true}};return A};

Resultando:
if (typeof SNAP_COM == "undefined") {
    SNAP_COM = {}
}
SNAP_COM.get_js_src = function() {
    var D, C, E = null;
    var B = /\/(snap_preview_anywhere|snap_shots).js/;
    var A = document.getElementsByTagName("script");
    C = A.length;
    for (D = 0; D < C; D++) {
        if (A[D].src.search(B) != -1) {
            if (!E || (E && A[D].src.search(/plugin=1/))) {
                E = A[D].src
            }
        }
    }
    return E
};
SNAP_COM.timer_obj = function() {
    var A = {
        events: {},
        on: false,
        logged: false,
        el: null,
        id: null,
        reset: function() {
            this.events = {}
        },
        set_id: function(B) {
            this.id = B
        },
        enabled: function(B) {
            this.on = B ? true: false
        },
        mark: function(B) {
            if (!this.on) {
                return
            }
            this.events[B] = (new Date()).getTime()
        },
        sequence: function() {
            var E, B, H, F = [],
            D = {};
            if (!this.on) {
                return undefined
            }
            for (E in this.events) {
                if (this.events.hasOwnProperty(E)) {
                    F.push(E)
                }
            }
            var C = this.events;
            function G(J, I) {
                return C[J] - C[I]
            }
            F.sort(G);
            H = this.events[F[0]];
            B = F.length;
            for (E = 0; E < B; E++) {
                D[F[E]] = (this.events[F[E]] - H)
            }
            return D
        },
        log: function(E) {
            var D, I, H, C;
            if (!this.on || this.logged || !this.events.show) {
                return
            }
            var F = {
                mouseover: "a",
                mouseout: "b",
                show: "c",
                hide: "d",
                doubleclick_start: "e",
                doubleclick_end: "f",
                preview_start: "g",
                preview_end: "h",
                rss_check_start: "i",
                rss_check_end: "j",
                shot_iframe_start: "k",
                shot_iframe_end: "l",
                marea_start: "m",
                marea_end: "n",
                shotsense_start: "o",
                shotsense_end: "p",
                click: "q"
            };
            var B = this.sequence();
            var G = "";
            for (D in F) {
                if (F.hasOwnProperty(D) && B[D] !== undefined) {
                    G += F[D] + B[D]
                }
            }
            H = E.cfg.prefix.image + "snip/tmr/" + G + "/" + this.id + "/" + E.cfg.key + "/" + E.dfs() + "/tmr";
            I = "snap_com_shot_tmr_img";
            C = document.getElementById(I);
            if (!C) {
                C = document.createElement("img");
                C.id = I;
                C.style.position = "absolute";
                C.style.visiblility = "hidden";
                C.style.zIndex = "0";
                C.src = H;
                E.div.main.insertBefore(C, null)
            } else {
                C.src = H
            }
            this.logged = true
        }
    };
    return A
};
por Anónimo el 2009-02-06

Thumb_up
Thumb_down

0%
0%
muy bueno esto del . http://elfz.laacz.lv/beautify/
gracias!!
por Anónimo el 2010-06-03

Thumb_up
Thumb_down

0%
0%
muy buen reporte.

este codigo me ayudo mucho, pude recuperar un codigo chido de una pagina.
por Anónimo el 2009-06-09

Anónimo:   Entrar


Consejo: Sé tan específico y descriptivo como puedas. Comparte tu experiencia personal o tus conocimientos.
Puedes investigar para completar tu respuesta.

Puedes poner directamente trozos de código usando las etiquetas [code=php] y [/code] o incrustar desde Snipplr.com [snippet=id_snippet]

Compartir: WebeameMeneame Delicious Digg

Preguntas relacionadas