Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
d0ge committed Jul 26, 2024
1 parent 3f486dd commit f5bcd98
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import burp.api.montoya.BurpExtension;
import burp.api.montoya.MontoyaApi;
import net.portswigger.burp.extensions.beens.Browsers;
import net.portswigger.burp.extensions.beens.MatchAndReplace;

import javax.swing.*;
import java.util.concurrent.BlockingQueue;
Expand Down Expand Up @@ -32,13 +34,8 @@ public void initialize(MontoyaApi montoyaApi) {
});
// warming up
Utilities.log(Utilities.getResourceString("loading"));
String project_settings = Utilities.readResourceForClass("/project_options.json", BypassBotDetection.class);
SwingUtilities.invokeAndWait(() -> {
if(project_settings!=null) {
Utilities.importProject(project_settings);
}
});
Utilities.loadTLSSettings();
Utilities.updateTLSSettings(Constants.BROWSERS_PROTOCOLS.get(Browsers.FIREFOX.name), Constants.BROWSERS_CIPHERS.get(Browsers.FIREFOX.name));
Utilities.updateProxySettings(MatchAndReplace.create(Browsers.FIREFOX));


} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public List<Component> provideMenuItems(ContextMenuEvent contextMenuEvent) {


public void addTLSCiphers(Browsers browser){
Utilities.updateTLSSettings(Constants.BROWSERS_PROTOCOLS.get(browser.name), Constants.BROWSERS_CIPHERS.get(browser.name));
Utilities.updateProxySettings(MatchAndReplace.create(browser));
Utilities.updateTLSSettingsSync(Constants.BROWSERS_PROTOCOLS.get(browser.name), Constants.BROWSERS_CIPHERS.get(browser.name));
Utilities.updateProxySettingsSync(MatchAndReplace.create(browser));
}
public void addManualSettings(String negotiation){
Utilities.importProject(negotiation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import burp.api.montoya.core.Annotations;
import burp.api.montoya.http.message.HttpRequestResponse;
import net.portswigger.burp.extensions.beens.Browsers;
import net.portswigger.burp.extensions.beens.MatchAndReplace;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand Down Expand Up @@ -67,7 +69,8 @@ public void run() {
Utilities.log(e.getMessage());
}
finally {
Utilities.loadTLSSettings();
Utilities.updateTLSSettingsSync(Constants.BROWSERS_PROTOCOLS.get(Browsers.FIREFOX.name), Constants.BROWSERS_CIPHERS.get(Browsers.FIREFOX.name));
Utilities.updateProxySettingsSync(MatchAndReplace.create(Browsers.FIREFOX));
}
}
});
Expand Down
32 changes: 24 additions & 8 deletions src/main/java/net/portswigger/burp/extensions/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import com.google.gson.Gson;
import net.portswigger.burp.extensions.beens.*;

import javax.swing.*;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.URI;
import java.net.URL;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -53,14 +55,28 @@ static void updateTLSSettings(String[] protocols, String[] ciphers) {
String serializedTLSSettings = gson.toJson(currentTLSSettings);
importProject(serializedTLSSettings);
}

static void importProject(String serializedSettings) {
montoyaApi.burpSuite().importProjectOptionsFromJson(serializedSettings);
static void updateProxySettingsSync(MatchAndReplace rule) {
String proxy = montoyaApi.burpSuite().exportProjectOptionsAsJson("proxy.match_replace_rules");
ProxySettings currentProxySettings = gson.fromJson(proxy, ProxySettings.class);
ProxySettings changedProxySettings = currentProxySettings.toggleMatchAndReplace(rule);
String serializedProxySettings = gson.toJson(changedProxySettings);
montoyaApi.burpSuite().importProjectOptionsFromJson(serializedProxySettings);
}
static void updateTLSSettingsSync(String[] protocols, String[] ciphers) {
String project_settings = montoyaApi.burpSuite().exportProjectOptionsAsJson("project_options");
TLSSettings currentTLSSettings = gson.fromJson(project_settings, TLSSettings.class);
currentTLSSettings.addProtocols(protocols);
currentTLSSettings.addCiphers(ciphers);
String serializedTLSSettings = gson.toJson(currentTLSSettings);
montoyaApi.burpSuite().importProjectOptionsFromJson(serializedTLSSettings);
}

static void warmTLSSettings() {
String project_settings = Utilities.readResourceForClass("/project_options.json", Utilities.class);
montoyaApi.burpSuite().importProjectOptionsFromJson(project_settings);
static void importProject(String serializedSettings) {
try {
SwingUtilities.invokeAndWait(() -> {
montoyaApi.burpSuite().importProjectOptionsFromJson(serializedSettings);
});
} catch (Exception ignored){}
}


Expand Down Expand Up @@ -99,7 +115,7 @@ public static String readResourceForClass(final String fileName, Class clazz) {

public static boolean doesHostExist(String urlString) {
try {
URL url = new URL(urlString);
URI url = new URI(urlString);
String host = url.getHost();
InetAddress address = InetAddress.getByName(host);
return address != null;
Expand All @@ -126,7 +142,7 @@ static HttpRequestResponse attemptRequest(HttpRequestResponse requestResponse, S
}

static boolean compareResponses(HttpRequestResponse baseRequest, HttpRequestResponse comparableResponse) {
if (baseRequest.response() == null || comparableResponse == null) return false;
if (baseRequest.response() == null || comparableResponse.response() == null) return false;
double P = 0.1;
int b = 0;
int c = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ greetings=Bypass bot detection started
error=Extension failed with exception!
menu_brute_force=Brute force ciphers
preferences=net.portswigger.burp.extensions.bypass.bot.detection
loading=Loading custom Settings -> Network -> TLS Negotiation. Unload the extension to restore defaults!
loading=Loading custom Settings -> Network -> TLS Negotiation -> Use custom protocols and ciphers. Unload the extension to restore defaults!
negotiation=Bypass!

0 comments on commit f5bcd98

Please sign in to comment.