通过Finalshell工具连接linux服务之后,但是忘记了linux登入密码,不需要重置就可以找回,步骤如下 步骤1,找到finalshell工具安装路径 步骤2,该文件夹下面文件都是以连接过的服务主机名称命名的,打开你忘记密码的主机
通过Finalshell工具连接linux服务之后,但是忘记了linux登入密码,不需要重置就可以找回,步骤如下
步骤1,找到finalshell工具安装路径
步骤2,该文件夹下面文件都是以连接过的服务主机名称命名的,打开你忘记密码的主机名称文件
步骤3,文件中passWord后面绿色就是加密的密码 如图
步骤4,如下图解密代码,把加密密码当做入参,执行一下main方法,控制台就可以打印出解密的密码
package cn.demo.controller;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("e0QlMF52FiAGXQl0r1RQao7UE9PbfFm+")); } 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; }}
步骤5,如图
步骤6,连接成功。
来源地址:https://blog.csdn.net/qq_40609490/article/details/127394663
--结束END--
本文标题: 如何获取Finalshell中保存的密码
本文链接: https://lsjlt.com/news/409472.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-01-21
2023-10-28
2023-10-28
2023-10-27
2023-10-27
2023-10-27
2023-10-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0