某卢小说网站登录密码逆向
最近一直学习js逆向,今晚找了一个小说网站,分析一下登录密码的解密逆向过程,过程不是很难,分享给和我一样的小白,很详细呦!学习网站'aHR0cHM6Ly91LmZhbG9vLmNvbS9yZWdpc3QvbG9naW4uYXNweA=='
这个就是加密后的密码,今晚就逆向它,其他参数暂时不研究,留做以后分析
1.先找登录的调用方法,这里明显看到login
2.搜索login,发现可疑js,名为md5.js,跟进去
3.下断以后,发现是这里进行的加密,通过明文和时间戳进行的加密
4.login_md5里调用了hex_md5方法
5.hex_md5又调用了一堆方法,一个方法套一个方法,大概套了6、7层,这里不一一赘述了,把所有用到的代码都扣下来就好了
6.需要注意有2个常量,一个是chrsz = 8;一个是 hexcase = 0;
7.扣完所有代码以后我们校验一下结果,可以看到结果是一样的
总结:整体过程不是特别复杂,就是扣代码跟栈一个一个找有点费时间,但是非常适合像我这种小白练手用,大佬直接跳过就好。
最后附上扣的代码,方便和我一样的小白对照着调试,不知道让不让放,如果不让的话,烦请管理员告知,我再删除。
var chrsz = 8;
var hexcase = 0;
var datetime_num = Math.round(new Date() / 1000);
function login_md5(pwd, datetime_num) {
return hex_md5("@345Kie(873_dfbKe>d3<.d23432=" + hex_md5("EW234@![#$&]*{,OP}Kd^w349Op+-32_" + pwd + datetime_num));
}
function hex_md5(s) {
return binl2hex(core_md5(str2binl(s), s.length * chrsz));
}
function core_md5(x, len) {
x |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for (var i = 0; i < x.length; i += 16) {
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x, 7, -680876936);
d = md5_ff(d, a, b, c, x, 12, -389564586);
c = md5_ff(c, d, a, b, x, 17, 606105819);
b = md5_ff(b, c, d, a, x, 22, -1044525330);
a = md5_ff(a, b, c, d, x, 7, -176418897);
d = md5_ff(d, a, b, c, x, 12, 1200080426);
c = md5_ff(c, d, a, b, x, 17, -1473231341);
b = md5_ff(b, c, d, a, x, 22, -45705983);
a = md5_ff(a, b, c, d, x, 7, 1770035416);
d = md5_ff(d, a, b, c, x, 12, -1958414417);
c = md5_ff(c, d, a, b, x, 17, -42063);
b = md5_ff(b, c, d, a, x, 22, -1990404162);
a = md5_ff(a, b, c, d, x, 7, 1804603682);
d = md5_ff(d, a, b, c, x, 12, -40341101);
c = md5_ff(c, d, a, b, x, 17, -1502002290);
b = md5_ff(b, c, d, a, x, 22, 1236535329);
a = md5_gg(a, b, c, d, x, 5, -165796510);
d = md5_gg(d, a, b, c, x, 9, -1069501632);
c = md5_gg(c, d, a, b, x, 14, 643717713);
b = md5_gg(b, c, d, a, x, 20, -373897302);
a = md5_gg(a, b, c, d, x, 5, -701558691);
d = md5_gg(d, a, b, c, x, 9, 38016083);
c = md5_gg(c, d, a, b, x, 14, -660478335);
b = md5_gg(b, c, d, a, x, 20, -405537848);
a = md5_gg(a, b, c, d, x, 5, 568446438);
d = md5_gg(d, a, b, c, x, 9, -1019803690);
c = md5_gg(c, d, a, b, x, 14, -187363961);
b = md5_gg(b, c, d, a, x, 20, 1163531501);
a = md5_gg(a, b, c, d, x, 5, -1444681467);
d = md5_gg(d, a, b, c, x, 9, -51403784);
c = md5_gg(c, d, a, b, x, 14, 1735328473);
b = md5_gg(b, c, d, a, x, 20, -1926607734);
a = md5_hh(a, b, c, d, x, 4, -378558);
d = md5_hh(d, a, b, c, x, 11, -2022574463);
c = md5_hh(c, d, a, b, x, 16, 1839030562);
b = md5_hh(b, c, d, a, x, 23, -35309556);
a = md5_hh(a, b, c, d, x, 4, -1530992060);
d = md5_hh(d, a, b, c, x, 11, 1272893353);
c = md5_hh(c, d, a, b, x, 16, -155497632);
b = md5_hh(b, c, d, a, x, 23, -1094730640);
a = md5_hh(a, b, c, d, x, 4, 681279174);
d = md5_hh(d, a, b, c, x, 11, -358537222);
c = md5_hh(c, d, a, b, x, 16, -722521979);
b = md5_hh(b, c, d, a, x, 23, 76029189);
a = md5_hh(a, b, c, d, x, 4, -640364487);
d = md5_hh(d, a, b, c, x, 11, -421815835);
c = md5_hh(c, d, a, b, x, 16, 530742520);
b = md5_hh(b, c, d, a, x, 23, -995338651);
a = md5_ii(a, b, c, d, x, 6, -198630844);
d = md5_ii(d, a, b, c, x, 10, 1126891415);
c = md5_ii(c, d, a, b, x, 15, -1416354905);
b = md5_ii(b, c, d, a, x, 21, -57434055);
a = md5_ii(a, b, c, d, x, 6, 1700485571);
d = md5_ii(d, a, b, c, x, 10, -1894986606);
c = md5_ii(c, d, a, b, x, 15, -1051523);
b = md5_ii(b, c, d, a, x, 21, -2054922799);
a = md5_ii(a, b, c, d, x, 6, 1873313359);
d = md5_ii(d, a, b, c, x, 10, -30611744);
c = md5_ii(c, d, a, b, x, 15, -1560198380);
b = md5_ii(b, c, d, a, x, 21, 1309151649);
a = md5_ii(a, b, c, d, x, 6, -145523070);
d = md5_ii(d, a, b, c, x, 10, -1120210379);
c = md5_ii(c, d, a, b, x, 15, 718787259);
b = md5_ii(b, c, d, a, x, 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
function str2binl(str) {
var bin = Array();
var mask = (1 << chrsz) - 1;
for (var i = 0; i < str.length * chrsz; i += chrsz)
bin |= (str.charCodeAt(i / chrsz) & mask) << (i % 32);
return bin;
}
function binl2hex(binarray) {
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for (var i = 0; i < binarray.length * 4; i++) {
str += hex_tab.charAt((binarray >> ((i % 4) * 8 + 4)) & 0xF) + hex_tab.charAt((binarray >> ((i % 4) * 8)) & 0xF);
}
return str;
}
function md5_ff(a, b, c, d, x, s, t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_cmn(q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}
function safe_add(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
function bit_rol(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
}
function md5_hh(a, b, c, d, x, s, t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
console.log(login_md5("123456",'1690810935'))
总结就是个md5: md5("@345Kie(873_dfbKe>d3<.d23432="+md5("MD5 EW234@![#$&]*{,OP}Kd^w349Op+-32_+密码+时间戳"))
下面给出易语言的 代码 {:1_925:}
取数据摘要 (到字节集 (“@345Kie(873_dfbKe>d3<.d23432=” + 取数据摘要 (到字节集 (“EW234@![#$&]*{,OP}Kd^w349Op+-32_” + pwd + datetime_num))))
附上易语言 代码,pwd,datetime_num 是文本型变量,原始密码,和 10位时间戳 感谢分享过程,很详细:lol 他这啥意思 在前端加密再传后端? 能不能搞个管理员账号
xiaomishouji 发表于 2023-8-1 13:51
他这啥意思 在前端加密再传后端?
后端犯懒一点,直接存用户加密后的认证信息,每次看跟前端的字符串匹配不,不匹配就错了。 厉害了,支持一下 好厉害,学习了:lol 请教下楼主啊,知道密码是怎么加密的有什么用吗? 感谢分享,学习中 搜索login,是在哪里搜?老哥用的什么浏览器?