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 16, 2023
1 parent 7b4f456 commit 1b0759d
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![](https://img.shields.io/github/v/release/4ra1n/super-xray)](https://github.com/4ra1n/super-xray/releases/latest)
![](https://img.shields.io/github/downloads/4ra1n/super-xray/total)
![](https://img.shields.io/badge/build-JDK8-orange)
![](https://img.shields.io/badge/Code%20Lines-10018-orange)
![](https://img.shields.io/badge/Code%20Lines-10104-orange)

[English Version](doc/README.md)

Expand Down
2 changes: 1 addition & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![](https://img.shields.io/github/v/release/4ra1n/super-xray)](https://github.com/4ra1n/super-xray/releases/latest)
![](https://img.shields.io/github/downloads/4ra1n/super-xray/total)
![](https://img.shields.io/badge/build-JDK8-orange)
![](https://img.shields.io/badge/Code%20Lines-10018-orange)
![](https://img.shields.io/badge/Code%20Lines-10104-orange)

## Introduce

Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/chaitin/xray/form/MainForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@
</component>
</children>
</grid>
<grid id="72ed5" binding="startScanPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="72ed5" binding="startScanPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="5" 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 @@ -589,7 +589,7 @@
<grid id="d137c" binding="mitmPanel" layout-manager="GridLayoutManager" row-count="3" 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="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"/>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-725535"/>
Expand Down Expand Up @@ -681,6 +681,14 @@
</component>
</children>
</grid>
<component id="c5181" class="javax.swing.JButton" binding="copyCmdButton">
<constraints>
<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"/>
</constraints>
<properties>
<text value="复制当前命令"/>
</properties>
</component>
</children>
</grid>
<grid id="a03a5" binding="otherPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
Expand Down
101 changes: 97 additions & 4 deletions src/main/java/com/chaitin/xray/form/MainForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.swing.plaf.FontUIResource;
import javax.swing.text.StyleContext;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.*;
Expand Down Expand Up @@ -186,6 +187,7 @@ public class MainForm {
public JCheckBox delCaCheckBox;
private JButton ajpScanButton;
private JLabel ajpLabel;
private JButton copyCmdButton;
private SubdomainForm subdomainInstance;
private AJPScanForm ajpInstance;

Expand Down Expand Up @@ -221,8 +223,24 @@ public void init() {
frame.setVisible(true);
});

lookupCmdButton.addActionListener(e ->
JOptionPane.showMessageDialog(this.SuperXray, xrayCmd.buildCmd()));
lookupCmdButton.addActionListener(e -> {
String[] cmd = xrayCmd.buildCmd();
StringBuilder sb = new StringBuilder();
for (String c : cmd) {
if (c.length() < 50) {
if (StringUtil.notEmpty(c)) {
sb.append(c);
sb.append("\n");
}
} else {
String t = c.substring(0, 44);
sb.append(t);
sb.append("......");
sb.append("\n");
}
}
JOptionPane.showMessageDialog(this.SuperXray, sb.toString().trim());
});
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -857,6 +875,47 @@ public void initRawScanConfig() {
private static boolean activeRunning = false;

public void initActiveScan() {
copyCmdButton.addActionListener(e -> {
XrayCmd temp = new XrayCmd();
temp.setXray(xrayCmd.getXray());
temp.setModule("webscan");
temp.setConfig(String.format("%s", configPath));
temp.setOthers(null);

String uuid = UUID.randomUUID().toString();
if (htmlRadioButton.isSelected()) {
temp.setOutputPrefix("--html-output");
temp.setOutput(Paths.get(String.format("./xray-%s.html", uuid)).toFile().getAbsolutePath());
}
if (jsonRadioButton.isSelected()) {
temp.setOutputPrefix("--json-output");
temp.setOutput(Paths.get(String.format("./xray-%s.txt", uuid)).toFile().getAbsolutePath());
}
if (cliRadioButton.isSelected()) {
temp.setOutput(null);
}

temp.setPoc(xrayCmd.getPoc());
temp.setInput(xrayCmd.getInput());
temp.setInputPrefix(xrayCmd.getInputPrefix());

String[] cmdA = temp.buildCmd();
StringBuilder sb = new StringBuilder();
for (String cmd : cmdA) {
sb.append(cmd);
sb.append(" ");
}

Toolkit.getDefaultToolkit()
.getSystemClipboard()
.setContents(new StringSelection(sb.toString().trim()), null);

if (LANG == CHINESE) {
JOptionPane.showMessageDialog(this.SuperXray, "已复制");
} else {
JOptionPane.showMessageDialog(this.SuperXray, "Copy");
}
});
activeScanButton.addActionListener(e -> {
if (!StringUtil.notEmpty(xrayCmd.getInput()) ||
!StringUtil.notEmpty(xrayCmd.getInputPrefix())) {
Expand All @@ -871,6 +930,17 @@ public void initActiveScan() {
if (!activeRunning) {

int value = (int) parallelSet.getValue();

if (value > 100 || value < 1) {
if (LANG == CHINESE) {
JOptionPane.showMessageDialog(this.SuperXray, "设置有误");
} else {
JOptionPane.showMessageDialog(this.SuperXray, "Error Config");
}
parallelSet.setValue(30);
return;
}

configObj.put("parallel", value);
refreshConfig();

Expand Down Expand Up @@ -1120,6 +1190,15 @@ public void initMitmScan() {
}

int value = (int) parallelSet.getValue();
if (value > 100 || value < 1) {
if (LANG == CHINESE) {
JOptionPane.showMessageDialog(this.SuperXray, "设置有误");
} else {
JOptionPane.showMessageDialog(this.SuperXray, "Error Config");
}
parallelSet.setValue(30);
return;
}
configObj.put("parallel", value);
refreshConfig();

Expand Down Expand Up @@ -1497,6 +1576,15 @@ private void initOther() {
delCaCheckBox.setSelected(true);
parallelSet.addChangeListener(e -> {
int value = (int) parallelSet.getValue();
if (value > 100 || value < 1) {
if (LANG == CHINESE) {
JOptionPane.showMessageDialog(this.SuperXray, "设置有误");
} else {
JOptionPane.showMessageDialog(this.SuperXray, "Error Config");
}
parallelSet.setValue(30);
return;
}
configObj.put("parallel", value);
refreshConfig();
});
Expand Down Expand Up @@ -1650,6 +1738,7 @@ public void refreshLang() {
tipParallelLabel.setText("Concurrency");
delCaCheckBox.setText("Delete CA When Exit");
ajpScanButton.setText("AJP Scan");
copyCmdButton.setText("Copy Cmd");
} else if (LANG == CHINESE) {
xrayPathLabel.setText("你选择的xray文件是:");
noteLabel.setText("<html> 注意:在 Mac OS 中请用 control+c/v 复制/粘贴 </html>");
Expand Down Expand Up @@ -1748,6 +1837,7 @@ public void refreshLang() {
tipParallelLabel.setText("并发越高发包越快");
delCaCheckBox.setText("关闭后删除ca文件");
ajpScanButton.setText("AJP服务扫描");
copyCmdButton.setText("复制当前命令");
}
}

Expand Down Expand Up @@ -2358,7 +2448,7 @@ private static JMenuBar createMenuBar() {
reverseServerButton.setText("配置服务端");
reverseConfigPanel.add(reverseServerButton, new GridConstraints(1, 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));
startScanPanel = new JPanel();
startScanPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
startScanPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
startScanPanel.setBackground(new Color(-725535));
rightConfigPanel.add(startScanPanel, new GridConstraints(5, 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));
startScanPanel.setBorder(BorderFactory.createTitledBorder(null, "启动", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
Expand All @@ -2368,7 +2458,7 @@ private static JMenuBar createMenuBar() {
mitmPanel = new JPanel();
mitmPanel.setLayout(new GridLayoutManager(3, 6, new Insets(0, 0, 0, 0), -1, -1));
mitmPanel.setBackground(new Color(-725535));
startScanPanel.add(mitmPanel, 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));
startScanPanel.add(mitmPanel, new GridConstraints(1, 0, 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));
mitmScanButton = new JButton();
mitmScanButton.setText("开启被动扫描");
mitmPanel.add(mitmScanButton, 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));
Expand Down Expand Up @@ -2399,6 +2489,9 @@ private static JMenuBar createMenuBar() {
ajpLabel = new JLabel();
ajpLabel.setText("Tomcat AJP");
mitmPanel.add(ajpLabel, new GridConstraints(2, 3, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
copyCmdButton = new JButton();
copyCmdButton.setText("复制当前命令");
startScanPanel.add(copyCmdButton, 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));
otherPanel = new JPanel();
otherPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
otherPanel.setBackground(new Color(-725535));
Expand Down

0 comments on commit 1b0759d

Please sign in to comment.