Skip to content

Commit

Permalink
初始版本
Browse files Browse the repository at this point in the history
  • Loading branch information
retnullyu committed Dec 1, 2021
0 parents commit 4e4741d
Show file tree
Hide file tree
Showing 10 changed files with 614 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/out
/.idea
*.class
src/META-INF/*
.DS_Store
target/
*.iml%
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# burp加载dirsearch
## 项目介绍
项目改自[sqlmap4burp++](https://github.com/c0ny1/sqlmap4burp-plus-plus),其实本质都是一样,调用python启动本地[dirsearch](https://github.com/maurosoria/dirsearch),sqlmap读取request数据改为--raw即可

## 插件编译

```
mvn clean package
```

## 参考项目
* https://github.com/blueroutecn/Burpsuite4Extender
* https://github.com/difcareer/sqlmap4burp
* https://github.com/c0ny1/sqlmap4burp-plus-plus
45 changes: 45 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>retnull.top</groupId>
<artifactId>burp2dirsearch</artifactId>
<version>0.1</version>

<dependencies>
<!-- https://mvnrepository.com/artifact/net.portswigger.burp.extender/burp-extender-api -->
<dependency>
<groupId>net.portswigger.burp.extender</groupId>
<artifactId>burp-extender-api</artifactId>
<version>1.7.22</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
22 changes: 22 additions & 0 deletions src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package burp;

import java.io.PrintWriter;

public class BurpExtender implements IBurpExtender {
public static IExtensionHelpers helpers;
public static IBurpExtenderCallbacks callbacks;
public static PrintWriter stdout;
public static PrintWriter stderr;

@Override
public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks) {
this.helpers = callbacks.getHelpers();
this.callbacks = callbacks;
this.stdout = new PrintWriter(callbacks.getStdout(),true);
this.stderr = new PrintWriter(callbacks.getStderr(),true);

callbacks.registerContextMenuFactory(new Menu());
callbacks.setExtensionName(String.format("%s %s",Config.getExtenderName(),Config.getExtenderVersion()));
stdout.println(Util.getBanner());
}
}
99 changes: 99 additions & 0 deletions src/main/java/burp/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package burp;

public class Config {
private static final String EXTENDER_NAME = "burp2dirsearch";
private static final String EXTENDER_VERSION = "0.1";
private static String PYTHON_NAME = "python3";
private static String DIRSEARCH_PATH = "dirsearch";
private static String REQUST_FILE_PATH = "";
private static String DIRSEARCH_OPTIONS_COMMAND = "";
private static String OS_TYPE;
private static boolean IS_INJECT = false;


public static String getExtenderName() {
return EXTENDER_NAME;
}

public static String getExtenderVersion() {
return EXTENDER_VERSION;
}

public static String getPythonName() {
try {
String val = BurpExtender.callbacks.loadExtensionSetting("PYTHON_NAME");
if(val == null){
return Config.PYTHON_NAME;
}else{
return val;
}
}catch(Exception e){
return Config.PYTHON_NAME;
}
}

public static void setPythonName(String pythonName) {
BurpExtender.callbacks.saveExtensionSetting("PYTHON_NAME", String.valueOf(pythonName));
Config.DIRSEARCH_PATH = pythonName;
}

public static String getDirsearch() {
try {
String val = BurpExtender.callbacks.loadExtensionSetting("DIRSEARCH_PATH");
if(val == null){
return Config.DIRSEARCH_PATH;
}else{
return val;
}
}catch(Exception e){
return Config.DIRSEARCH_PATH;
}
}

public static void setDirsearchPath(String dirsearch) {
BurpExtender.callbacks.saveExtensionSetting("DIRSEARCH_PATH", String.valueOf(dirsearch));
Config.DIRSEARCH_PATH = dirsearch;
}

public static String getRequstFilePath() {
return REQUST_FILE_PATH;
}

public static void setRequstFilePath(String requstFilePath) {
REQUST_FILE_PATH = requstFilePath;
}

public static String getDirsearchOptionsCommand() {
try {
String val = BurpExtender.callbacks.loadExtensionSetting("DIRSEARCH_OPTIONS_COMMAND");
if(val == null){
return Config.DIRSEARCH_OPTIONS_COMMAND;
}else{
return val;
}
}catch(Exception e){
return Config.DIRSEARCH_OPTIONS_COMMAND;
}
}

public static void setDirsearchOptionsCommand(String dirsearchOptionsCommand) {
BurpExtender.callbacks.saveExtensionSetting("DIRSEARCH_OPTIONS_COMMAND", String.valueOf(dirsearchOptionsCommand));
Config.DIRSEARCH_OPTIONS_COMMAND = dirsearchOptionsCommand;
}

public static String getOsType() {
return OS_TYPE;
}

public static void setOsType(String osType) {
OS_TYPE = osType;
}

public static boolean isIsInject() {
return IS_INJECT;
}

public static void setIsInject(boolean isInject) {
IS_INJECT = isInject;
}
}
138 changes: 138 additions & 0 deletions src/main/java/burp/ConfigDlg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package burp;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
* 配置窗口类,负责显示配置窗口,处理窗口消息
*/
public class ConfigDlg extends JDialog {
private final JPanel mainPanel = new JPanel();

private final JLabel lbPythonName = new JLabel("Python name:");
private final JTextField tfPythonName = new JTextField(30);
private final JLabel lbDirsearchPath = new JLabel("dirsearch path:");
private final JTextField tfDirsearchPath = new JTextField(30);
private final JButton btnBrowse = new JButton("Browse");
private final JLabel lbDirsearchOption = new JLabel("dirsearch option:");
private final JTextField tfDirsearchOption = new JTextField(30);
private final JLabel lbPrompt = new JLabel("Prompt:");

private final JButton btnOK = new JButton("OK");
private final JButton btnCancel = new JButton("Cancel");


public ConfigDlg(){
initGUI();
initEvent();
initValue();
this.setTitle("burp2dirsearch config");
}


/**
* 初始化UI
*/
private void initGUI(){
JLabel lbPythonNameHelp = new JLabel("?");
lbPythonNameHelp.setToolTipText("eg: python,python2,python3,py2,py3,...");
JLabel lbDirsearchOptionHelp = new JLabel("?");
lbDirsearchOptionHelp.setToolTipText("eg: --skip-on-status/size,-t...");

mainPanel.setLayout(new GridBagLayout());
mainPanel.add(lbPythonName,new GBC(0,0,2,1).setFill(GBC.BOTH).setInsets(10,10,2,0));
mainPanel.add(tfPythonName, new GBC(2,0,3,1).setFill(GBC.BOTH).setInsets(10,0,2,10));
mainPanel.add(lbPythonNameHelp,new GBC(5,0,6,1).setFill(GBC.BOTH).setInsets(10,0,2,10));
mainPanel.add(lbDirsearchPath,new GBC(0,1,2,1).setFill(GBC.BOTH).setInsets(10,10,2,0));
mainPanel.add(tfDirsearchPath,new GBC(2,1,3,1).setFill(GBC.BOTH).setInsets(10,0,2,10));
mainPanel.add(btnBrowse,new GBC(5,1,1,1).setFill(GBC.BOTH).setInsets(10,0,2,10));
mainPanel.add(lbDirsearchOption,new GBC(0,2,2,1).setFill(GBC.BOTH).setInsets(10,10,2,0));
mainPanel.add(tfDirsearchOption,new GBC(2,2,3,1).setFill(GBC.BOTH).setInsets(10,0,2,10));
mainPanel.add(lbDirsearchOptionHelp,new GBC(5,2,1,1).setFill(GBC.BOTH).setInsets(10,0,2,10));
mainPanel.add(btnOK,new GBC(0,3,1,1).setFill(GBC.BOTH).setInsets(10,10,10,0));
mainPanel.add(btnCancel,new GBC(1,3,1,1).setFill(GBC.BOTH).setInsets(10,0,10,10));

if(Util.getOSType() == Util.OS_LINUX){
lbPrompt.setText("Notice: The command will be copied to the clipboard. Paste it into Terminal!");
mainPanel.add(lbPrompt,new GBC(2,3,1,1).setFill(GBC.BOTH).setInsets(10,0,2,10));
}else if(Util.getOSType() == Util.OS_MAC){
lbPrompt.setText("Notice: Please ensure that Terminal is in running state!");
mainPanel.add(lbPrompt,new GBC(2,3,1,1).setFill(GBC.BOTH).setInsets(10,0,2,10));
}
lbPrompt.setForeground(new Color(0,0,255));

this.setModal(true);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.add(mainPanel);
//使配置窗口自动适应控件大小,防止部分控件无法显示
this.pack();
//居中显示配置窗口
Dimension screensize=Toolkit.getDefaultToolkit().getScreenSize();
this.setBounds(screensize.width/2-this.getWidth()/2,screensize.height/2-this.getHeight()/2,this.getWidth(),this.getHeight());
BurpExtender.callbacks.customizeUiComponent(this);
}


/**
* 初始化事件
*/
private void initEvent(){

btnBrowse.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);//设置只能选择目录
int returnVal = chooser.showOpenDialog(ConfigDlg.this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
String selectPath =chooser.getSelectedFile().getPath() ;
tfDirsearchPath.setText(selectPath);
chooser.hide();
}
}
});


btnOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Config.setIsInject(true);
Config.setPythonName(tfPythonName.getText().trim());
Config.setDirsearchPath(tfDirsearchPath.getText().trim());
Config.setDirsearchOptionsCommand(tfDirsearchOption.getText().trim());
ConfigDlg.this.dispose();
}
});

btnCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Config.setIsInject(false);
ConfigDlg.this.dispose();
}
});

this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
Config.setIsInject(false);
}
});

}


/**
* 为控件赋值
*/
public void initValue(){
tfPythonName.setText(Config.getPythonName());
//BurpExtender.stderr.println("Python name:"+Config.getPythonName());
tfDirsearchPath.setText(Config.getDirsearch());
tfDirsearchOption.setText(Config.getDirsearchOptionsCommand());
}
}
Loading

0 comments on commit 4e4741d

Please sign in to comment.