菜单
个人主页
(当前)
写文章
浏览博文
    
搜索
登录
微信公众号
站点链接
半根蓝白个人主页
CSDN
Github
友情链接
摘繁华个人博客
博文目录
#custom-toc-container
finalshell 找回密码
BGLB0324
2021年10月16日 23:19
最后发布:2021年10月16日 23:19
首发:2021年10月16日 23:19
1433
1
博文分类:
杂学
博文标签:
finalshell
密码解密
版权声明:本文为博主[BGLB0324]原创文章,遵循
CC 4.0 BY
版权协议,转载请附上原文出处链接和本声明。
本文链接:
http://blog.bglb.work/blog/blog-detail/63
版权
# finalshell 找回密码 > 很久没有登录云服务器了, 今天突然需要查看一下日志, 打开finalshell,选中aliyun, 点击登录,一顿操作猛如虎, 以迅雷不及掩耳之势,输入cd, 哎! 怎么跟以前不一样了,仔细看了一下 需要重新认证密码及设置新密码. **** 完了!,密码忘了! ## 万能的浏览器,打开世界的搜索框,我来了 **果不其然 已经有大佬踩过坑了 来吧 操作一波**  **1. 找到finalshell的安装目录**  **2. 找到 `conn` 文件夹**  **3. 打开 `*.json ` 文件** > 可以通过 `host` 字段区分服务器 下图是我手机端的 `terminal` 的 `ssh` 链接配置  其中, `password` 字段是密码的密文 ## 来吧! 上代码 ```java import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Base64; import java.util.Random; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.DESKeySpec; public class FinalShellDecodePass { public static void main(String[] args)throws Exception { System.out.println(decodePass(args[0])); } public static byte[] desDecode(byte[] data, byte[] head) throws Exception { SecureRandom sr = new SecureRandom(); DESKeySpec dks = new DESKeySpec(head); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); SecretKey securekey = keyFactory.generateSecret(dks); Cipher cipher = Cipher.getInstance("DES"); cipher.init(2, securekey, sr); return cipher.doFinal(data); } public static String decodePass(String data) throws Exception { if (data == null) { return null; } else { String rs = ""; byte[] buf = Base64.getDecoder().decode(data); byte[] head = new byte[8]; System.arraycopy(buf, 0, head, 0, head.length); byte[] d = new byte[buf.length - head.length]; System.arraycopy(buf, head.length, d, 0, d.length); byte[] bt = desDecode(d, ranDomKey(head)); rs = new String(bt); return rs; } } static byte[] ranDomKey(byte[] head) { long ks = 3680984568597093857L / (long)(new Random((long)head[5])).nextInt(127); Random random = new Random(ks); int t = head[0]; for(int i = 0; i < t; ++i) { random.nextLong(); } long n = random.nextLong(); Random r2 = new Random(n); long[] ld = new long[]{(long)head[4], r2.nextLong(), (long)head[7], (long)head[3], r2.nextLong(), (long)head[1], random.nextLong(), (long)head[2]}; ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); long[] var15 = ld; int var14 = ld.length; for(int var13 = 0; var13 < var14; ++var13) { long l = var15[var13]; try { dos.writeLong(l); } catch (IOException var18) { var18.printStackTrace(); } } try { dos.close(); } catch (IOException var17) { var17.printStackTrace(); } byte[] keyData = bos.toByteArray(); keyData = md5(keyData); return keyData; } public static byte[] md5(byte[] data) { String ret = null; byte[] res=null; try { MessageDigest m; m = MessageDigest.getInstance("MD5"); m.update(data, 0, data.length); res=m.digest(); ret = new BigInteger(1, res).toString(16); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return res; } } ``` 打开cmd 进行编译 `javac FinalShellDecodePass`, `java FinalShellDecodePass 密文` 进行解密  **ok! 密码已经出来了, 估计这解密代码是从源码里抠出来的!** **java 还是有点不习惯, 有时间改一个`python` 版本的! 下期再见!**
点赞
1
打赏
暂时没有评论
请
登录
后评论
暂时没有评论