如何获取Finalshell中保存的密码

当忘记Linux登录密码时,可以通过Finalshell工具中保存的加密密码进行解密找回。首先定位到Finalshell的安装路径,找到对应主机名的文件,找出加密密码。然后使用提供的Java代码,将加密密码作为参数,执行main方法,即可解密出原始密码,从而重新连接Linux服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通过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,连接成功。

 

 

 

### 如何找回或重置 FinalShell密码 当涉及到找回或重置 FinalShell保存的 Linux 登录密码时,重要的是理解 FinalShell 自身并不存储明文形式的密码。相反,FinalShell 使用加密方式来保护这些敏感信息。因此,不存在直接从 FinalShell 应用程序内部简单恢复原始密码的方法。 对于那些曾经成功登录过目标Linux服务器并希望重新获得访问权限的情况,可以通过利用已有的会话记录尝试间接解决问题[^1]。具体操作方法依赖于操作系统以及安全策略设置的不同而有所差异: - 如果仍然能够通过其他认证机制(如密钥对验证)进入同一台机器,则可以直接修改 `/etc/shadow` 文件中的相应条目或者使用 `passwd` 命令更改用户账户的口令。 - 对于某些特定版本的操作系统和服务提供商环境,可能存在额外的安全措施阻止上述常规手段的有效实施,在这种情况下建议联系管理员寻求帮助。 然而,如果确实需要完全绕开现有凭证来进行紧急修复工作,可能不得不采取更激进的方式——即重启系统进入单用户模式或其他非常规途径以实现无证访问目的;但这通常只适用于物理控制下的设备,并且可能会违反服务条款或法律法规,请谨慎行事。 针对 MySQL 数据库管理系统的 root 用户密码遗忘情况,提供了具体的解决方案:先停止 mysqld 服务进程,接着启动带有跳过授权表选项的服务实例以便允许无需身份验证即可执行必要的变更指令,最后按照给定 SQL 语句完成新密码设定过程[^3]。 需要注意的是以上提到的技术细节主要面向数据库管理系统而非 SSH 客户端工具本身的功能特性讨论范围之内。 ```bash sudo systemctl stop mariadb.service sudo mysqld_safe --skip-grant-tables & mysql -u root FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword!'; exit; sudo systemctl start mariadb.service ```
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值