百度首页js - doranbai/Note GitHub Wiki

var _0xe7d2 = ["words", "sigBytes", "length", "stringify", "ceil", "slice", "random", "enc", "Hex", "join", "substr", "push", "fromCharCode", "charCodeAt", "Utf8", "Malformed UTF-8 data", "parse", "BufferedBlockAlgorithm", "_data", "_nDataBytes", "concat", "blockSize", "max", "_minBufferSize", "min", "_doProcessBlock", "splice", "clone", "Hasher", "cfg", "reset", "_append", "_doFinalize", "finalize", "HMAC", "algo", "Cipher", "WordArray", "EvpKDF", "_ENC_XFORM_MODE", "_DEC_XFORM_MODE", "_xformMode", "_key", "_doReset", "_process", "encrypt", "decrypt", "flush", "mode", "BlockCipherMode", "Encryptor", "Decryptor", "_cipher", "_iv", "CBC", "encryptBlock", "_prevBlock", "pad", "Pkcs7", "BlockCipher", "createEncryptor", "createDecryptor", "_mode", "__creator", "unpad", "CipherParams", "formatter", "format", "ciphertext", "_parse", "kdf", "OpenSSL", "PasswordBasedCipher", "ivSize", "key", "execute", "keySize", "salt", "MD5", "hasher", "update", "compute", "Base64", "_map", "clamp", "_reverseMap", "charAt", "indexOf", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", "abs", "sin", "_hash", "floor", "HmacMD5", "_createHmacHelper", "Word", "high", "low", "SHA1", "_createHelper", "HmacSHA1", "_iKey", "_hasher", "_oKey", "0123456789abcdef", "sqrt", "SHA256", "HmacSHA256", "x64", "toX32", "SHA512", "HmacSHA512", "moonshad5moonsh2", "moonshad3moonsh0", "moonshad8moonsh6", "moonshad0moonsh1", "moonshad1moonsh9", "OOOO0O", "O0000O", "O00O0O", "OO0OOO", "screen", "width", "height", "alg", "version", "round", "getTime", "sig", "traceid", "callback", "elapsed", "shaOne", "encryption", "sort", "split", "substring", "ECB", "byteOffset", "byteLength", "Utf16BE", "Utf16LE", "Utf16", "SHA224", "SHA384", "HmacSHA384", "SHA3", "_state", "outputLength", "HmacSHA3", "RIPEMD160", "HmacRIPEMD160", "iterations", "PBKDF2", "CFB", "CTR", "_counter", "OFB", "_keystream", "decryptBlock", "AnsiX923", "Ansix923", "Iso10126", "Iso97971", "ZeroPadding", "NoPadding", "AES", "_nRounds", "_keyPriorReset", "_keySchedule", "_invKeySchedule", "_doCryptBlock", "DES", "_subKeys", "_invSubKeys", "_lBlock", "_rBlock", "TripleDES", "_des2", "_des3", "_des1", "StreamCipher", "RC4", "drop", "RC4Drop", "Rabbit", "RabbitLegacy", "location", "protocol", "//nsclick.baidu.com/v.gif?", "pid=111&type=1023&v=", "&data_source=fe", "&extrajson=", "&monitorType=moonshadErrors", "{eventType:na-moonshad-error}", "&auto_en=na-monitor", "onload", "onerror", "src", "exports", "defineProperty", "undefined", "toStringTag", "Module", "__esModule", "object", "create", "default", "string", "bind", "prototype", "hasOwnProperty", "call", "lib", "Base", "mixIn", "init", "$super", "apply", "toString", "extend"];
!function(c) {
    !function(x) {
        for (; --x; )
            c.push(c.shift())
    }(421)
}(_0xe7d2);

_0xe7d2这是一个Array(221) !只是为了形成一个表达式,函数就可以运行,function(c)函数的形参为c,实参为_0xe7d2,函数体中又是一个函数调用function(x),形参为x,实参为421。这个函数体为

        for (; --x; )
            c.push(c.shift())

x为421,c为_0xe7d2这,一个Array(221)的数组。c.shift() 数组头部删除 shift() 方法用于把数组的第一个元素从其中删除,并返回第一个元素的值 数组尾部添加 **push()*方法可向数组的末尾添加一个或多个元素,并返回新的长度

var _0x19c3 = function(x, c) {
    return _0xe7d2[x -= 0]
};

将函数赋值给_0x19c3

!function(x, c) {
    for (var _ in c)
        x[_] = c[_]
}(window, function(_) {                   
                       }([function(x, c, _) {
}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {
 
}
, function(x, c, _) {

}
, function(x, c, _) {
  
}
, function(x, c, _) {

}
, function(x, c) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c) {
 
}
, function(x, c, _) {
  
}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {
 
}
, function(x, c, _) {
 
}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {
 
}
, function(x, c, _) {

}
, function(x, c, _) {
 
}
, function(x, c, _) {
 
}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c, _) {

}
, function(x, c) {

}
, function(x, c, _) {

}
, function(x, c) {

}
]));

大概是个这个结构,更清晰的

!function(x, c) {
    for (var _ in c)
        x[_] = c[_]
}(      window, function(_){}(      [  f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f  ]    )       )

大概就是这个意思 function()的参数为一个数组,这个数组的成员都是函数 function(x, c)中传递的实参为 window 和function()的返回值 function(_)这是个函数表达式,他会先执行,参数是一个数组,执行后的返回值会当实参,传递给c

分析下function(_)的函数体,看看返回值是什么

function(_) {
    var t = {};
    function r(x) {
        if (t[x])
            return t[x][_0x19c3("0x0")];
        var c = t[x] = {
            i: x,
            l: !1,
            exports: {}
        };
        return _[x].call(c[_0x19c3("0x0")], c, c[_0x19c3("0x0")], r),
        c.l = !0,
        c[_0x19c3("0x0")]
    }
    return r.m = _,
    r.c = t,
    r.d = function(x, c, _) {
        r.o(x, c) || Object[_0x19c3("0x1")](x, c, {
            enumerable: !0,
            get: _
        })
    }
    ,
    r.r = function(x) {
        typeof Symbol !== _0x19c3("0x2") && Symbol[_0x19c3("0x3")] && Object[_0x19c3("0x1")](x, Symbol.toStringTag, {
            value: _0x19c3("0x4")
        }),
        Object[_0x19c3("0x1")](x, _0x19c3("0x5"), {
            value: !0
        })
    }
    ,
    r.t = function(c, x) {
        if (1 & x && (c = r(c)),
        8 & x)
            return c;
        if (4 & x && typeof c === _0x19c3("0x6") && c && c[_0x19c3("0x5")])
            return c;
        var _ = Object[_0x19c3("0x7")](null);
        if (r.r(_),
        Object.defineProperty(_, _0x19c3("0x8"), {
            enumerable: !0,
            value: c
        }),
        2 & x && typeof c != _0x19c3("0x9"))
            for (var t in c)
                r.d(_, t, function(x) {
                    return c[x]
                }
                [_0x19c3("0xa")](null, t));
        return _
    }
    ,
    r.n = function(x) {
        var c = x && x[_0x19c3("0x5")] ? function() {
            return x[_0x19c3("0x8")]
        }
        : function() {
            return x
        }
        ;
        return r.d(c, "a", c),
        c
    }
    ,
    r.o = function(x, c) {
        return Object[_0x19c3("0xb")][_0x19c3("0xc")][_0x19c3("0xd")](x, c)
    }
    ,
    r.p = "",
    r(r.s = 12)
}

这个结构是这样的

var t
声明了function r
return x,x,x,x,xx,x,x,x,

直接返回了? 没有 问题在最后一句

r(r.s=12)

这个r是里面声明的那个函数,参数值是12

function r(x) {
        if (t[x])
            return t[x][_0x19c3("0x0")];
        var c = t[x] = {
            i: x,
            l: !1,
            exports: {}
        };
        return _[x].call(c[_0x19c3("0x0")], c, c[_0x19c3("0x0")], r),
        c.l = !0,
        c[_0x19c3("0x0")]
    }

x为12 为函数数组,[x].call也就是获得了数组第12个函数,然后调用

_0x19c3("0x0")为exports