适用版本:
SecureCRT 7.3.3 之后的版本 - Password V2 算法
参考文章:
- how-does-SecureCRT-encrypt-password
- 内网常用工具密码
- AES-256-CBC加密
- Java实现SHA256算法
全部代码:
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.util.Random;import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;public class SecureCRTPwdDecrypt {// 初始向量private static final byte[] IV = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};// 如果未设置配置密码,则密钥为SHA256的空字符串摘要private static final byte[] KEY = AES256.autoKey(AES256.getSHA256Str(""));// 如果设置配置密码,则密钥为
// private static byte[] passphrase = {
// (byte) 0xe3, (byte) 0xb0, (byte) 0xc4, 0x42, (byte) 0x98, (byte) 0xfc, 0x1c, 0x14,
// (byte) 0x9a, (byte) 0xfb, (byte) 0xf4, (byte) 0xc8, (byte) 0x99, 0x6f, (byte) 0xb9, 0x24,
// 0x27, (byte) 0xae, 0x41, (byte) 0xe4, 0x64, (byte) 0x9b, (byte) 0x93, 0x4c,
// (byte) 0xa4, (byte) 0x95, (byte) 0x99, 0x1b, 0x78, 0x52, (byte) 0xb8, 0x55
// };public static void main(String[] args) throws Exception {String plainText = "1234567";String encHexStr = passwordV2EnDecrytion(plainText);System.out.println(encHexStr.toLowerCase());String passwd = passwordV2Decrytion(encHexStr);System.out.println(passwd);}private static String passwordV2Decrytion(String encDataStr) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException {// 1. 16进制字符串转成 byte[]byte[] encData = AES256.hexStringToBytes(encDataStr);// 2. 解密byte[] decData