前言
在酒店实在无聊,想着测测路由器玩玩,看看有没有摄像头

抓到包就是这个样子

治不了 gov 还治不了你?
手搓了一会 js,又是异或啥的,实在是头疼,后来发现,把 admin 加密后的字符串放到百度一搜,就有师傅逆向出来过

测试一下抠出来的加密函数可用性
var TpLinkPasswordEncoder = { // 'presetString' 是一个预设的字符串,用于与输入密码进行异或操作的一部分 presetString: "RDpbLfCPsJZ7fiv",
// 'dictionary' 字典字符串,用于生成加密后的字符 dictionary: "yLwVl0zKqws7LgKPRQ84Mdt708T1qQ3Ha7xv3H7NyU84p21BriUWBU43odz3iP4rBL3cD02KZciX" + "TysVXiV8ngg6vL48rPJyAUw0HurW20xqxv9aYb4M9wK1Ae0wlro510qXeU07kV57fQMc8L6aLgML" + "wygtc0F10a0Dg70TOoouyFhdysuRMO51yY5ZlOZZLEal1h0t9YQW0Ko7oBwmCAHoic4HYbUyVeU3" + "sfQ1xtXcPcf1aT303wAQhv66qzW",
// 'encodePassword' 方法用于加密传入的密码 encodePassword: function (password) { var dictionary = this.dictionary; var output = ""; // 加密后的字符串将存储在这里 var len, lenPassword, lenPreset, lenDict; var charLeft = 0xBB, charRight = 0xBB;
lenPassword = password.length; // 输入密码的长度 lenPreset = this.presetString.length; // 预设字符串的长度 lenDict = dictionary.length; // 字典字符串的长度 len = lenPassword > lenPreset ? lenPassword : lenPreset; // 取最长的长度作为循环的次数
// 遍历每个字符进行加密处理 for (var index = 0; index < len; index++) { charLeft = 0xBB; charRight = 0xBB;
// 根据索引位置,决定如何与预设字符串的字符进行异或操作 if (index >= lenPassword) { // 如果索引超出了密码长度,只使用预设字符串的字符 charRight = this.presetString.charCodeAt(index); } else if (index >= lenPreset) { // 如果索引超出了预设字符串长度,只使用密码的字符 charLeft = password.charCodeAt(index); } else { // 如果索引在两个字符串的长度内,使用两者的字符进行异或操作 charLeft = password.charCodeAt(index); charRight = this.presetString.charCodeAt(index); }
// 根据异或操作的结果,从字典中选取字符,添加到输出字符串中 output += dictionary.charAt((charLeft ^ charRight) % lenDict); }
return output; // 返回加密后的字符串 }};
// 测试加密功能,输出加密后的'admin'密码console.log(TpLinkPasswordEncoder.encodePassword("admin"));


用 AI 使用 Python 重构一下加密逻辑
问:为什么要 Python 重构?
答:看 Python 顺眼,只看得懂 Python

然后 Deepwiki+手改
无奈 Deepwiki 抽风,给了好几次结果都不对

最后手改了一份
tplinkPasswordEncode = password => { presetString = "RDpbLfCPsJZ7fiv" dictionary = "yLwVl0zKqws7LgKPRQ84Mdt708T1qQ3Ha7xv3H7NyU84p21BriUWBU43odz3iP4rBL3cD02KZciXTysVXiV8ngg6vL48rPJyAUw0HurW20xqxv9aYb4M9wK1Ae0wlro510qXeU07kV57fQMc8L6aLgMLwygtc0F10a0Dg70TOoouyFhdysuRMO51yY5ZlOZZLEal1h0t9YQW0Ko7oBwmCAHoic4HYbUyVeU3sfQ1xtXcPcf1aT303wAQhv66qzW"
output = "" lenPassword = len(password) lenPreset = len(presetString) lenDict = len(dictionary)
// 使用max函数确定循环长度 length = lenPassword if lenPreset > lenPassword { length = lenPreset }
for i = 0; i < length; i++ { charLeft = 0xBB charRight = 0xBB
if i >= lenPassword { // 超出密码长度,使用预设字符串 charRight = presetString[i] } else if i >= lenPreset { // 超出预设字符串长度,使用密码字符 charLeft = password[i] } else { // 都在范围内,使用两者 charLeft = password[i] charRight = presetString[i] }
// 异或运算并取字典字符 index = (charLeft ^ charRight) % lenDict output += dictionary[index:index+1] }
return output }print(tplinkPasswordEncode("admin"))

然而,事实并不是很美好

同时也是证明算法是对的。
最后也是成功被 ban 了

希望官方微调训练 AI 模型,这样就可以懒死了。
参考资料:
Yaklang 官方手册https://www.yaklang.com/docs/introCSDN 算法解析https://blog.csdn.net/qq_38238956/article/details/124363565Deepwikihttps://deepwiki.com/yaklang/yaklang