保存在FinalShell服务器登录密码忘记了,如何快速获取到

一、从FinalShell获取服务器基本信息

如图操作会导出一个json文件,可以直接保存在桌面,或者其他位置

json格式如下:

{"forwarding_auto_reconnect":false
,"custom_size":false
,"delete_time":0
,"secret_key_id":""
,"user_name":"root"
,"remote_port_forwarding":{}
,"conection_type":100
,"sort_time":0
,"description":""
,"proxy_id":"0"
,"authentication_type":1
,"drivestoredirect":true
,"delete_key_sequence":0
,"password":"xE4F2Pi13TnbkO8vo6wwmQNbqB77PUeI"
,"modified_time":1700460445433
,"host":"x.xx.xx.xx"
,"accelerate":false
,"id":"sn1xqbrr5womw787"
,"height":0
,"order":0
,"create_time":1700460445433
,"port_forwarding_list":[]
,"parent_update_time":0
,"rename_time":0
,"backspace_key_sequence":2
,"fullscreen":false
,"port":22
,"terminal_encoding":"UTF-8"
,"parent_id":"root"
,"exec_channel_enable":true
,"width":0
,"name":"xx.xx.xx.xx"
,"access_time":1719895278353}

二、代码读取并解析获取账号明文信息

package com.base.info.controller;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.*;

public class FinalShellDecodePass {
    public static void main(String[] args) throws Exception {
        // 获取finalshell的所有json数据,json数据所在文件夹
        File file = new File("C:\\Users\\12118\\Desktop"); //我的放在桌面了,如果json文件在其他位置,需要更改为对应路径
        // 获取所有的json文件
        File[] files = file.listFiles(pathname -> "json".equalsIgnoreCase(FilenameUtils.getExtension(pathname.getName())));
        // 主要信息: ip/端口/用户名/密码
        List<Map<String, Object>> infoList = new ArrayList<>(files.length);
        for (File jsonFile : files) {
            String s = FileUtils.readFileToString(jsonFile);
            FinalShellConfig shellConfig = JSON.parseObject(s, FinalShellConfig.class);
            // 密文改明文
            String password = shellConfig.getPassword();
            if (StringUtils.isNotBlank(password)) {
                shellConfig.setPassword(decodePass(password));
            }
            String s1 = JSON.toJSONString(shellConfig);
            System.err.println(s1);

            Map<String, Object> map = new LinkedHashMap<>();
            map.put("主机", shellConfig.getHost());
            map.put("端口", shellConfig.getPort());
            map.put("用户名", shellConfig.getUserName());
            map.put("密码", shellConfig.getPassword());
            infoList.add(map);
        }
        for (Map<String, Object> stringObjectMap : infoList) {
            System.err.println(JSON.toJSONString(stringObjectMap));
        }

    }

    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;
    }


    @NoArgsConstructor
    @Data
    static class FinalShellConfig {

        @JsonProperty("forwarding_auto_reconnect")
        private Boolean forwardingAutoReconnect;
        @JsonProperty("custom_size")
        private Boolean customSize;
        @JsonProperty("delete_time")
        private Integer deleteTime;
        @JsonProperty("secret_key_id")
        private String secretKeyId;
        @JsonProperty("user_name")
        private String userName;
        @JsonProperty("conection_type")
        private Integer conectionType;
        @JsonProperty("sort_time")
        private Integer sortTime;
        @JsonProperty("description")
        private String description;
        @JsonProperty("proxy_id")
        private String proxyId;
        @JsonProperty("authentication_type")
        private Integer authenticationType;
        @JsonProperty("drivestoredirect")
        private Boolean drivestoredirect;
        @JsonProperty("delete_key_sequence")
        private Integer deleteKeySequence;
        @JsonProperty("password")
        private String password;
        @JsonProperty("modified_time")
        private Long modifiedTime;
        @JsonProperty("host")
        private String host;
        @JsonProperty("accelerate")
        private Boolean accelerate;
        @JsonProperty("id")
        private String id;
        @JsonProperty("height")
        private Integer height;
        @JsonProperty("order")
        private Integer order;
        @JsonProperty("create_time")
        private Long createTime;
        @JsonProperty("port_forwarding_list")
        private List<?> portForwardingList;
        @JsonProperty("parent_update_time")
        private Integer parentUpdateTime;
        @JsonProperty("rename_time")
        private Long renameTime;
        @JsonProperty("backspace_key_sequence")
        private Integer backspaceKeySequence;
        @JsonProperty("fullscreen")
        private Boolean fullscreen;
        @JsonProperty("port")
        private Integer port;
        @JsonProperty("terminal_encoding")
        private String terminalEncoding;
        @JsonProperty("parent_id")
        private String parentId;
        @JsonProperty("exec_channel_enable")
        private Boolean execChannelEnable;
        @JsonProperty("width")
        private Integer width;
        @JsonProperty("name")
        private String name;
        @JsonProperty("access_time")
        private Long accessTime;
    }
}

三、执行main方法,获取信息

这样就获取到了!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/780266.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

从0到1制作单只鳌虾运动轨迹追踪软件

前言 需要准备windows10操作系统&#xff0c;python3.11.9&#xff0c;cuDNN8.9.2.26&#xff0c;CUDA11.8&#xff0c;paddleDetection2.7 流程&#xff1a; 准备数据集-澳洲鳌虾VOC数据集 基于RT-DETR目标检测模型训练导出onnx模型进行python部署平滑滤波处理视频帧保留的…

数字化精益生产系统--QMS质量管理系统

QMS质量管理系统&#xff08;Quality Management System&#xff09;是现代企业管理的关键组成部分&#xff0c;旨在确保产品和服务的质量达到或超过客户需求和期望。 以下是对QMS质量管理系统的功能设计&#xff1a;

ip地址突然变了一个城市怎么办

在数字化日益深入的今天&#xff0c;IP地址不仅是网络连接的标识&#xff0c;更是我们网络行为的“身份证”。然而&#xff0c;当您突然发现您的IP地址从一个城市跳转到另一个城市时&#xff0c;这可能会引发一系列的疑问和担忧。本文将带您深入了解IP地址突变的可能原因&#…

软件系统架构的一些常见专业术语

分层架构是逻辑上的&#xff0c;在物理部署上&#xff0c;三层结构可以部署在同一个物理机器上&#xff0c;但是随着网站业务的发展&#xff0c;必然需要对已经分层的模块分离部署&#xff0c;即三层结构分别部署在不同的服务器上&#xff0c;使网站拥有更多的计算资源以应对越…

信号与系统笔记分享

文章目录 一、导论信号分类周期问题能量信号和功率信号系统的线性判断时变&#xff0c;时不变系统因果系统判断记忆性系统判断稳定性系统判断 二、信号时域分析阶跃函数冲激函数取样性质四种特性1 筛选特性2 抽样特性3 展缩特性4 卷积特性卷积作用 冲激偶函数奇函数性质公式推导…

Java版Flink使用指南——安装Flink和使用IntelliJ制作任务包

大纲 安装Flink操作系统安装JDK安装Flink修改配置启动Flink测试 使用IntelliJ制作任务包新建工程Archetype 编写测试代码打包测试 参考资料 在《0基础学习PyFlink》专题中&#xff0c;我们熟悉了Flink的相关知识以及Python编码方案。这个系列我们将使用相对主流的Java语言&…

C++基础(十一):STL简介

从今天开始&#xff0c;我们正式步入STL的学习&#xff0c;STL&#xff08;标准模板库&#xff0c;Standard Template Library&#xff09;是C标准库的重要组成部分&#xff0c;提供了一系列通用的类和函数模板&#xff0c;包括容器、算法、迭代器等。它的设计极大地提高了代码…

中国科学技术大学发布了2024年少年班录取名单

7月7日&#xff0c;中国科学技术大学发布了2024年少年班录取名单公示&#xff0c;来自上海的12岁“小孩哥”刘尧进入名单。 据澎湃新闻此前报道&#xff0c;刘尧是因为此前通过了中科大少年班的校测考试&#xff0c;提前拿到了“高考体验券”。他所在的上海市实验学校&#xff…

柳叶刀:5Kg负重巡飞无人机技术详解

一、引言 随着无人机技术的不断发展&#xff0c;巡飞无人机在军事侦察、环境监测、边境巡逻等领域的应用日益广泛。其中&#xff0c;“柳叶刀”作为一款5Kg负重巡飞无人机&#xff0c;凭借其独特的机体结构、高效的动力系统、先进的飞行控制系统等技术优势&#xff0c;在众多无…

【位运算】基础算法总结

目录 基础位运算给一个数n&#xff0c;确定它的二进制表示的第x位是0还是1将一个数n的二进制表示的第x位修改成1将一个数n的二进制表示的第x位修改成0位图思想&#xff08;哈希表&#xff09;提取一个数&#xff08;n&#xff09;二进制表示中的最右侧的1&#xff08;lowbit&am…

KIVY 3D Rotating Monkey Head¶

7 Python Kivy Projects (With Full Tutorials) – Pythonista Planet KIVY 3D Rotating Monkey Head kivy 3D 旋转猴子头How to display rotating monkey example in a given layout. Issue #6688 kivy/kivy GitHub 3d 模型下载链接 P99 - Download Free 3D model by …

vue学习笔记(购物车小案例)

用一个简单的购物车demo来回顾一下其中需要注意的细节。 先看一下最终效果 功能&#xff1a; &#xff08;1&#xff09;全选按钮和下面的商品项的选中状态同步&#xff0c;当下面的商品全部选中时&#xff0c;全选勾选&#xff0c;反之&#xff0c;则不勾选。 &#xff08…

前端扫盲:cookie、localStorage和sessionStorage

cookie、localStorage和sessionStorage都是存储数据的方式&#xff0c;他们之间有什么不同&#xff0c;各有什么应用场景&#xff0c;本文为您一一解答。 一、什么是cookie、localStorage和sessionStorage 1. Cookie是一种存储在用户计算机上的小型文本文件&#xff0c;由服务…

和干瘪的列表说拜拜,看看卡片列表的精彩演绎

在移动UI设计中&#xff0c;卡片列表是一种常见的设计模式&#xff0c;可以将干瘪的列表变得更加生动和精彩。卡片列表通过使用卡片元素来呈现列表项&#xff0c;每个卡片可以包含图片、标题、描述、按钮等内容&#xff0c;使得列表项更加丰富和有趣。 以下是一些卡片列表的精彩…

网络防御保护——网络安全概述

一.网络安全概念 1.网络空间---一个由信息基础设施组成相互依赖的网络 。 网络空间&#xff0c;它跟以前我们所理解的网络不一样了&#xff0c;它不光是一个虚无缥缈的&#xff0c;虚拟的东西&#xff0c;它更多的是融入了我们这些真实的物理设备&#xff0c;也就意味着这个网…

数据库作业2

需求 一、在数据库中创建一个表student&#xff0c;用于存储学生信息 CREATE TABLE student( id INT PRIMARY KEY, name VARCHAR(20) NOT NULL, grade FLOAT ); 1、向student表中添加一条新记录 记录中id字段的值为1&#xff0c;name字段的值为"monkey"&#xff0…

1分钟了解LangChain是什么?

一: LangChain介绍 LangChain 是一个基于大型语言模型&#xff08;LLM&#xff09;开发应用程序的框架, 它旨在简化语言模型应用的开发流程&#xff0c;特别是在构建对话系统和其他基于语言的AI解决方案时.目标是将复杂的语言模型技术转化为可通过简单API调用实现的功能&#…

第T4周:使用TensorFlow实现猴痘病识别

&#x1f368; 本文为&#x1f517;365天深度学习训练营 中的学习记录博客&#x1f356; 原作者&#xff1a;K同学啊 文章目录 一、前期工作1.设置GPU&#xff08;如果使用的是CPU可以忽略这步&#xff09;2. 导入数据3. 查看数据 二、数据预处理1、加载数据2、数据可视化3、再…

Splunk Enterprise 中的严重漏洞允许远程执行代码

Splunk 是搜索、监控和分析机器生成大数据的软件领先提供商&#xff0c;为其旗舰产品 Splunk Enterprise 发布了紧急安全更新。 这些更新解决了几个构成重大安全风险的关键漏洞&#xff0c;包括远程代码执行 (RCE) 的可能性。 受影响的版本包括 * 9.0.x、9.1.x 和 9.2.x&…

竞赛 深度学习OCR中文识别 - opencv python

文章目录 0 前言1 课题背景2 实现效果3 文本区域检测网络-CTPN4 文本识别网络-CRNN5 最后 0 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 &#x1f6a9; **基于深度学习OCR中文识别系统 ** 该项目较为新颖&#xff0c;适合作为竞赛课题方向&#xff0c;…