Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit a3117ff

Browse files
committed
NEW GUI
1 parent 8bf81d4 commit a3117ff

File tree

8 files changed

+230
-18
lines changed

8 files changed

+230
-18
lines changed

CHANGELOG.MD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ GUI 版本的使用和 CLI 版本基本一致,具体参考 README 文件
3636

3737
## 0.3
3838

39+
修改`JVM`阻止通过`HSDB``dump`字节码,支持`linux``windows`
40+
3941
更新日志:
40-
- [FEATURE] 参考beichen师傅议题阻止dump字节码的方法 #6
42+
- [FEATURE] 参考`beichen`师傅议题阻止dump字节码的方法 #6
4143
- [FEATURE] 应该对完整的所有的字节码进行加密 #3
4244
- [FEATURE] 优化打印的日志以及调试信息 #4
4345
- [FEATURE] ENGLISH DOC #1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ java -XX:+DisableAttachMechanism -agentpath:D:\abs-path\decrypter.dll=PACKAGE_NA
6969

7070
另外支持了简易的`GUI`版本,选择需要加密的`Jar`文件即可一键加密(仅支持`Windows`版)
7171

72-
![screenshot](img/001.png)
72+
![screenshot](img/010.png)
7373

7474
## 特点
7575

doc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ java -XX:+DisableAttachMechanism -agentpath:D:\abs-path\decrypter.dll=PACKAGE_NA
6666

6767
We also offer a straightforward GUI version that allows you to encrypt your chosen `Jar` file with a single click. (Available for Windows only)
6868

69-
![screenshot](../img/001.png)
69+
![screenshot](../img/010.png)
7070

7171
## Features
7272

img/010.png

8.63 KB
Loading

src/main/java/org/y4sec/encryptor/gui/MainForm.form

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
<grid id="27dc6" binding="masterPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="0" left="0" bottom="0" right="0"/>
55
<constraints>
6-
<xy x="20" y="20" width="500" height="400"/>
6+
<xy x="20" y="20" width="524" height="400"/>
77
</constraints>
88
<properties/>
99
<border type="none"/>
1010
<children>
11-
<grid id="8489f" binding="rootPanel" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
11+
<grid id="8489f" binding="rootPanel" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
1212
<margin top="0" left="0" bottom="0" right="3"/>
1313
<constraints>
1414
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -58,16 +58,16 @@
5858
</component>
5959
<component id="8d055" class="javax.swing.JLabel" binding="operationLabel">
6060
<constraints>
61-
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
61+
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
6262
</constraints>
6363
<properties>
6464
<text value="Operation"/>
6565
</properties>
6666
</component>
67-
<grid id="c5561" binding="operationPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
67+
<grid id="c5561" binding="operationPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
6868
<margin top="0" left="0" bottom="0" right="0"/>
6969
<constraints>
70-
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
70+
<grid row="3" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
7171
</constraints>
7272
<properties/>
7373
<border type="none"/>
@@ -85,11 +85,35 @@
8585
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
8686
</constraints>
8787
<properties>
88-
<text value="Export Agent Lib"/>
88+
<text value="Export Lib"/>
89+
</properties>
90+
</component>
91+
<component id="4cfba" class="javax.swing.JButton" binding="showCommandButton" default-binding="true">
92+
<constraints>
93+
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
94+
</constraints>
95+
<properties>
96+
<text value="Show Command"/>
8997
</properties>
9098
</component>
9199
</children>
92100
</grid>
101+
<component id="4c268" class="javax.swing.JLabel" binding="keyLabel">
102+
<constraints>
103+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
104+
</constraints>
105+
<properties>
106+
<text value="Your KEY"/>
107+
</properties>
108+
</component>
109+
<component id="c88c9" class="javax.swing.JTextField" binding="keyText">
110+
<constraints>
111+
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
112+
<preferred-size width="150" height="-1"/>
113+
</grid>
114+
</constraints>
115+
<properties/>
116+
</component>
93117
</children>
94118
</grid>
95119
<grid id="c12ed" binding="logPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

src/main/java/org/y4sec/encryptor/gui/MainForm.java

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import javax.swing.filechooser.FileNameExtensionFilter;
1111
import java.awt.*;
1212
import java.io.File;
13-
import java.io.PrintStream;
1413
import java.nio.file.Path;
1514
import java.nio.file.Paths;
1615

@@ -29,6 +28,13 @@ public class MainForm implements Constants {
2928
private JLabel packageLabel;
3029
private JLabel operationLabel;
3130
private JPanel operationPanel;
31+
private JLabel keyLabel;
32+
private JTextField keyText;
33+
private JButton showCommandButton;
34+
private static String pack;
35+
private static String globalKey;
36+
private static String libAbs;
37+
private static String jarAbs;
3238

3339
public static void start() {
3440
JFrame frame = new JFrame("code-encryptor-plus");
@@ -75,17 +81,56 @@ public MainForm() {
7581
log("jar is null");
7682
return;
7783
}
84+
String key = keyText.getText();
85+
if (key == null || key.isEmpty()) {
86+
log("jar is null");
87+
return;
88+
}
89+
key = key.trim();
90+
if (key.getBytes().length != 16) {
91+
JOptionPane.showMessageDialog(rootPanel, "KEY LENGTH MUST BE 16");
92+
return;
93+
}
94+
byte[] keyBytes = key.getBytes();
95+
96+
String finalKey = key;
7897
new Thread(() -> {
7998
JNIUtil.extractDllSo(EncryptorDLL, null, true);
8099
Path libPath = Paths.get(TempDir).resolve(EncryptorDLL);
81-
PatchHelper.patchJar(Paths.get(jar), libPath, packageName,new byte[]{});
100+
Path jarPath = Paths.get(jar);
101+
102+
PatchHelper.patchJar(jarPath, libPath, packageName, keyBytes);
103+
104+
String srcName = jarPath.getFileName().toString();
105+
jarAbs = Paths.get(String.format("%s_%s.jar", srcName.substring(0,
106+
srcName.lastIndexOf(".")), NewFileSuffix)).toAbsolutePath().toString();
107+
log("final key: " + finalKey);
108+
log("package: " + packageName);
109+
globalKey = finalKey;
110+
pack = packageName;
82111
}).start();
83112
});
84113

85114
exportAgentLibButton.addActionListener(e -> {
86115
JNIUtil.extractDllSo(DecrypterDLL, null, false);
87-
JOptionPane.showMessageDialog(rootPanel,
88-
"File: " + TempDir + "/" + "decrypter.dll");
116+
String sb = "File: " +
117+
TempDir +
118+
"/" +
119+
"decrypter.dll";
120+
libAbs = Paths.get(TempDir).resolve("decrypter.dll").toAbsolutePath().toString();
121+
JOptionPane.showMessageDialog(rootPanel, sb);
122+
});
123+
124+
showCommandButton.addActionListener(e -> {
125+
if (jarAbs.isEmpty() || pack.isEmpty() || libAbs.isEmpty() || globalKey.isEmpty()) {
126+
JOptionPane.showMessageDialog(rootPanel, "NOT ALLOWED");
127+
return;
128+
}
129+
JFrame frame = new JFrame("Show Command");
130+
frame.setContentPane(new Show(jarAbs, libAbs, pack, globalKey).rootPanel);
131+
frame.pack();
132+
frame.setVisible(true);
133+
frame.setResizable(false);
89134
});
90135
}
91136

@@ -107,7 +152,7 @@ public MainForm() {
107152
masterPanel = new JPanel();
108153
masterPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
109154
rootPanel = new JPanel();
110-
rootPanel.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 3), -1, -1));
155+
rootPanel.setLayout(new GridLayoutManager(4, 3, new Insets(0, 0, 0, 3), -1, -1));
111156
masterPanel.add(rootPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
112157
jarLabel = new JLabel();
113158
jarLabel.setText("Jar File");
@@ -124,16 +169,24 @@ public MainForm() {
124169
rootPanel.add(packageText, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
125170
operationLabel = new JLabel();
126171
operationLabel.setText("Operation");
127-
rootPanel.add(operationLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
172+
rootPanel.add(operationLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
128173
operationPanel = new JPanel();
129-
operationPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
130-
rootPanel.add(operationPanel, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
174+
operationPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
175+
rootPanel.add(operationPanel, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
131176
encryptJarFileButton = new JButton();
132177
encryptJarFileButton.setText("Encrypt Jar File");
133178
operationPanel.add(encryptJarFileButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
134179
exportAgentLibButton = new JButton();
135-
exportAgentLibButton.setText("Export Agent Lib");
180+
exportAgentLibButton.setText("Export Lib");
136181
operationPanel.add(exportAgentLibButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
182+
showCommandButton = new JButton();
183+
showCommandButton.setText("Show Command");
184+
operationPanel.add(showCommandButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
185+
keyLabel = new JLabel();
186+
keyLabel.setText("Your KEY");
187+
rootPanel.add(keyLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
188+
keyText = new JTextField();
189+
rootPanel.add(keyText, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
137190
logPanel = new JPanel();
138191
logPanel.setLayout(new GridLayoutManager(1, 1, new Insets(3, 3, 3, 3), -1, -1));
139192
masterPanel.add(logPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, new Dimension(500, 200), new Dimension(500, 200), new Dimension(500, 200), 0, false));
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.y4sec.encryptor.gui.Show">
3+
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
4+
<margin top="0" left="0" bottom="0" right="0"/>
5+
<constraints>
6+
<xy x="20" y="20" width="504" height="400"/>
7+
</constraints>
8+
<properties/>
9+
<border type="none"/>
10+
<children>
11+
<grid id="8cc15" binding="showPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
12+
<margin top="0" left="0" bottom="0" right="0"/>
13+
<constraints>
14+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
15+
</constraints>
16+
<properties/>
17+
<border type="none"/>
18+
<children>
19+
<component id="312fd" class="javax.swing.JButton" binding="copyButton" default-binding="true">
20+
<constraints>
21+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
22+
</constraints>
23+
<properties>
24+
<text value="Copy"/>
25+
</properties>
26+
</component>
27+
<component id="be4d2" class="javax.swing.JButton" binding="clearButton" default-binding="true">
28+
<constraints>
29+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
30+
</constraints>
31+
<properties>
32+
<text value="Clear"/>
33+
</properties>
34+
</component>
35+
</children>
36+
</grid>
37+
<scrollpane id="dd4ee" binding="scroll">
38+
<constraints>
39+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="1" use-parent-layout="false">
40+
<minimum-size width="500" height="100"/>
41+
<preferred-size width="500" height="100"/>
42+
<maximum-size width="500" height="100"/>
43+
</grid>
44+
</constraints>
45+
<properties/>
46+
<border type="none"/>
47+
<children>
48+
<component id="bea2f" class="javax.swing.JTextArea" binding="showArea">
49+
<constraints/>
50+
<properties/>
51+
</component>
52+
</children>
53+
</scrollpane>
54+
</children>
55+
</grid>
56+
</form>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package org.y4sec.encryptor.gui;
2+
3+
import com.intellij.uiDesigner.core.GridConstraints;
4+
import com.intellij.uiDesigner.core.GridLayoutManager;
5+
6+
import javax.swing.*;
7+
import java.awt.*;
8+
import java.awt.datatransfer.Clipboard;
9+
import java.awt.datatransfer.StringSelection;
10+
11+
public class Show {
12+
public JPanel rootPanel;
13+
private JTextArea showArea;
14+
private JButton copyButton;
15+
private JButton clearButton;
16+
private JPanel showPanel;
17+
private JScrollPane scroll;
18+
19+
public Show(String jarAbs, String libAbs, String pack, String key) {
20+
String base = "java -XX:+DisableAttachMechanism -agentpath:";
21+
base = base + libAbs + "=PACKAGE_NAME=" + pack + ",KEY=" + key + " -jar " + jarAbs;
22+
showArea.setText(base);
23+
24+
copyButton.addActionListener(e -> {
25+
String myString = showArea.getText();
26+
StringSelection stringSelection = new StringSelection(myString);
27+
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
28+
clipboard.setContents(stringSelection, null);
29+
JOptionPane.showMessageDialog(rootPanel, "Copy OK!");
30+
});
31+
32+
clearButton.addActionListener(e -> this.showArea.setText(null));
33+
}
34+
35+
public Show() {
36+
}
37+
38+
{
39+
// GUI initializer generated by IntelliJ IDEA GUI Designer
40+
// >>> IMPORTANT!! <<<
41+
// DO NOT EDIT OR ADD ANY CODE HERE!
42+
$$$setupUI$$$();
43+
}
44+
45+
/**
46+
* Method generated by IntelliJ IDEA GUI Designer
47+
* >>> IMPORTANT!! <<<
48+
* DO NOT edit this method OR call it in your code!
49+
*
50+
* @noinspection ALL
51+
*/
52+
private void $$$setupUI$$$() {
53+
rootPanel = new JPanel();
54+
rootPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
55+
showPanel = new JPanel();
56+
showPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
57+
rootPanel.add(showPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
58+
copyButton = new JButton();
59+
copyButton.setText("Copy");
60+
showPanel.add(copyButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
61+
clearButton = new JButton();
62+
clearButton.setText("Clear");
63+
showPanel.add(clearButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
64+
scroll = new JScrollPane();
65+
rootPanel.add(scroll, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, new Dimension(500, 100), new Dimension(500, 100), new Dimension(500, 100), 1, false));
66+
showArea = new JTextArea();
67+
scroll.setViewportView(showArea);
68+
}
69+
70+
/**
71+
* @noinspection ALL
72+
*/
73+
public JComponent $$$getRootComponent$$$() {
74+
return rootPanel;
75+
}
76+
77+
}

0 commit comments

Comments
 (0)