Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
4ra1n committed Mar 13, 2023
1 parent f6549c3 commit 6e1a08e
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,14 @@ Others:
## 1.6

更新内容:
- [important] 给RAD联动提供一种批量执行的办法 #155
- [important] RAD联动支持Cookie配置 #153
- [feat] RAD联动支持一键复制RAD命令 #154
- [bug] 备份xray目录原来的config.yaml文件 #152
- [feat] RAD 联动支持拖拽功能 #151
- [feat] request 支持自定义 user-agent #149
- [feat] 允许设置请求Cookie内容 #150
- [feat] radium support file input #148 (同#155)

下载:
- super-xray-1.6.jar 版本通过`java -jar super-xray-1.6.jar`启动
Expand Down
46 changes: 39 additions & 7 deletions src/main/java/com/chaitin/xray/form/RadForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</component>
</children>
</scrollpane>
<grid id="c75a2" binding="radConfigPanel" layout-manager="GridLayoutManager" row-count="4" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="c75a2" binding="radConfigPanel" layout-manager="GridLayoutManager" row-count="5" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<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"/>
Expand All @@ -64,7 +64,7 @@
</component>
<component id="3fb0d" class="javax.swing.JTextField" binding="urlText">
<constraints>
<grid row="1" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="1" column="1" row-span="1" col-span="4" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
Expand All @@ -80,7 +80,7 @@
</component>
<component id="3fe05" class="javax.swing.JTextField" binding="radFileText">
<constraints>
<grid row="0" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="0" column="1" row-span="1" col-span="4" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
Expand All @@ -91,15 +91,15 @@
</component>
<component id="8fa81" class="javax.swing.JButton" binding="startRadButton" default-binding="true">
<constraints>
<grid row="3" column="2" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="4" column="3" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Start Rad"/>
</properties>
</component>
<component id="a282" class="javax.swing.JLabel" binding="startLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=" Start"/>
Expand All @@ -123,20 +123,52 @@
</component>
<component id="b8f0a" class="javax.swing.JButton" binding="confirmButton" default-binding="true">
<constraints>
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="2" column="3" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Confirm"/>
</properties>
</component>
<component id="fa810" class="javax.swing.JButton" binding="copyCommandButton" default-binding="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="4" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Copy Command"/>
</properties>
</component>
<component id="e1e90" class="javax.swing.JLabel" binding="fileLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=" Target File"/>
</properties>
</component>
<component id="26b50" class="javax.swing.JTextField" binding="fileText">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="f1b48" class="javax.swing.JButton" binding="exportButton" default-binding="true">
<constraints>
<grid row="3" column="3" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Export"/>
</properties>
</component>
<component id="fee4e" class="javax.swing.JButton" binding="choseButton">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Chose"/>
</properties>
</component>
</children>
</grid>
</children>
Expand Down
97 changes: 90 additions & 7 deletions src/main/java/com/chaitin/xray/form/RadForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class RadForm {
private JLabel radCookieLabel;
private JButton confirmButton;
private JButton copyCommandButton;
private JTextField fileText;
private JButton exportButton;
private JButton choseButton;
private JLabel fileLabel;

private static RadCmd radCmd;
public volatile boolean stop = false;
Expand Down Expand Up @@ -115,6 +119,9 @@ private void initLang() {
targetLabel.setText(" 目标url");
radCookieLabel.setText(" 设置Cookie");
copyCommandButton.setText("复制命令");
choseButton.setText("选择文件");
exportButton.setText("导出命令表");
fileLabel.setText("批量目标文件");
outputPanel.setBorder(BorderFactory.createTitledBorder(
null, "控制台",
TitledBorder.DEFAULT_JUSTIFICATION,
Expand All @@ -128,6 +135,9 @@ private void initLang() {
targetLabel.setText(" Target URL");
radCookieLabel.setText(" Cookie");
copyCommandButton.setText("Copy Command");
choseButton.setText("Chose");
exportButton.setText("Export");
fileLabel.setText("Target File");
outputPanel.setBorder(BorderFactory.createTitledBorder(
null, "Console",
TitledBorder.DEFAULT_JUSTIFICATION,
Expand Down Expand Up @@ -187,6 +197,65 @@ private void initCookie() {
}).start());
}

private void initExport() {
choseButton.addActionListener(e -> {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int option = fileChooser.showOpenDialog(new JFrame());
if (option == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
String absPath = file.getAbsolutePath();
Path path = Paths.get(absPath);
if (!Files.exists(path)) {
JOptionPane.showMessageDialog(radPane, "File Not Found");
return;
}
fileText.setText(absPath);
}
});

exportButton.addActionListener(e -> {
String file = fileText.getText();
if (!StringUtil.notEmpty(file)) {
JOptionPane.showMessageDialog(radPane, "Chose File First");
return;
}
Path filePath = Paths.get(file);
if (!Files.exists(filePath)) {
JOptionPane.showMessageDialog(radPane, "File Not Found");
return;
}
try {
String data = new String(Files.readAllBytes(filePath));
String[] split = data.split("\n");
StringBuilder ss = new StringBuilder();
for (String s : split) {
s = s.trim();
if (!StringUtil.notEmpty(s)) {
continue;
}
if (s.endsWith("\r")) {
s = s.substring(0, s.length() - 1);
}
radCmd.setTargetUrl(s);
String[] cmd = radCmd.buildCmd();
StringBuilder sb = new StringBuilder();
for (String a : cmd) {
sb.append(a);
sb.append(" ");
}
ss.append(sb.toString().trim());
ss.append("\n");
}
Files.write(Paths.get("rad-cmd.txt"), ss.toString().getBytes());
radCmd.setTargetUrl(null);
JOptionPane.showMessageDialog(radPane, "rad-cmd.txt");
} catch (Exception ex) {
JOptionPane.showMessageDialog(radPane, "Error");
}
});
}

public RadForm(String inputPort) {
initLang();

Expand Down Expand Up @@ -266,7 +335,10 @@ public synchronized void drop(DropTargetDropEvent evt) {
.getSystemClipboard()
.setContents(new StringSelection(sb.toString().trim()), null);
JOptionPane.showMessageDialog(radPane, "Success");
radCmd.setTargetUrl(null);
});

initExport();
}

{
Expand Down Expand Up @@ -304,38 +376,49 @@ public synchronized void drop(DropTargetDropEvent evt) {
outputTextArea.setLineWrap(true);
outputPanel.setViewportView(outputTextArea);
radConfigPanel = new JPanel();
radConfigPanel.setLayout(new GridLayoutManager(4, 4, new Insets(0, 0, 0, 0), -1, -1));
radConfigPanel.setLayout(new GridLayoutManager(5, 5, new Insets(0, 0, 0, 0), -1, -1));
radConfigPanel.setBackground(new Color(-12828863));
radPane.add(radConfigPanel, 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));
targetLabel = new JLabel();
targetLabel.setText(" Target URL");
radConfigPanel.add(targetLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
urlText = new JTextField();
radConfigPanel.add(urlText, new GridConstraints(1, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
radConfigPanel.add(urlText, new GridConstraints(1, 1, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
choseRadFileButton = new JButton();
choseRadFileButton.setText("Chose Rad File");
radConfigPanel.add(choseRadFileButton, 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));
radFileText = new JTextField();
radFileText.setEditable(false);
radFileText.setEnabled(false);
radConfigPanel.add(radFileText, new GridConstraints(0, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
radConfigPanel.add(radFileText, new GridConstraints(0, 1, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
startRadButton = new JButton();
startRadButton.setText("Start Rad");
radConfigPanel.add(startRadButton, new GridConstraints(3, 2, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
radConfigPanel.add(startRadButton, new GridConstraints(4, 3, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
startLabel = new JLabel();
startLabel.setText(" Start");
radConfigPanel.add(startLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
radConfigPanel.add(startLabel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
radCookieLabel = new JLabel();
radCookieLabel.setText(" Cookie");
radConfigPanel.add(radCookieLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
radCookieText = new JTextField();
radConfigPanel.add(radCookieText, 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));
confirmButton = new JButton();
confirmButton.setText("Confirm");
radConfigPanel.add(confirmButton, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
radConfigPanel.add(confirmButton, new GridConstraints(2, 3, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
copyCommandButton = new JButton();
copyCommandButton.setText("Copy Command");
radConfigPanel.add(copyCommandButton, new GridConstraints(3, 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));
radConfigPanel.add(copyCommandButton, new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
fileLabel = new JLabel();
fileLabel.setText(" Target File");
radConfigPanel.add(fileLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
fileText = new JTextField();
radConfigPanel.add(fileText, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
exportButton = new JButton();
exportButton.setText("Export");
radConfigPanel.add(exportButton, new GridConstraints(3, 3, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
choseButton = new JButton();
choseButton.setText("Chose");
radConfigPanel.add(choseButton, new GridConstraints(3, 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));
}

/**
Expand Down

0 comments on commit 6e1a08e

Please sign in to comment.