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 Jan 13, 2023
1 parent e9cc10e commit bd6d99a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,7 @@ Others:
更新内容:
- [important] [feat] 新菜单显示当前版本和支持xray最低版本 #113
- [important] [feat] 验证super-xray最新版本 #114
- [feat] 子域名扫描加入关闭删除选项 #118
- [improve] 支持关闭时删除被动扫描生成的ca文件 #117
- [improve] 子域名扫描的输入过滤 #116
- [improve] 子域名扫描的输入过滤 #116
- [improve] 禁用子域名扫描的ip-only选项 #119
11 changes: 10 additions & 1 deletion src/main/java/com/chaitin/xray/form/SubdomainForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<text value="Generate"/>
</properties>
</component>
<grid id="291a0" binding="optionPanel" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="291a0" binding="optionPanel" layout-manager="GridLayoutManager" row-count="1" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="1" row-span="1" col-span="6" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand Down Expand Up @@ -134,6 +134,15 @@
<text value="only web apps"/>
</properties>
</component>
<component id="f2576" class="javax.swing.JCheckBox" binding="delCheckbox">
<constraints>
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-725535"/>
<text value="delete reports when exit"/>
</properties>
</component>
</children>
</grid>
</children>
Expand Down
40 changes: 31 additions & 9 deletions src/main/java/com/chaitin/xray/form/SubdomainForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Locale;
import java.util.UUID;

Expand Down Expand Up @@ -96,6 +97,7 @@ private void initLang() {
onlyWebCheckbox.setText("只输出web应用子域名");
openResultButton.setText("打开输出文件");
generateButton.setText("随机文件名");
delCheckbox.setText("关闭时删除报告");
} else {
targetLabel.setText(" Target");
outputLabel.setText(" Output File");
Expand All @@ -106,6 +108,7 @@ private void initLang() {
onlyWebCheckbox.setText("only web apps");
openResultButton.setText("Open Result");
generateButton.setText("Generate");
delCheckbox.setText("delete reports when exit");
}
}

Expand All @@ -126,9 +129,11 @@ private void initLang() {
private JButton openResultButton;
private JButton generateButton;
private JPanel optionPanel;
private JCheckBox delCheckbox;
private static String xray;
private static boolean running = false;
private static String outputFilePath;
public static String outputFilePath;
public static ArrayList<String> outputFilePathList = new ArrayList<>();

public void initOpenOutput() {
openResultButton.addActionListener(e -> {
Expand All @@ -150,13 +155,6 @@ public void initOpenOutput() {
} catch (Exception ignored) {
}
new Thread(() -> ExecUtil.execOpen(tempOutput)).start();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
Files.delete(Paths.get(tempOutput));
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}));
} else {
if (MainForm.LANG == MainForm.CHINESE) {
JOptionPane.showMessageDialog(this.subdomainPanel, "目前没有输出文件");
Expand All @@ -169,6 +167,21 @@ public void initOpenOutput() {
}

public SubdomainForm(XrayCmd xrayCmd) {

Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (delCheckbox.isSelected()) {
for (String path : outputFilePathList) {
try {
Files.delete(Paths.get(path));
} catch (Exception ignored) {
}
}
}
}));

delCheckbox.setSelected(true);
onlyIpCheckbox.setSelected(false);
onlyIpCheckbox.setEnabled(false);
xray = xrayCmd.getXray();
initLang();
initOpenOutput();
Expand Down Expand Up @@ -217,6 +230,11 @@ public SubdomainForm(XrayCmd xrayCmd) {
return;
}
outputFilePath = outPath.toAbsolutePath().toString();
if (StringUtil.notEmpty(outputFilePath)) {
outputFilePathList.add(outputFilePath);
String copyName = outputFilePath.split("\\.html")[0] + "copy.html";
outputFilePathList.add(copyName);
}
}

String target = targetText.getText();
Expand Down Expand Up @@ -303,7 +321,7 @@ public SubdomainForm(XrayCmd xrayCmd) {
generateButton.setText("Generate");
confPanel.add(generateButton, new GridConstraints(1, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
optionPanel = new JPanel();
optionPanel.setLayout(new GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1));
optionPanel.setLayout(new GridLayoutManager(1, 6, new Insets(0, 0, 0, 0), -1, -1));
optionPanel.setBackground(new Color(-528927));
confPanel.add(optionPanel, new GridConstraints(2, 1, 1, 6, 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));
bruteForceCheckBox = new JCheckBox();
Expand All @@ -318,6 +336,10 @@ public SubdomainForm(XrayCmd xrayCmd) {
onlyWebCheckbox.setBackground(new Color(-725535));
onlyWebCheckbox.setText("only web apps");
optionPanel.add(onlyWebCheckbox, new GridConstraints(0, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
delCheckbox = new JCheckBox();
delCheckbox.setBackground(new Color(-725535));
delCheckbox.setText("delete reports when exit");
optionPanel.add(delCheckbox, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
configPanel.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, new Dimension(-1, 5), null, null, 0, false));
outputPanel = new JScrollPane();
Expand Down

0 comments on commit bd6d99a

Please sign in to comment.