• 服务器连接时间长了,忘记密码,解密密码


    一、选中连接地址,右键导出

    二、打开导出的配置文件,搜索password,找到password的编码后的字符串复制

    三、main()方法的字符串替换成复制的password编码

    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 FinalShellDecodePassWard {
        public static void main(String[] args)throws Exception {
            System.out.println(decodePass("替换成复制的字符串编码"));
        }
        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;
        }
    }
    
    
    • 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
  • 相关阅读:
    Python很慢,但它即将变得更快
    如何使用 GPU 访问运行 Docker Compose 容器
    排序算法(以从小到大排列为例)
    FPGA实现10M多功能信号发生器
    Leetcode刷题Day1----数组
    Ubuntu上安装和配置MySQL
    1.6HTML的表格和列表
    git常用命令记录
    《Linux运维总结:基于快照模式迁移单节点elasticsearch数据(方案二)》
    【T3】畅捷通T3凭证打印修改边距后,打印效果没有任何变化。
  • 原文地址:https://blog.csdn.net/qq_49641620/article/details/133639568