Skip to content

Commit

Permalink
Fix date issue
Browse files Browse the repository at this point in the history
  • Loading branch information
egru committed Mar 1, 2018
1 parent 3569137 commit 27cb04d
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 35 deletions.
16 changes: 8 additions & 8 deletions .idea/artifacts/awssigner_jar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 12 additions & 26 deletions src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package burp;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

public class BurpExtender implements IBurpExtender, ITab, IHttpListener
Expand All @@ -22,28 +23,9 @@ public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks)

callbacks.setExtensionName("AWS Signer");

SwingUtilities.invokeLater(() -> {
panel = new JPanel(new BorderLayout());

JPanel labels = new JPanel(new GridLayout(0, 1));
JPanel inputs = new JPanel(new GridLayout(0, 1));

panel.add(labels, BorderLayout.WEST);
panel.add(inputs, BorderLayout.CENTER);

accessKey = new JTextField();
secretKey = new JTextField();
region = new JTextField();
service = new JTextField();
callbacks.registerContextMenuFactory(new Menu());

labels.add(new JLabel("Access Key: "), BorderLayout.WEST);
inputs.add(accessKey, BorderLayout.CENTER);
labels.add(new JLabel("Secret Key: "), BorderLayout.WEST);
inputs.add(secretKey, BorderLayout.CENTER);
labels.add(new JLabel("Region: "), BorderLayout.WEST);
inputs.add(region, BorderLayout.CENTER);
labels.add(new JLabel("Service: "), BorderLayout.WEST);
inputs.add(service, BorderLayout.CENTER);
SwingUtilities.invokeLater(() -> {

callbacks.customizeUiComponent(panel);

Expand All @@ -64,16 +46,20 @@ public Component getUiComponent() {
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) throws Exception {

IRequestInfo request = helpers.analyzeRequest(messageInfo.getRequest());
if (Menu.getStatus()) {
IRequestInfo request = helpers.analyzeRequest(messageInfo.getRequest());

java.util.List<String> headers = request.getHeaders();
java.util.List<String> headers = request.getHeaders();

if (headers.stream().anyMatch((str -> str.trim().toLowerCase().contains("x-amz-date")))){
if (headers.stream().anyMatch((str -> str.trim().toLowerCase().contains("x-amz-date")))){

byte[] signedRequest = Utility.signRequest(messageInfo, helpers, service.getText(), region.getText(), accessKey.getText(), secretKey.getText());
byte[] signedRequest = Utility.signRequest(messageInfo, helpers, service.getText(), region.getText(), accessKey.getText(), secretKey.getText());

messageInfo.setRequest(signedRequest);
messageInfo.setRequest(signedRequest);

}
}


}
}
59 changes: 59 additions & 0 deletions src/main/java/burp/Menu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package burp;

import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;

public class Menu implements IContextMenuFactory {
private static boolean status = false;

@Override
public List<JMenuItem> createMenuItems(IContextMenuInvocation invocation) {
List<JMenuItem> list;
list = new ArrayList<>();
JMenuItem item;
if (status){
item = new JMenuItem("Disable AWS Signer");
} else {
item = new JMenuItem("Enable AWS Signer");
}

item.addMouseListener(new MouseListener() {

public void mouseClicked(MouseEvent e) {

}


public void mousePressed(MouseEvent e) {

}


public void mouseReleased(MouseEvent e) {
status = !status;

}


public void mouseEntered(MouseEvent e) {

}


public void mouseExited(MouseEvent e) {

}
});
list.add(item);

return list;
}

public static boolean getStatus(){
return status;
}

}
82 changes: 82 additions & 0 deletions src/main/java/burp/TabPanel.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="burp.BurpExtender">
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="5" 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>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="ae305" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Access Key: "/>
</properties>
</component>
<vspacer id="78274">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="41dbd" class="javax.swing.JTextField" binding="accessKey">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="7e645" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Secret Key:"/>
</properties>
</component>
<component id="7960f" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Region: "/>
</properties>
</component>
<component id="1aea9" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Service: "/>
</properties>
</component>
<component id="f508d" class="javax.swing.JTextField" binding="secretKey">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="c59c4" class="javax.swing.JTextField" binding="region">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="15b58" class="javax.swing.JTextField" binding="service">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>
3 changes: 2 additions & 1 deletion src/main/java/burp/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public static byte[] signRequest(IHttpRequestResponse messageInfo, IExtensionHel
newHeaders.remove(amzDate);

SimpleDateFormat amz = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
amz.setTimeZone(TimeZone.getTimeZone("GMT"));
amz.setTimeZone(TimeZone.getTimeZone("UTC"));
String amzdate = amz.format(new Date());

SimpleDateFormat dateStamp = new SimpleDateFormat("yyyyMMdd");
dateStamp.setTimeZone(TimeZone.getTimeZone("UTC"));
String dateStampString = dateStamp.format(new Date());

headerMap.put("x-amz-date",amzdate);
Expand Down
12 changes: 12 additions & 0 deletions src/main/main.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: com.google.guava:guava:23.2-jre" level="project" />
</component>
</module>

0 comments on commit 27cb04d

Please sign in to comment.