Skip to content

Commit

Permalink
remove script editor, not that useful, from v2.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-m0nst3r committed Aug 4, 2021
1 parent 94b1527 commit fb2e977
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 206 deletions.
20 changes: 0 additions & 20 deletions burpy.iml

This file was deleted.

12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.m0nst3r</groupId>
<artifactId>burpy</artifactId>
<version>2.4.3-SNAPSHOT</version>
<version>2.4.4-SNAPSHOT</version>
<name>burpy</name>
<description>burp plugin to run custom python</description>
<properties>
Expand Down Expand Up @@ -103,11 +103,11 @@
</dependency>

<!-- Local dependency that must be installed locally with Maven -->
<dependency>
<groupId>com.fifesoft</groupId>
<artifactId>rsyntaxtextarea</artifactId>
<version>2.6.1.edited</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.fifesoft</groupId>-->
<!-- <artifactId>rsyntaxtextarea</artifactId>-->
<!-- <version>2.6.1.edited</version>-->
<!-- </dependency>-->

</dependencies>
</project>
190 changes: 10 additions & 180 deletions src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
@@ -1,48 +1,25 @@
package burp;

import burp.ui.MessageDialog;
import net.razorvine.pyro.PyroProxy;
import net.razorvine.pyro.PyroURI;

import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.*;
import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultStyledDocument;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;

import burp.ui.MessageDialog;
import org.apache.commons.lang3.ArrayUtils;
import org.fife.ui.rsyntaxtextarea.FileLocation;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rsyntaxtextarea.TextEditorPane;
import org.fife.ui.rtextarea.RTextScrollPane;

import net.razorvine.pyro.*;


public class BurpExtender implements IBurpExtender, ITab, ActionListener, IContextMenuFactory, MouseListener, IExtensionStateListener, IIntruderPayloadProcessor,IHttpListener {

public static final int PLATFORM_ANDROID = 0;
public static final int PLATFORM_IOS = 1;
public static final int PLATFORM_GENERIC = 2;

private IBurpExtenderCallbacks callbacks;
private IExtensionHelpers helpers;

Expand All @@ -65,17 +42,13 @@ public class BurpExtender implements IBurpExtender, ITab, ActionListener, IConte
private JCheckBox chckbxPro;
private JCheckBox chckbxAuto;

public JMenuItem itemEnc;
public JMenuItem itemDec;

public Boolean should_pro = false;
public Boolean should_auto = false;


private Style redStyle;
private Style greenStyle;
DefaultStyledDocument documentServerStatus;
DefaultStyledDocument documentApplicationStatus;

DefaultStyledDocument documentServerStatusButtons;
DefaultStyledDocument documentApplicationStatusButtons;
Expand All @@ -86,18 +59,11 @@ public class BurpExtender implements IBurpExtender, ITab, ActionListener, IConte

private IContextMenuInvocation currentInvocation;



private JButton loadPyFileButton;
private JButton savePyFileButton;

private JButton clearConsoleButton;
private JButton reloadScript;

private JEditorPane pluginConsoleTextArea;

private TextEditorPane pyEditorTextArea;

private Thread stdoutThread;
private Thread stderrThread;

Expand Down Expand Up @@ -183,21 +149,6 @@ public void run() {

// Tabbed Pabel
final JTabbedPane tabbedPanel = new JTabbedPane();
tabbedPanel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {

SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {

showHideButtons(tabbedPanel.getSelectedIndex());

}
});

}
});

// **** TABS

Expand Down Expand Up @@ -358,23 +309,14 @@ public void actionPerformed(ActionEvent actionEvent) {
configurationConfPanel.add(pyroHostPanel);
configurationConfPanel.add(pyroPortPanel);
configurationConfPanel.add(burpyPathPanel);
// configurationConfPanel.add(chckbxNewCheckBox, autoSignBox);

configurationConfPanel.add(chckbxPro,shouldProBox);
configurationConfPanel.add(chckbxAuto, shouldAutoBox);

// **** END CONFIGURATION PANEL

// **** PY EDITOR PANEL / CONSOLE
pyEditorTextArea = new TextEditorPane();
pyEditorTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PYTHON);
pyEditorTextArea.setCodeFoldingEnabled(false);
RTextScrollPane sp = new RTextScrollPane(pyEditorTextArea);
pyEditorTextArea.setFocusable(true);
// **** END PY EDITOR PANEL / CONSOLE

tabbedPanel.add("Configurations",configurationConfPanel);
tabbedPanel.add("PY Editor",sp);

// *** CONSOLE
pluginConsoleTextArea = new JEditorPane("text/html", "<font color=\"green\"><b>*** Burpy Console ***</b></font><br/><br/>");
Expand Down Expand Up @@ -424,15 +366,6 @@ public void actionPerformed(ActionEvent actionEvent) {
reloadScript.setActionCommand("reloadScript");
reloadScript.addActionListener(BurpExtender.this);

loadPyFileButton = new JButton("Load PY file");
loadPyFileButton.setActionCommand("loadPyFile");
loadPyFileButton.addActionListener(BurpExtender.this);

savePyFileButton = new JButton("Save PY file");
savePyFileButton.setActionCommand("savePyFile");
savePyFileButton.addActionListener(BurpExtender.this);


JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
separator.setBorder(BorderFactory.createMatteBorder(3, 0, 3, 0, Color.ORANGE));

Expand All @@ -448,11 +381,6 @@ public void actionPerformed(ActionEvent actionEvent) {
rightSplitPane.add(separator,gbc);


// TAB PY EDITOR
rightSplitPane.add(loadPyFileButton,gbc);
rightSplitPane.add(savePyFileButton,gbc);


splitPane.setLeftComponent(consoleTabbedSplitPane);
splitPane.setRightComponent(rightSplitPane);

Expand All @@ -470,55 +398,6 @@ public void actionPerformed(ActionEvent actionEvent) {
callbacks.registerHttpListener(this);

}



private void showHideButtons(int indexTabbedPanel) {

switch(indexTabbedPanel) {

// CONFIGURATIONS
case 0:

SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {

loadPyFileButton.setVisible(false);
savePyFileButton.setVisible(false);


}

});

break;

// PY editor
case 1:

SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {

loadPyFileButton.setVisible(true);
savePyFileButton.setVisible(true);

}

});

break;

default:
printException(null,"ShowHideButtons: index not found");
break;

}

}

@SuppressWarnings("unchecked")
public void getMethods() {
Expand Down Expand Up @@ -730,35 +609,6 @@ public void run() {



} else if(command.equals("loadPyFile")) {

File pyFile = new File(burpyPath.getText().trim());
final FileLocation fl = FileLocation.create(pyFile);

SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {

try {
pyEditorTextArea.load(fl, null);
} catch (IOException e) {
printException(e,"Exception loading PY file");
}

}
});

} else if(command.equals("savePyFile")) {

try {
pyEditorTextArea.save();
// TODO: stop pyro and start pyro

} catch (IOException e) {
printException(e,"Error saving PY file");
}

} else if (burpyMethods.contains(command)) {
IHttpRequestResponse[] selectedItems = currentInvocation.getSelectedMessages();
byte selectedInvocationContext = currentInvocation.getInvocationContext();
Expand Down Expand Up @@ -1162,19 +1012,15 @@ public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequ
List<String> headers = null;
String pyroUrl = "PYRO:BridaServicePyro@" + pyroHost.getText() +":" + pyroPort.getText();
if (should_auto) {
// itemEnc.doClick();

if (toolFlag == IBurpExtenderCallbacks.TOOL_SCANNER ||
toolFlag == IBurpExtenderCallbacks.TOOL_REPEATER ||
toolFlag == IBurpExtenderCallbacks.TOOL_INTRUDER) {
if (messageIsRequest) {
// itemEnc.doClick();
// Get request bytes

byte[] request = messageInfo.getRequest();


//String urlDecodedContentParameterValue = helpers.urlDecode(contentParameter.getValue());
String ret = "";
// String pyroUrl = "PYRO:BridaServicePyro@localhost:19999";
try {
PyroProxy pp = new PyroProxy(new PyroURI(pyroUrl));

Expand All @@ -1188,31 +1034,18 @@ public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequ
stderr.println(exceptionElements[i].toString());
}
}
// Create the new parameter
//IParameter newTestParameter = helpers.buildParameter(contentParameter.getName(), helpers.urlEncode(ret), contentParameter.getType());
// Create the new request with the updated parameter
//byte[] newRequest = helpers.updateParameter(request, newTestParameter);

IRequestInfo nreqInfo = helpers.analyzeRequest(ret.getBytes());
headers = nreqInfo.getHeaders();
int nbodyOff = nreqInfo.getBodyOffset();
byte[] nbody = ret.substring(nbodyOff).getBytes();

byte[] newRequest = helpers.buildHttpMessage(headers, nbody); //

// Update the messageInfo object with the modified request (otherwise the request remains the old one)

messageInfo.setRequest(newRequest);

}else {

// byte[] request = messageInfo.getRequest();
//
// IRequestInfo requestInfo = helpers.analyzeRequest(request);
//
// String requestStr = new String(request);
//
// byte[] reqbody = requestStr.substring(requestInfo.getBodyOffset()).getBytes();
// if(reqbody != null) {
// Get response bytes
byte[] response = messageInfo.getResponse();

Expand All @@ -1230,15 +1063,12 @@ public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequ
stderr.println(exceptionElements[i].toString());
}
}
// Update the messageInfo object with the modified request (otherwise the request remains the old one)
// byte[] newResponse = ArrayUtils.addAll(Arrays.copyOfRange(response, 0, bodyOffset),ret.getBytes());
IResponseInfo nresInfo = helpers.analyzeResponse(ret.getBytes());
int nbodyOff = nresInfo.getBodyOffset();
byte[] nbody = ret.substring(nbodyOff).getBytes();
headers = nresInfo.getHeaders();
byte[] newResponse = helpers.buildHttpMessage(headers, nbody);
messageInfo.setResponse(newResponse);
// }
}

}
Expand Down

0 comments on commit fb2e977

Please sign in to comment.