有时候需要找保存的ssh密码,但是finalshell不能直接查看,需要解密

可以用在线工具

查看FinalShell已保存密码 | 在线工具 - 查看FinalShell密码 免费 (uiucode.com)

antontwelve.github.io/finalshellPasswordDecrypter/

解密代码

public class FinalShellDecodePass {
    public static void main(String[] args) throws Exception {
        System.out.print(decodePassword("这里输入你的加密字符串"));
    }
    public static byte[] decryptDes(byte[] data, byte[] key) throws Exception {
        SecureRandom secureRandom = new SecureRandom();
        DESKeySpec desKeySpec = new DESKeySpec(key);
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
        SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
        Cipher cipher = Cipher.getInstance("DES");
        cipher.init(Cipher.DECRYPT_MODE, secretKey, secureRandom);
        return cipher.doFinal(data);
    }
    public static String decodePassword(String data) throws Exception {
        if (data == null) {
            return null;
        } else {
            byte[] decodedData = Base64.getDecoder().decode(data);
            byte[] head = new byte[8];
            System.arraycopy(decodedData, 0, head, 0, head.length);
            byte[] encryptedData = new byte[decodedData.length - head.length];
            System.arraycopy(decodedData, head.length, encryptedData, 0, encryptedData.length);
            byte[] decryptedData = decryptDes(encryptedData, generateRandomKey(head));
            // 将解密后的数据转换为字符串
        }
    }
}

在线运行java:Java 在线工具 | 菜鸟工具 (jyshare.com)

Last modification:October 24, 2024
如果觉得我的文章对你有用,请随意赞赏