搞了网上好多的下载,不是在本地上乱安装东西,都是运行不起来,索性就捋一下哪个可行,哪个比较用,看到有Java解析源码,经过调试可以使用,就开发了一个图形工具,用了图形工具,也就想着搞一下wind 安装程序,本着开源精神就把这个流程记录一下,方便大家,
1、破解源码和图形源码
package com.winscp.decode; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; public class Main { /** * ./core/Security.h:#define PWALG_SIMPLE_FLAG 0xFF */ public static final int PWALG_SIMPLE_FLAG = 0xFF; /** * ./core/Security.h:#define PWALG_SIMPLE_MAGIC 0xA3 */ public static final char PWALG_SIMPLE_MAGIC = 0xA3; private JFrame jFrame = new JFrame("破解WinScp密码"); private Container c = jFrame.getContentPane(); private JLabel a1 = new JLabel("username:"); private JTextField username = new JTextField(); private JLabel a2 = new JLabel("配置中password:"); private JPasswordField password = new JPasswordField(); private JLabel a3 = new JLabel("hostname:"); private JTextField hostname = new JTextField(); private JLabel a4 = new JLabel("解密后的密码:"); private JTextField passwordAffter = new JTextField(); private JButton okbtn = new JButton("解密"); private JButton cancelbtn = new JButton("清空"); public Main() { //设置窗体的位置及大小 jFrame.setBounds(600, 200, 300, 220); //设置一层相当于桌布的东西 c.setLayout(new BorderLayout());//布局管理器 //设置按下右上角X号后关闭 jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //初始化--往窗体里放其他控件 init(); //设置窗体可见 jFrame.setVisible(true); } public void init() { /*标题部分--North*/ // JPanel titlePanel = new JPanel(); // titlePanel.setLayout(new FlowLayout()); // titlePanel.add(new JLabel("破解WinScp密码")); // c.add(titlePanel, "North"); /*输入部分--Center*/ JPanel fieldPanel = new JPanel(); fieldPanel.setLayout(null); a1.setBounds(20, 20, 100, 20); a2.setBounds(20, 40, 100, 20); a3.setBounds(20, 60, 100, 20); a4.setBounds(20, 80, 100, 20); fieldPanel.add(a1); fieldPanel.add(a2); fieldPanel.add(a3); fieldPanel.add(a4); username.setBounds(120, 20, 120, 20); password.setBounds(120, 40, 120, 20); hostname.setBounds(120, 60, 120, 20); passwordAffter.setBounds(120, 80, 120, 20); passwordAffter.setEditable(false); fieldPanel.add(username); fieldPanel.add(password); fieldPanel.add(hostname); fieldPanel.add(passwordAffter); c.add(fieldPanel, "Center"); /*按钮部分--South*/ JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); buttonPanel.add(okbtn); buttonPanel.add(cancelbtn); c.add(buttonPanel, "South"); // okbtn.addActionListener((e) -> { listerner(); // }); // cancelbtn.addActionListener((e) -> { // listerner(); // }); } public void listerner() { //确认按下去获取 okbtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String uname = username.getText(); String pwd = String.valueOf(password.getPassword()); String hostnames=hostname.getText(); if(uname==null || pwd==null|| hostnames==null || "".equals(uname) || "".equals(pwd)|| "".equals(hostnames)){ JOptionPane.showConfirmDialog(null, "输入有误!不能有空值!", "choose one", JOptionPane.YES_NO_OPTION); }else{ passwordAffter.setText(decryptPassword( pwd, uname , hostnames)); } } }); //取消按下去清空 cancelbtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { username.setText(""); password.setText(""); hostname.setText(""); } }); } //测试 public static void main(String[] args) { new Main(); } static String decryptPassword(String fPassword,String username ,String hostname){ List<Character> password = new ArrayList<Character>(); for( int i=0; i< fPassword.length(); ++i){ password.add((char) Integer.parseInt(""+fPassword.charAt(i),16)); } String unicodeKey=username + hostname; System.out.println("unicodeKey = " + unicodeKey); String key = unicodeKey; String result = ""; char length, flag; flag = simpleDecryptNextChar(password); System.out.println("flag = " + (int) flag); if(flag == PWALG_SIMPLE_FLAG){ /* Dummy = */ simpleDecryptNextChar(password); length = simpleDecryptNextChar(password); } else length = flag; System.out.println("length = " + (int) length); int newStart = ((int)simpleDecryptNextChar(password)*2); System.out.println("newStart = " + newStart + ", password.size() = " + password.size()); removeItems(password, 0, newStart); for(int index=0; index < length; ++index) result += simpleDecryptNextChar(password); System.out.println("result = " + result); if(flag == PWALG_SIMPLE_FLAG) { if (!result.substring(0, key.length()).equals(key)) result = ""; else result = result.substring(key.length()); } return result; } /** * unsigned char simpleDecryptNextChar(RawByteString &Str) { if (Str.Length() > 0) { unsigned char Result = (unsigned char) ~((((PWALG_SIMPLE_STRING.Pos(Str.c_str()[0])-1) << 4) + ((PWALG_SIMPLE_STRING.Pos(Str.c_str()[1])-1) << 0)) ^ PWALG_SIMPLE_MAGIC); Str.Delete(1, 2); return Result; } else return 0x00; } * @param str * @return */ static public char simpleDecryptNextChar(java.util.List<Character> str){ if(str.size() > 0){ char result = unsignedChar( ~( ( unsignedChar(str.get(0) << 4) + str.get(1) // Remove bitshift overflow bits. ) ^ PWALG_SIMPLE_MAGIC ) ); removeItems(str, 0, 2); return result; } else return 0x00; } /** * Cut off anything over 255. * @param v * @return */ static char unsignedChar(int v){ return (char) (v & 0xFF); } /** * Remove items from list */ static void removeItems(java.util.List lst, int start, int end){ for(int i=0; i<end-start; ++i){ lst.remove(start); } } }
2、 Java jar打包成exe应用程序(超详细)
https://blog.csdn.net/m0_37701381/article/details/104163877
附件上我的https://download.csdn.net/download/liu_dong_kang/20833014安装地址