开发工具系列---【finalshell连接时间长了,忘记密码,如何查看密码?】
1.把连接的服务器导出。
2.打开导出的文件,找到password的编码后的字符串,复制。
3.运行下面代码,即可查看原来的密码,把紫色部分的字符串替换成上一步复制的字符串。
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("Pn1vK14tShb4G7ByTjidNtT/EoQ8ic6f")); } 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; } }
愿你走出半生,归来仍是少年!
分类:
【开发工具系列】
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?