工具
阅读:评论:
finalshell查看连接远程linux的用户名密码
在finalshell工具中导出远程连接的配置json文件。在json文件中找到加密后的密码,然后使用一下代码进行解密 import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io
- 在finalshell工具中导出远程连接的配置json文件。在json文件中找到加密后的密码,然后使用一下代码进行解密
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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 TestDecodePass { public static void main(String[] args) throws Exception { // 如果没有提供参数,显示使用方法 // if (args.length == 0) {// System.out.println("使用方法:");// System.out.println("1.从Finalshell导出配置文件");// System.out.println("2.在配置文件中搜索password字段,复制编码后的字符串");// System.out.println("3.运行: java TestDecodePass [编码后的密码字符串]");// System.out.println("\n示例:");// System.out.println("java TestDecodePass \"示例密码字符串\"");// return;// }// String encodedPass = args[0];//被外部调用这样写,并取消以上的注释 String encodedPass = "替换加密的密码";// 密码是1 String decodedPass = decodePass(encodedPass); System.out.println("解密后的密码:" + decodedPass); } 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(Cipher.DECRYPT_MODE, 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); for (long l : ld) { 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) { byte[] res = null; try { MessageDigest m = MessageDigest.getInstance("MD5"); m.update(data, 0, data.length); res = m.digest(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return res; }} - 转载:<https://blog.csdn.net/zmsofts/article/details/156767240>