问题:cryptoAPI.js 是一段JavaScript源代码,它(部分)实现了加密API。它包含三个单独的漏洞,允许攻击者在稍后cryptoAPI. sha1.hash(x)调用函数时针对某些参数执行任意代码x。
代码:
var CryptoAPI = (function() {
var encoding = {
a2b: function(a) {return a},
b2a: function(b) {return b}
};
var API = {
sha1: {
name: 'sha1',
identifier: '2b0e03021a',
size: 20,
block: 64,
hash: function(s) {
console.log(s)
var len = (s += '\x80').length,
blocks = len >> 6,
chunk = len & 63,
res = "",
i = 0,
j = 0,
H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0],
w = [];
while (chunk++ != 56) {
s += "\x00";
if (chunk == 64) {
blocks++;
chunk = 0;
}
}
for (s += "\x00\x00\x00\x00", chunk = 3, len = 8 * (len - 1); chunk >= 0; chunk--) {
s += encoding.b2a(len >> (8 * chunk) & 255);
}
for (i = 0; i < s.length; i++) {
j = (j << 8) + encoding.a2b(s[i]);
if ((i & 3) == 3) {
w[(i >> 2) & 15] = j;
j = 0;
}
if ((i & 63) == 63) CryptoAPI.sha1._round(H, w);
}
for (i = 0; i < H.length; i++)
for (j = 3; j >= 0; j--)
res += encoding.b2a(H[i] >> (8 * j) & 255);
return res;
}, // End "hash"
_round: function(H, w) {return H*w}
} // End "sha1"
}; // End "API"
return API; // End body of anonymous function
})(); // End "CryptoAPI"
网络安全方面的题目
希望大家能帮忙找找它包含三个单独的漏洞行数,我搞了半天实在一个也找不出来,谢谢=