Skip to content

Commit

Permalink
修复了以下问题
Browse files Browse the repository at this point in the history
1.扫描历史展示界面没有扫描参数问题
2.添加了扫描默认参数可配置功能
  • Loading branch information
GitHubNull committed Jun 1, 2023
1 parent 561d432 commit e41f5d6
Show file tree
Hide file tree
Showing 17 changed files with 320 additions and 74 deletions.
91 changes: 52 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,48 @@
<version>0.0.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<!-- <maven.compiler.source>8</maven.compiler.source>-->
<!-- <maven.compiler.target>8</maven.compiler.target>-->
</properties>

<!-- <build>-->
<!-- <sourceDirectory>src</sourceDirectory>-->
<!-- <plugins>-->
<!-- <plugin>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!--&lt;!&ndash; <version>3.8.0</version>&ndash;&gt;-->
<!-- <configuration>-->
<!-- <source>11</source>-->
<!-- <target>11</target>-->
<!-- <encoding>UTF-8</encoding>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <artifactId>maven-assembly-plugin</artifactId>-->
<!-- <version>2.2</version>-->
<!-- <configuration>-->
<!-- <descriptorRefs>-->
<!-- <descriptorRef>jar-with-dependencies</descriptorRef>-->
<!-- </descriptorRefs>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>make-assembly</id>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>single</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- <resources>-->
<!-- <resource>-->
<!-- <directory>resources</directory>-->
<!-- </resource>-->
<!-- </resources>-->
<!-- </build>-->
<build>
<sourceDirectory>src/main/java</sourceDirectory>

<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
</build>

<dependencies>
<dependency>
Expand Down Expand Up @@ -114,5 +115,17 @@
</dependency>

</dependencies>
<!-- <build>-->
<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <source>9</source>-->
<!-- <target>9</target>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->

</project>
9 changes: 8 additions & 1 deletion src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,17 @@ private void loadCommandLines() {

String[] objectStrArray = tmp.split(GlobalStaticsVar.EXTENDER_CONFIG_SEPARATOR);

boolean configDefaultFlag = false;
for (String objectStr : objectStrArray) {
try {
// stdout.println(String.format("objectStr: %s", objectStr));
OptionsCommandLine optionsCommandLine = SerializeUtil.deserialize(objectStr);
if (null == optionsCommandLine) {
continue;
}
if (!configDefaultFlag && Boolean.TRUE.equals(optionsCommandLine.getWasDefault())) {
GlobalStaticsVar.DEFAULT_COMMAND_LINE_STR = optionsCommandLine.getCommandLineStr();
configDefaultFlag = true;
}
consoleTab.getcommandLineManagerPanel().getTableModel().addOptionsCommandLine(optionsCommandLine);
} catch (Exception e) {
stderr.println(e);
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/controller/ContextMenuFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import ui.component.ScanTaskConfigLevel2;
import ui.component.ScanTaskConfigLevel3;
import ui.component.ScanTaskConfigLevel4;
import utils.GlobalStaticsVar;
import utils.MyStringUtil;

import javax.swing.*;
Expand Down Expand Up @@ -82,11 +83,16 @@ private void initActionListening(IContextMenuInvocation contextMenuInvocation, J
for (IHttpRequestResponse httpRequestResponse : httpRequestResponses) {
String taskName = MyStringUtil.genTaskName();
String scanTaskCommandLineStr = "-threads 5";
if (!GlobalStaticsVar.DEFAULT_COMMAND_LINE_STR.trim().isEmpty()) {

scanTaskCommandLineStr = GlobalStaticsVar.DEFAULT_COMMAND_LINE_STR.trim();
}

try {
BurpExtender.startScanTask(taskName, scanTaskCommandLineStr, httpRequestResponse);
} catch (IOException ex) {
BurpExtender.stderr.println(ex.getMessage());
// throw new RuntimeException(ex);
throw new RuntimeException(ex);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/entities/CommandLineColumnName.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

public enum CommandLineColumnName {
ID("序号"),
WAS_DEFAULT("是否是默认参数"),
TAG("标签"),

COMMAND_LINE_STR("参数(s)字符串");

private final String text;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/entities/CommandLineColumnNameIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class CommandLineColumnNameIndex {
public final static int
ID_INDEX = 0,
TAG_INDEX = 1,
COMMAND_LINE_STR_INDEX = 2;
WAS_DEFAULT_INDEX = 1,
TAG_INDEX = 2,
COMMAND_LINE_STR_INDEX = 3;
}
4 changes: 3 additions & 1 deletion src/main/java/entities/OptionsCommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
public class OptionsCommandLine implements Comparable<OptionsCommandLine>, Serializable {
private final static long serialVersionUID = 1;
int id;
Boolean wasDefault;
String tag;
String commandLineStr;

public OptionsCommandLine(int id, String tag, String commandLineStr) {
public OptionsCommandLine(int id, String tag, String commandLineStr, Boolean wasDefault) {
this.id = id;
this.wasDefault = wasDefault;
this.tag = tag;
this.commandLineStr = commandLineStr;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/entities/YesOrNoInStringOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package entities;

public final class YesOrNoInStringOption {
public final static String YES = "是";
public final static String NO = "否";
}
6 changes: 6 additions & 0 deletions src/main/java/entities/YesOrNoIntegerOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package entities;

public final class YesOrNoIntegerOption {
public final static Integer YES = 1;
public final static Integer NO = 0;
}
49 changes: 37 additions & 12 deletions src/main/java/models/CommandLineTableModel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package models;

import entities.CommandLineColumnName;
import entities.CommandLineColumnNameIndex;
import entities.OptionsCommandLine;

import javax.swing.*;
Expand All @@ -10,7 +11,7 @@

public class CommandLineTableModel extends AbstractTableModel {
List<OptionsCommandLine> optionsCommandLineList = new ArrayList<>();
static final int STATIC_COLUMN_COUNT = 3;
static final int STATIC_COLUMN_COUNT = 4;

public void setScanTaskArgsList(List<OptionsCommandLine> optionsCommandLineList) {
this.optionsCommandLineList = optionsCommandLineList;
Expand All @@ -34,11 +35,13 @@ public Object getValueAt(int rowIndex, int columnIndex) {

OptionsCommandLine optionsCommandLine = optionsCommandLineList.get(rowIndex);
switch (columnIndex) {
case 0:
case CommandLineColumnNameIndex.ID_INDEX:
return optionsCommandLine.getId();
case 1:
case CommandLineColumnNameIndex.WAS_DEFAULT_INDEX:
return optionsCommandLine.getWasDefault();
case CommandLineColumnNameIndex.TAG_INDEX:
return optionsCommandLine.getTag();
case 2:
case 3:
return optionsCommandLine.getCommandLineStr();
default:
return null;
Expand All @@ -52,11 +55,13 @@ public String getColumnName(int column) {
}

switch (column) {
case 0:
case CommandLineColumnNameIndex.ID_INDEX:
return CommandLineColumnName.ID.toString();
case 1:
case CommandLineColumnNameIndex.WAS_DEFAULT_INDEX:
return CommandLineColumnName.WAS_DEFAULT.toString();
case CommandLineColumnNameIndex.TAG_INDEX:
return CommandLineColumnName.TAG.toString();
case 2:
case CommandLineColumnNameIndex.COMMAND_LINE_STR_INDEX:
return CommandLineColumnName.COMMAND_LINE_STR.toString();

default:
Expand All @@ -74,7 +79,9 @@ public Class<?> getColumnClass(int columnIndex) {
case 0:
return Integer.class;
case 1:
return Boolean.class;
case 2:
case 3:
return String.class;
default:
return null;
Expand All @@ -94,13 +101,19 @@ public void setValueAt(Object obj, int row, int col) {

OptionsCommandLine optionsCommandLine = optionsCommandLineList.get(row);
switch (col) {
case 1:
case CommandLineColumnNameIndex.WAS_DEFAULT_INDEX:
SwingUtilities.invokeLater(() -> {
optionsCommandLine.setWasDefault((Boolean) obj);
fireTableCellUpdated(row, col);
});
break;
case CommandLineColumnNameIndex.TAG_INDEX:
SwingUtilities.invokeLater(() -> {
optionsCommandLine.setTag((String) obj);
fireTableCellUpdated(row, col);
});
break;
case 2:
case CommandLineColumnNameIndex.COMMAND_LINE_STR_INDEX:
SwingUtilities.invokeLater(() -> {
optionsCommandLine.setCommandLineStr((String) obj);
fireTableCellUpdated(row, col);
Expand All @@ -126,7 +139,7 @@ public void addOptionsCommandLine(OptionsCommandLine optionsCommandLine) {
public void addOptionsCommandLine(String tag, String argsStr) {
SwingUtilities.invokeLater(() -> {
int id = optionsCommandLineList.size();
optionsCommandLineList.add(new OptionsCommandLine(id, tag, argsStr));
optionsCommandLineList.add(new OptionsCommandLine(id, tag, argsStr, false));
fireTableRowsInserted(id, id);
});
}
Expand All @@ -142,14 +155,26 @@ public synchronized void deleteOptionsCommandLineById(int id) {
});
}

public void updateWasDefaultById(int id, Boolean wasDefault) {
if (0 == optionsCommandLineList.size() || (0 > id || id >= optionsCommandLineList.size())) {
return;
}

SwingUtilities.invokeLater(() -> {
optionsCommandLineList.get(id).setWasDefault(wasDefault);
fireTableCellUpdated(id, 1);
});

}

public void updateTagById(int id, String tag) {
if (0 == optionsCommandLineList.size() || (0 > id || id >= optionsCommandLineList.size()) || (null == tag || tag.trim().isEmpty())) {
return;
}

SwingUtilities.invokeLater(() -> {
optionsCommandLineList.get(id).setTag(tag.trim());
fireTableCellUpdated(id, 1);
fireTableCellUpdated(id, 2);
});

}
Expand All @@ -161,7 +186,7 @@ public void updateCommandLinesById(int id, String commandLineStr) {

SwingUtilities.invokeLater(() -> {
optionsCommandLineList.get(id).setCommandLineStr(commandLineStr);
fireTableCellUpdated(id, 2);
fireTableCellUpdated(id, 3);
});
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/sqlmapApi/SqlMapApiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public void start() throws IOException {
cmdLine = new String[]{PYTHON_EXEC_PATH, "-u", SQLMAP_API_PATH, "-s", "-p", Integer.toString(SQLMAP_API_PORT)};
}

String tmp = String.join(",", cmdLine);
BurpExtender.stdout.println(String.format("SqlMapApiService.start() cmdLine: %s", tmp));
ProcessBuilder processBuilder = new ProcessBuilder(cmdLine);
sqlmapApiSubProcess = processBuilder.start();

Expand Down
11 changes: 9 additions & 2 deletions src/main/java/ui/component/ScanResultShowDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
import sqlmapApi.SqlMapApiClient;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.io.IOException;

public class ScanResultShowDialog extends JDialog {
public class ScanResultShowDialog extends JFrame {
JTextArea payloadTextArea;
JTextArea logsTextArea;

Expand All @@ -32,10 +33,12 @@ public ScanResultShowDialog(String taskId) {
payloadTextArea = new JTextArea();
payloadTextArea.setEditable(false);
JScrollPane payloadPanel = new JScrollPane(payloadTextArea);
payloadPanel.setBorder(new TitledBorder("payloads"));

logsTextArea = new JTextArea();
logsTextArea.setEditable(false);
JScrollPane logsPanel = new JScrollPane(logsTextArea);
logsPanel.setBorder(new TitledBorder("logs"));

JSplitPane resultPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, payloadPanel, logsPanel);

Expand All @@ -51,7 +54,7 @@ public ScanResultShowDialog(String taskId) {
add(southPanel, BorderLayout.SOUTH);

setSize(getPreferredSize());
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLocationRelativeTo(null);

getScanResult();
Expand Down Expand Up @@ -93,6 +96,8 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}

payloadTextArea.setText(data.toJSONString(JSONWriter.Feature.PrettyFormat));
setSize(getPreferredSize());
setLocationRelativeTo(null);
}
});

Expand Down Expand Up @@ -126,6 +131,8 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}

logsTextArea.setText(data.toJSONString(JSONWriter.Feature.PrettyFormat));
setSize(getPreferredSize());
setLocationRelativeTo(null);
}
});

Expand Down
Loading

0 comments on commit e41f5d6

Please sign in to comment.