Skip to content

Commit

Permalink
Merge pull request #20 from irsdl/early-adopter
Browse files Browse the repository at this point in the history
Early adopter to main
  • Loading branch information
irsdl authored Jan 29, 2024
2 parents b529b9e + 07b0359 commit a22ec66
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 25 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ repositories {
}

dependencies {
compileOnly "net.portswigger.burp.extensions:montoya-api:2023.10" //https://central.sonatype.com/artifact/net.portswigger.burp.extensions/montoya-api/
compileOnly "net.portswigger.burp.extensions:montoya-api:2023.12.1" //https://central.sonatype.com/artifact/net.portswigger.burp.extensions/montoya-api/
implementation "com.github.CoreyD97:Burp-Montoya-Utilities:54678c64" //https://jitpack.io/com/github/CoreyD97/Burp-Montoya-Utilities/
//implementation "com.google.code.gson:gson:2.10.1" //https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation "com.google.guava:guava:32.1.2-jre" //https://mvnrepository.com/artifact/com.google.guava/guava
implementation "org.apache.commons:commons-lang3:3.13.0" //https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation "com.formdev:flatlaf:3.2" //https://mvnrepository.com/artifact/com.formdev/flatlaf
implementation "org.springframework:spring-core:6.0.11" //https://mvnrepository.com/artifact/org.springframework/spring-core
implementation "com.google.guava:guava:32.1.3-jre" //https://mvnrepository.com/artifact/com.google.guava/guava
implementation "org.apache.commons:commons-lang3:3.14.0" //https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation "com.formdev:flatlaf:3.2.5" //https://mvnrepository.com/artifact/com.formdev/flatlaf
implementation "org.springframework:spring-core:6.0.15" //https://mvnrepository.com/artifact/org.springframework/spring-core
implementation "com.fifesoft:rsyntaxtextarea:3.3.4" //https://mvnrepository.com/artifact/com.fifesoft/rsyntaxtextarea/
implementation "com.fifesoft:autocomplete:3.3.1" //https://mvnrepository.com/artifact/com.fifesoft/autocomplete
implementation "org.reflections:reflections:0.10.2" // https://mvnrepository.com/artifact/org.reflections/reflections/0.10.2
implementation "org.reflections:reflections:0.10.2" // https://mvnrepository.com/artifact/org.reflections/reflections/

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class ExtensionSharedParameters extends BurpExtensionSharedParameters {
public boolean isTitleFilterNegative = false;
public boolean isTabGroupSupportedByDefault = false;
public boolean isSubTabScrollSupportedByDefault = false;
public String burpSupportedColorNames = "Red|Orange|Yellow|Green|Cyan|Blue|Pink|Magenta|Gray"; // from burp.api.montoya.core.HighlightColor
public HashMap<BurpUITools.MainTabs, Integer> filterOperationMode = new HashMap<>();
public HashMap<BurpUITools.MainTabs, LinkedList<Integer>> subTabPreviouslySelectedIndexHistory = new HashMap<>();
public HashMap<BurpUITools.MainTabs, LinkedList<Integer>> subTabNextlySelectedIndexHistory = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ public class ManualHighlighterRequestResponseHandler implements ProxyRequestHand
CapabilitySettings capabilitySettings;

// the shortest color is red and the longest is magenta in Burp Suite HighlightColor
String highlightPatternToBeRemovedStr = "tempcolor([a-z]{3,7}+)";
String highlightPatternStayStr = "permcolor([a-z]{3,7}+)";
Pattern highlightPatternToBeRemoved = Pattern.compile(highlightPatternToBeRemovedStr, Pattern.CASE_INSENSITIVE);
Pattern highlightPatternStayPattern = Pattern.compile(highlightPatternStayStr, Pattern.CASE_INSENSITIVE);
String highlightPatternToBeRemovedStr = "";
String highlightPatternStayStr = "";
Pattern highlightPatternToBeRemoved;
Pattern highlightPatternStayPattern;

public ManualHighlighterRequestResponseHandler(ExtensionSharedParameters sharedParameters, CapabilitySettings capabilitySettings) {
this.sharedParameters = sharedParameters;
this.capabilitySettings = capabilitySettings;

highlightPatternToBeRemovedStr = "tempcolor("+sharedParameters.burpSupportedColorNames+")";
highlightPatternStayStr = "permcolor("+sharedParameters.burpSupportedColorNames+")";
highlightPatternToBeRemoved = Pattern.compile(highlightPatternToBeRemovedStr, Pattern.CASE_INSENSITIVE);
highlightPatternStayPattern = Pattern.compile(highlightPatternStayStr, Pattern.CASE_INSENSITIVE);
}

// REQUEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ManualHighlighterSettings(ExtensionSharedParameters sharedParameters) {
"manualHighlightCapability",
Arrays.asList(CapabilityGroup.PROXY_REQUEST_HANDLER, CapabilityGroup.PROXY_RESPONSE_HANDLER, CapabilityGroup.WEBSOCKET_CREATION_HANDLER),
"ninja.burpsuite.extension.sharpener.capabilities.implementations.ManualHighlighterRequestResponseHandler",
10000));
10000, true));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public PwnFoxSettings(ExtensionSharedParameters sharedParameters) {
"pwnFoxSupportCapability",
Arrays.asList(CapabilityGroup.PROXY_REQUEST_HANDLER),
"ninja.burpsuite.extension.sharpener.capabilities.implementations.PwnFoxProxyRequestHandler",
50000));
50000, true));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ public class Capability implements Serializable {
public List<CapabilityGroup> capabilityGroupList = new ArrayList<>();
public String implementationClassName = ""; // this is used when loading the capability
public int order = 100000; // this is used when sorting the capabilities

public boolean enabledByDefault = false; // this is used when sorting the capabilities
// constructor for the capability
public Capability(String name, String description, String settingName, List<CapabilityGroup> capabilityGroupList, String implementationClassName) {
this(name, description, settingName, capabilityGroupList, implementationClassName, 100000);
this(name, description, settingName, capabilityGroupList, implementationClassName, 100000, false);
}

public Capability(String name, String description, String settingName, List<CapabilityGroup> capabilityGroupList, String implementationClassName, int order) {
public Capability(String name, String description, String settingName, List<CapabilityGroup> capabilityGroupList, String implementationClassName, int order, boolean enabledByDefault) {
this.name = name;
this.description = description;
this.settingName = settingName;
this.capabilityGroupList = capabilityGroupList;
this.implementationClassName = implementationClassName;
this.order = order;
this.enabledByDefault = enabledByDefault;
}

// create the class object for the implemented capability using implementationClassName and reflection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public CapabilitySettings(ExtensionSharedParameters sharedParameters, Capability

private void registerStateSetting() {
try {
sharedParameters.preferences.registerSetting(capability.settingName, boolean.class, false, Preferences.Visibility.GLOBAL);
sharedParameters.preferences.registerSetting(capability.settingName, boolean.class, capability.enabledByDefault, Preferences.Visibility.GLOBAL);
} catch (Exception e) {
//already registered setting
sharedParameters.printDebugMessage(e.getMessage());
Expand All @@ -25,8 +25,7 @@ private void registerStateSetting() {
}
}

public boolean isEnabled() {
return sharedParameters.preferences.safeGetSetting(capability.settingName, false);
public boolean isEnabled() {return sharedParameters.preferences.safeGetSetting(capability.settingName, capability.enabledByDefault);
}

public void setEnabled(boolean enabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ private void initParameters(String extensionName, String version, String extensi
this.isBurpPro = true;

try{
//TODO: replace this and minor version with the new method in MontoyaApi (buildNumber() --> its format is like YYYY_MM_RR_PPP_BBBBBB (Year, month, release, patch, build number)
this.burpMajorVersion = Double.parseDouble(montoyaApi.burpSuite().version().major());
}catch(Exception e){
// this means the major version now cannot be converted to numbers!
Expand Down Expand Up @@ -427,18 +428,34 @@ public JTabbedPane get_rootTabbedPaneUsingMontoya() {
if (this._rootTabbedPane == null) {
try {
JRootPane rootPane = ((JFrame) montoyaApi.userInterface().swingUtils().suiteFrame()).getRootPane();
set_rootTabbedPane((JTabbedPane) rootPane.getContentPane().getComponent(0));
Component firstComponent = rootPane.getContentPane().getComponent(0);

if (firstComponent instanceof JTabbedPane) {
set_rootTabbedPane((JTabbedPane) firstComponent);
} else {
// fix for version 2023.12.1-25776
set_rootTabbedPane((JTabbedPane) ((JLayeredPane) firstComponent).getComponent(1));
}
} catch (Exception e) {
// This is to find the root of the Burp Suite frame when the above fails
// We should not really be here
printlnError("A failure in get_rootTabbedPaneUsingMontoya() has occurred. Hopefully this will be recovered now.");
// Defining how our Burp Suite frame is
UiSpecObject uiSpecObject = new UiSpecObject();
uiSpecObject.set_objectType(JFrame.class);
uiSpecObject.set_isShowing(true);
UiSpecObject uiSpecObject_for_rootPane = new UiSpecObject();
uiSpecObject_for_rootPane.set_objectType(JFrame.class);
uiSpecObject_for_rootPane.set_isShowing(true);

JRootPane rootPane = ((JFrame) UIWalker.findUIObjectInComponents(JFrame.getWindows(), uiSpecObject_for_rootPane)).getRootPane();

UiSpecObject uiSpecObject_for_JTabbedPane = new UiSpecObject();
uiSpecObject_for_JTabbedPane.set_objectType(JTabbedPane.class);
uiSpecObject_for_JTabbedPane.set_isShowing(true);
uiSpecObject_for_JTabbedPane.set_isJComponent(true);
uiSpecObject_for_JTabbedPane.set_minJComponentCount(2);

JTabbedPane jTabbedPane = ((JTabbedPane) UIWalker.findUIObjectInSubComponents(rootPane, 4, uiSpecObject_for_JTabbedPane));

JRootPane rootPane = ((JFrame) UIWalker.findUIObjectInComponents(JFrame.getWindows(), uiSpecObject)).getRootPane();
set_rootTabbedPane((JTabbedPane) rootPane.getContentPane().getComponent(0));
set_rootTabbedPane(jTabbedPane);
}
}
return this._rootTabbedPane;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/extension.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Sharpener
version=4.2
version=4.5
url=https://github.com/irsdl/BurpSuiteSharpenerEx
issueTracker=https://github.com/irsdl/BurpSuiteSharpenerEx/issues
copyright=Released as open source under AGPL license\nOriginally released by MDSec - https://www.mdsec.co.uk/\nDeveloped by Soroush Dalili (@irsdl): https://burpsuite.ninja/
Expand Down

0 comments on commit a22ec66

Please sign in to comment.