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

news2024/10/6 2:54:19

一、从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.coloradmin.cn/o/1903927.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

python读取指定文件夹下的图片(glob获取)

python读取指定文件夹下的图片&#xff08;glob获取&#xff09; 定义traverse_images函数&#xff0c;仅需要改变下根路径即可 glob是python中用来查找符合特定规则的文件路径名的函数 import os from glob import globdef traverse_images (folder_path):image_formats …

ComfyUI如何高效率使用多Lora

Efficient 工作流 {"last_node_id": 29,"last_link_id": 56,"nodes": [{"id": 26,"type": "LoRA Stacker","pos": [540,270],"size": {"0": 320,"1": 322},"flag…

增强安全防护,解读智慧校园系统的登录日志功能

在构建智慧校园系统时&#xff0c;登录日志功能扮演着不可或缺的角色&#xff0c;它不仅是系统安全的守护者&#xff0c;也是提升管理效率和确保合规性的有力工具。这一机制详细记录每次登录尝试的方方面面&#xff0c;涵盖了时间戳、用户身份、登录来源的IP地址乃至使用的设备…

python脚本“文档”撰写——“诱骗”ai撰写“火火的动态”python“自动”脚本文档

“火火的动态”python“自动”脚本文档&#xff0c;又从ai学习搭子那儿“套”来&#xff0c;可谓良心质量&#x1f44d;&#x1f44d;。 (笔记模板由python脚本于2024年07月07日 15:15:33创建&#xff0c;本篇笔记适合喜欢钻研python和页面源码的coder翻阅) 【学习的细节是欢悦…

Python遥感开发之批量对TIF数据合并

Python遥感开发之批量对TIF数据合并 1 原始数据展示2 按照年份合成春夏秋冬季节数据3 完整代码实现 前言&#xff1a;通常对遥感数据按照月和年或者季节进行分析&#xff0c;我们需要对我们下载的8天或者16天数据按照需求进行合并&#xff0c;对数据的合并一般可以采取均值法、…

移动校园(5):课程表数据获取及展示

首先写下静态页面&#xff0c;起初打算做成一周的课表&#xff0c;由于是以小程序的形式展现&#xff0c;所以显示一周的话会很拥挤&#xff0c;所以放弃下面的方案&#xff0c;改作一次显示一天 改后结果如下&#xff0c;后期还会进行外观优化 真正困难的部分是数据获取 大家大…

高德地图 key 和安全密钥使用

参考高德地图&#xff1a;JS API 安全密钥使用 高德地图 key 和安全密钥使用 一、通过明文方式设置参数查看如下成功后返回的信息 二、通过代理服务器转发实验&#xff1a;通过本地地址转发返回错的错误信息&#xff0c;如下通过正确的项目的的服务地址&#xff0c;返回正常参数…

Flink,spark对比

三&#xff1a;az 如何调度Spark、Flink&#xff0c;MR 任务 首先&#xff0c;使用java编写一个spark任务&#xff0c;定义一个类&#xff0c;它有main方法&#xff0c;里面写好逻辑&#xff0c;sparkConf 和JavaSparkContext 获取上下文&#xff0c;然后打成一个jar包&#xf…

深度学习之网络构建

目标 选择合适的神经网络 卷积神经网络&#xff08;CNN&#xff09;&#xff1a;我们处理图片、视频一般选择CNN 循环神经网络&#xff08;RNN&#xff09;&#xff1a;我们处理时序数据一般选择RNN 超参数的设置 为什么训练的模型的错误率居高不下 如何调测出最优的超参数 …

Node.js介绍 , 安装与使用

1.Node.js 1 什么是Node.js 官网&#xff1a;https://nodejs.org/zh-cn/ 中文学习网&#xff1a;http://nodejs.cn/learn1.Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境。Node.js 使用了一个事件驱动、非阻塞式 I/O 的模型,使其轻量又高效。 2.前端的底层 html…

C++、QT企业管理系统

目录 一、项目介绍 二、项目展示 三、源码获取 一、项目介绍 人事端&#xff1a; 1、【产品中心】产品案列、新闻动态的发布&#xff1b; 2、【员工管理】新增、修改、删除、搜索功能&#xff1b;合同以图片的方式上传 3、【考勤总览】根据日期显示所有员工上班、下班时间…

下载nvm 管理多个node版本并切换

nvm管理多个node版本并切换 安装nvm时不能安装任何node版本&#xff08;先删除node再安装nvm&#xff09;&#xff0c;保证系统无任何node.js残留 1. 卸载node 控制面板中卸载nodejs 删除以下文件夹&#xff1a; C:\Program Files (x86)\Nodejs C:\Program Files\Nodejs C…

聚类分析方法(一)

目录 一、聚类分析原理&#xff08;一&#xff09;聚类分析概述&#xff08;二&#xff09;聚类的数学定义&#xff08;三&#xff09;簇的常见类型&#xff08;四&#xff09;聚类框架及性能要求&#xff08;五&#xff09;簇的距离 二、划分聚类算法&#xff08;一&#xff0…

【matlab】状态空间模型与传递函数模型的建立与转换

目录 SISO系统 MIMO系统 状态空间模型 状态空间模型到传递函数模型的转换 传递函数模型到状态空间模型的转换 (1) 转换函数ss() (2) 规范形转换函数canon() (3) 常微分方程(传递函数)转换为状态空间模型函数dif2ss() 状态空间模型的变换 特征值、特征向量与广义特征向量的计算…

进程控制-wait和waitpid进程回收

wait 阻塞函数 函数作用&#xff1a; 1. 阻塞并等待子进程退出 2. 回收子进程残留资源 3. 获取子进程结束状态&#xff08;退出原因&#xff09; pid_t wait(int *wstatus); 返回值&#xff1a; ‐1 : 回收失败&#xff0c;已经没有子进程了 >0 : 回收子进程对应的…

线上问题---反思与回顾

线上问题一&#xff1a;麦哲伦2.0 人群配置不生效 发现背景&#xff1a;产品发现三层模型部分计划个别测试计划圈选人群特征与数仓统计数据的人群不一致&#xff0c;向值班人员反馈 根因定位&#xff1a; &#xff08;1&#xff09;用户配置三层模型计划时&#xff0c;配置单…

文心一言 VS 讯飞星火 VS chatgpt (297)-- 算法导论22.1 1题

一、给定有向图的邻接链表&#xff0c;需要多长时间才能计算出每个结点的出度(发出的边的条数)&#xff1f;多长时间才能计算出每个结点的入度(进入的边的条数)&#xff1f;如果要写代码&#xff0c;请用go语言。 文心一言&#xff1a; 计算出度 对于有向图的邻接链表表示&a…

rufus-4.5 制作 Clonezilla(再生龙)启动盘报syslinux-6.04下载错误

1、官网下载rufus 官网下载rufus-4.5&#xff0c;下载地址&#xff1a;https://rufus.ie/downloads/ 2、下载再生龙&#xff08;Clonezilla&#xff09; 下载最新版本&#xff1a; Clonezilla live 版本: 3.1.2-22&#xff1a;https://sourceforge.net/projects/clonezill…

在 Docker 容器中运行 Vite 开发环境,有这两个问题要注意

容器化开发给我们带来了很多便捷&#xff0c;但是在开发环境下也有一些问题要注意&#xff0c;如果不解决这些问题&#xff0c;你的开发体验不会很好。 容器启动正常&#xff0c;却无法访问 我们用 Docker 启动一个 Vite Vue3 项目的开发环境后&#xff0c;发现端口日志一切…

Springboot使用WebSocket发送消息

1. 创建springboot项目&#xff0c;引入spring-boot-starter-websocket依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-websocket</artifactId></dependency>完整项目依赖 <?xml ver…