From 16ba30bf647a83e3bc6d66228e127ecb27763fac Mon Sep 17 00:00:00 2001 From: Soroush Dalili <1798313+irsdl@users.noreply.github.com> Date: Wed, 15 Feb 2023 14:06:53 +0000 Subject: [PATCH 01/19] Gradle update and GitHub workflow fix --- .github/workflows/maven.yml | 35 +++++++++++++++++++----- .gitignore | 3 +- build.gradle | 23 ++++++++++++++-- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index c8aeb3a..411c697 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -6,8 +6,12 @@ name: Java CI with Maven on: push: branches: [ master ] + tags: + - 'v*' pull_request: branches: [ master ] + tags: + - 'v*' jobs: build: @@ -15,10 +19,27 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Build with Maven - run: mvn -B package --file pom.xml + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'oracle' + java-version: '17' + cache: 'gradle' + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build + - name: Creating the jar file + run: ./gradlew jar + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + path: ./releases/*.jar + name: Downloadable Extension File + - name: Release + uses: ncipollo/release-action@v1 + with: + tag: "latest_builds_by_github" + allowUpdates: true + artifacts: "releases/*.jar" \ No newline at end of file diff --git a/.gitignore b/.gitignore index e72d88e..cf2764c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,10 @@ bin/ build/ target/ out/ +/releases/ #intellij .idea/ .classpath/ .project/ /build/ -/.gradle/ +/.gradle/ \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7ccc257..3769b8a 100644 --- a/build.gradle +++ b/build.gradle @@ -29,8 +29,8 @@ dependencies { implementation 'com.github.javafaker:javafaker:1.0.2' implementation 'com.fifesoft:rsyntaxtextarea:3.2.2' implementation 'com.fifesoft:autocomplete:3.3.1' - testImplementation 'junit:junit:4.13.1' - testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1' + testImplementation 'junit:junit:4.13.2' + testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2' } sourceSets { @@ -44,6 +44,24 @@ sourceSets { } } +jar{ + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + archivesBaseName = project.name + '-all' + from { + (configurations.runtimeClasspath).collect { it.isDirectory() ? it : zipTree(it) } + }{ + exclude "META-INF/*.SF" + exclude "META-INF/*.DSA" + exclude "META-INF/*.RSA" + exclude "META-INF/*.txt" + } +} + +tasks.withType(Jar) { + destinationDirectory = file("$rootDir/releases/") +} + +/* task fatJar(type: Jar) { baseName = project.name + '-all' duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -58,6 +76,7 @@ task fatJar(type: Jar) { } with jar } +*/ /*test { useJUnitPlatform() diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fc..da1db5f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From f8a1fb73831adff0a4e32cdd308b085b9741f2f9 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Fri, 31 Mar 2023 12:52:07 +0100 Subject: [PATCH 02/19] Fixed content length bug --- src/main/java/burp/BurpExtender.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index e1c13dc..86d81e1 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -202,7 +202,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.38"); + stdout.println("Hackvertor v1.7.39"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); @@ -1082,9 +1082,9 @@ public int[] getHeaderOffsets(byte[] request, String header) { int end = request.length; while (i < end) { int line_start = i; - while (i < end && request[i++] != ' ') { + while (i < end && request[i++] != ':') { } - byte[] header_name = Arrays.copyOfRange(request, line_start, i - 2); + byte[] header_name = Arrays.copyOfRange(request, line_start, i - 1); int headerValueStart = i; while (i < end && request[i++] != '\n') { } @@ -1095,7 +1095,7 @@ public int[] getHeaderOffsets(byte[] request, String header) { String header_str = helpers.bytesToString(header_name); if (header.equals(header_str)) { - int[] offsets = {line_start, headerValueStart, i - 2}; + int[] offsets = {line_start, headerValueStart, i - 1}; return offsets; } @@ -1111,7 +1111,7 @@ public byte[] setHeader(byte[] request, String header, String value) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { outputStream.write(Arrays.copyOfRange(request, 0, offsets[1])); - outputStream.write(helpers.stringToBytes(value)); + outputStream.write(helpers.stringToBytes(" " + value)); outputStream.write(Arrays.copyOfRange(request, offsets[2], request.length)); return outputStream.toByteArray(); } catch (IOException e) { From 1e94f533e9032bdf1e574582b90dc3c274234161 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Fri, 31 Mar 2023 13:36:38 +0100 Subject: [PATCH 03/19] Fixed bug where carriage return wasn't being added. --- src/main/java/burp/BurpExtender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index 86d81e1..ba13093 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -1095,7 +1095,7 @@ public int[] getHeaderOffsets(byte[] request, String header) { String header_str = helpers.bytesToString(header_name); if (header.equals(header_str)) { - int[] offsets = {line_start, headerValueStart, i - 1}; + int[] offsets = {line_start, headerValueStart, i - 2}; return offsets; } From e06772f61b12b5c0ebf47b9a6b0cf117fe1ec5b1 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Mon, 3 Apr 2023 12:36:04 +0100 Subject: [PATCH 04/19] Improved find() tag to allow groups --- src/main/java/burp/BurpExtender.java | 2 +- src/main/java/burp/Convertors.java | 10 +++++++--- src/main/java/burp/Hackvertor.java | 3 ++- src/main/java/burp/parser/Element.java | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index ba13093..ccdf16b 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -202,7 +202,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.39"); + stdout.println("Hackvertor v1.7.40"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); diff --git a/src/main/java/burp/Convertors.java b/src/main/java/burp/Convertors.java index 44468ae..ca2b858 100644 --- a/src/main/java/burp/Convertors.java +++ b/src/main/java/burp/Convertors.java @@ -405,7 +405,7 @@ public static String callTag(HashMap variableMap, JSONArray cust case "length": return len(output); case "find": - return find(output, getString(arguments, 0)); + return find(output, getString(arguments, 0), getInt(arguments, 1)); case "replace": return replace(output, getString(arguments, 0), getString(arguments, 1)); case "regex_replace": @@ -2466,12 +2466,16 @@ static String len(String str) { return Integer.toString(str.length()); } - static String find(String str, String find) { + static String find(String str, String find, int group) { java.util.List allMatches = new ArrayList(); try { Matcher m = Pattern.compile(find).matcher(str); while (m.find()) { - allMatches.add(m.group()); + if(group == -1) { + allMatches.add(m.group()); + } else { + allMatches.add(m.group(group)); + } } } catch (PatternSyntaxException e) { stderr.println(e.getMessage()); diff --git a/src/main/java/burp/Hackvertor.java b/src/main/java/burp/Hackvertor.java index 22ba072..79a4239 100644 --- a/src/main/java/burp/Hackvertor.java +++ b/src/main/java/burp/Hackvertor.java @@ -228,8 +228,9 @@ void init() { tags.add(new Tag(Tag.Category.String, "reverse", true, "reverse(String str)")); tags.add(new Tag(Tag.Category.String, "length", true, "len(String str)")); tags.add(new Tag(Tag.Category.String, "unique", true, "unique(String str)")); - tag = new Tag(Tag.Category.String, "find", true, "find(String str, String find)"); + tag = new Tag(Tag.Category.String, "find", true, "find(String str, String find, int group)"); tag.argument1 = new TagArgument("string", "find"); + tag.argument2 = new TagArgument("int", "-1"); tags.add(tag); tag = new Tag(Tag.Category.String, "replace", true, "replace(String str, String find, String replace)"); tag.argument1 = new TagArgument("string", "find"); diff --git a/src/main/java/burp/parser/Element.java b/src/main/java/burp/parser/Element.java index 31d7fcf..178aa7c 100644 --- a/src/main/java/burp/parser/Element.java +++ b/src/main/java/burp/parser/Element.java @@ -32,7 +32,7 @@ public String toString() { for (int i = 0; i < arguments.size(); i++) { if(i != 0) sb.append(","); String argument = arguments.get(i); - if(StringUtils.isNumeric(argument) || argument.equals("true") || argument.equals("false")) + if((argument.startsWith("-") && StringUtils.isNumeric(argument.substring(1))) || StringUtils.isNumeric(argument) || argument.equals("true") || argument.equals("false")) sb.append(argument); else sb.append("'" + JavaEscape.escapeJava(argument) + "'"); From 652d9e0e152bde3513a1198e9fb2e2f0cad6f48d Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Mon, 3 Apr 2023 12:51:31 +0100 Subject: [PATCH 05/19] Added uuid tag --- src/main/java/burp/BurpExtender.java | 2 +- src/main/java/burp/Convertors.java | 6 ++++++ src/main/java/burp/Hackvertor.java | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index ccdf16b..06b14f7 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -202,7 +202,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.40"); + stdout.println("Hackvertor v1.7.41"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); diff --git a/src/main/java/burp/Convertors.java b/src/main/java/burp/Convertors.java index ca2b858..acf0039 100644 --- a/src/main/java/burp/Convertors.java +++ b/src/main/java/burp/Convertors.java @@ -558,6 +558,8 @@ public static String callTag(HashMap variableMap, JSONArray cust return convert_base(output, getString(arguments, 0), getInt(arguments, 1), getInt(arguments, 2)); case "zeropad": return zeropad(output, getString(arguments, 0), getInt(arguments, 1)); + case "uuid": + return uuid(); case "behavior": return behavior(output); case "css_expression": @@ -2964,6 +2966,10 @@ static String zeropad(String str, String splitChar, int amount) { return StringUtils.join(chars, ","); } + static String uuid() { + return UUID.randomUUID().toString(); + } + static String eval_fromcharcode(String str) { return "eval(String.fromCharCode(" + to_charcode(str) + "))"; } diff --git a/src/main/java/burp/Hackvertor.java b/src/main/java/burp/Hackvertor.java index 79a4239..8709685 100644 --- a/src/main/java/burp/Hackvertor.java +++ b/src/main/java/burp/Hackvertor.java @@ -403,6 +403,8 @@ void init() { tag.argument1 = new TagArgument("string", ","); tag.argument2 = new TagArgument("int", "2"); tags.add(tag); + tag = new Tag(Tag.Category.Math, "uuid", false, "uuid()"); + tags.add(tag); tags.add(new Tag(Tag.Category.XSS, "behavior", true, "behavior(String str)")); tags.add(new Tag(Tag.Category.XSS, "css_expression", true, "css_expression(String str)")); tags.add(new Tag(Tag.Category.XSS, "datasrc", true, "datasrc(String str)")); From 561fde85a43a099a972ad9f8f618842f864af251 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Wed, 5 Apr 2023 12:41:51 +0100 Subject: [PATCH 06/19] Passed Hackvertor instance to custom tags to allow the context variable tags to be allowed --- src/main/java/burp/BurpExtender.java | 12 ++++------ src/main/java/burp/Convertors.java | 34 +++++++++++++++------------- src/main/java/burp/Hackvertor.java | 4 ++++ 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index 06b14f7..60ee724 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -4,9 +4,7 @@ import burp.ui.HackvertorInput; import org.apache.commons.codec.digest.DigestUtils; import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.SyntaxConstants; -import org.fife.ui.rsyntaxtextarea.Theme; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -202,7 +200,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.41"); + stdout.println("Hackvertor v1.7.42"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); @@ -787,13 +785,13 @@ public void actionPerformed(ActionEvent e) { try { if (language.equals("JavaScript")) { - output = javascript(new HashMap<>(), input, code, tagCodeExecutionKey, customTagOptions, hackvertor.getCustomTags()); + output = javascript(new HashMap<>(), input, code, tagCodeExecutionKey, customTagOptions, hackvertor.getCustomTags(), null); } else if(language.equals("Python")){ - output = python(new HashMap<>(), input, code, tagCodeExecutionKey, customTagOptions, hackvertor.getCustomTags()); + output = python(new HashMap<>(), input, code, tagCodeExecutionKey, customTagOptions, hackvertor.getCustomTags(), null); } else if(language.equals("Java")){ - output = java(new HashMap<>(), input, code, tagCodeExecutionKey, customTagOptions, hackvertor.getCustomTags()); + output = java(new HashMap<>(), input, code, tagCodeExecutionKey, customTagOptions, hackvertor.getCustomTags(), null); } else if(language.equals("Groovy")){ - output = groovy(new HashMap<>(), input, code, tagCodeExecutionKey, customTagOptions, hackvertor.getCustomTags()); + output = groovy(new HashMap<>(), input, code, tagCodeExecutionKey, customTagOptions, hackvertor.getCustomTags(), null); } }catch (Exception ee){ ee.printStackTrace(); diff --git a/src/main/java/burp/Convertors.java b/src/main/java/burp/Convertors.java index acf0039..e82d228 100644 --- a/src/main/java/burp/Convertors.java +++ b/src/main/java/burp/Convertors.java @@ -184,13 +184,13 @@ public static String callTag(HashMap variableMap, JSONArray cust String language = customTag.getString("language").toLowerCase(); String code = customTag.getString("code"); if (language.equals("javascript")) { - return javascript(variableMap, output, code, eKey, customTagOptions, customTags); + return javascript(variableMap, output, code, eKey, customTagOptions, customTags, hackvertor); } else if (language.equals("python")) { - return python(variableMap, output, code, eKey, customTagOptions, customTags); + return python(variableMap, output, code, eKey, customTagOptions, customTags, hackvertor); } else if (language.equals("java")) { - return java(variableMap, output, code, eKey, customTagOptions, customTags); + return java(variableMap, output, code, eKey, customTagOptions, customTags, hackvertor); } else if (language.equals("groovy")) { - return groovy(variableMap, output, code, eKey, customTagOptions, customTags); + return groovy(variableMap, output, code, eKey, customTagOptions, customTags, hackvertor); } } } @@ -581,13 +581,13 @@ public static String callTag(HashMap variableMap, JSONArray cust case "throw_eval": return throw_eval(output); case "python": - return python(variableMap, output, getString(arguments, 0), getString(arguments, 1), null, customTags); + return python(variableMap, output, getString(arguments, 0), getString(arguments, 1), null, customTags, null); case "javascript": - return javascript(variableMap, output, getString(arguments, 0), getString(arguments, 1), null, customTags); + return javascript(variableMap, output, getString(arguments, 0), getString(arguments, 1), null, customTags, null); case "java": - return java(variableMap, output, getString(arguments, 0), getString(arguments, 1), null, customTags); + return java(variableMap, output, getString(arguments, 0), getString(arguments, 1), null, customTags, null); case "groovy": - return groovy(variableMap, output, getString(arguments, 0), getString(arguments, 1), null, customTags); + return groovy(variableMap, output, getString(arguments, 0), getString(arguments, 1), null, customTags, null); case "read_url": return read_url(output, getString(arguments, 0), getBoolean(arguments, 1), getString(arguments, 2)); case "system": @@ -3020,7 +3020,7 @@ static String template_eval(String str) { return "eval(`" + str.replaceAll("(.)", "$1\\${[]}") + "`)"; } - static String python(HashMap variableMap, String input, String code, String executionKey, JSONObject customTagOptions, JSONArray customTags) { + static String python(HashMap variableMap, String input, String code, String executionKey, JSONObject customTagOptions, JSONArray customTags, Hackvertor hackvertor) { if (!codeExecutionTagsEnabled) { return "Code execution tags are disabled by default. Use the menu bar to enable them."; } @@ -3074,7 +3074,7 @@ static String python(HashMap variableMap, String input, String c "sys.stdout = StreamWrapper(orig_stdout)\n" + "from burp import Convertors\n" + "def convert(input):\n" + - " return Convertors.convert(variableMap, customTags, input)\n" + + " return Convertors.weakConvert(variableMap, customTags, input, hackvertor)\n" + "\n"; pythonInterpreter.exec(initCode + code); @@ -3092,7 +3092,7 @@ static String python(HashMap variableMap, String input, String c } } - static String java(HashMap variableMap, String input, String code, String executionKey, JSONObject customTagOptions, JSONArray customTags) { + static String java(HashMap variableMap, String input, String code, String executionKey, JSONObject customTagOptions, JSONArray customTags, Hackvertor hackvertor) { if (!codeExecutionTagsEnabled) { return "Code execution tags are disabled by default. Use the menu bar to enable them."; } @@ -3113,8 +3113,10 @@ static String java(HashMap variableMap, String input, String cod javaInterpreter.set("customTags", customTags); String initCode = "import burp.Convertors;\n" + "public String convert(String input) {\n" + - " return Convertors.convert(variableMap, customTags, input);\n" + + " return Convertors.weakConvert(variableMap, customTags, input, hackvertor);\n" + "}\n"; + + for (Map.Entry entry : variableMap.entrySet()) { String name = entry.getKey(); Object value = entry.getValue(); @@ -3147,7 +3149,7 @@ static String java(HashMap variableMap, String input, String cod return "Unable to parse Java:" + e.toString(); } } - static String groovy(HashMap variableMap, String input, String code, String executionKey, JSONObject customTagOptions, JSONArray customTags) { + static String groovy(HashMap variableMap, String input, String code, String executionKey, JSONObject customTagOptions, JSONArray customTags, Hackvertor hackvertor) { if (!codeExecutionTagsEnabled) { return "Code execution tags are disabled by default. Use the menu bar to enable them."; } @@ -3168,7 +3170,7 @@ static String groovy(HashMap variableMap, String input, String c data.setVariable("customTags", customTags); String initCode = "import burp.Convertors;\n" + "public String convert(String input) {\n" + - " return Convertors.convert(variableMap, customTags, input);\n" + + " return Convertors.weakConvert(variableMap, customTags, input, hackvertor);\n" + "}\n"; try { if (code.endsWith(".groovy")) { @@ -3181,7 +3183,7 @@ static String groovy(HashMap variableMap, String input, String c } return shell.getVariable("output").toString(); } - static String javascript(HashMap variableMap, String input, String code, String executionKey, JSONObject customTagOptions, JSONArray customTags) { + static String javascript(HashMap variableMap, String input, String code, String executionKey, JSONObject customTagOptions, JSONArray customTags, Hackvertor hackvertor) { if (!codeExecutionTagsEnabled) { return "Code execution tags are disabled by default. Use the menu bar to enable them."; } @@ -3207,7 +3209,7 @@ static String javascript(HashMap variableMap, String input, Stri public String invoke(final V8Object receiver, final V8Array parameters) { if (parameters.length() > 0) { Object input = parameters.get(0); - String output = convert(variableMap, customTags, input.toString()); + String output = Convertors.weakConvert(variableMap, customTags, input.toString(), hackvertor); if (input instanceof Releasable) { ((Releasable) input).release(); } diff --git a/src/main/java/burp/Hackvertor.java b/src/main/java/burp/Hackvertor.java index 8709685..ce2c53e 100644 --- a/src/main/java/burp/Hackvertor.java +++ b/src/main/java/burp/Hackvertor.java @@ -33,6 +33,10 @@ public byte[] getRequest() { return request; } + public void setRequest(byte[] request) { + this.request = request; + } + public static String removeHackvertorTags(String input) { try { input = HackvertorParser.parse(input).stream() From eafe0508e3b0409a88cde0aab82cd85527da7dff Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Fri, 21 Apr 2023 12:17:04 +0100 Subject: [PATCH 07/19] Updated maven.xml to use action from fork --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 411c697..baf9911 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -38,8 +38,8 @@ jobs: path: ./releases/*.jar name: Downloadable Extension File - name: Release - uses: ncipollo/release-action@v1 + uses: hackvertor/release-action@v1 with: tag: "latest_builds_by_github" allowUpdates: true - artifacts: "releases/*.jar" \ No newline at end of file + artifacts: "releases/*.jar" From 0a18bf5d075d7d29553e0dcd6add92e29c461aed Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Fri, 21 Apr 2023 12:50:50 +0100 Subject: [PATCH 08/19] Added base58 encoder/decoder. Updated entry point. --- BappManifest.bmf | 2 +- build.gradle | 23 +-------- src/main/java/burp/Base58.java | 75 ++++++++++++++++++++++++++++ src/main/java/burp/BurpExtender.java | 2 +- src/main/java/burp/Convertors.java | 12 +++++ src/main/java/burp/Hackvertor.java | 2 + 6 files changed, 92 insertions(+), 24 deletions(-) create mode 100644 src/main/java/burp/Base58.java diff --git a/BappManifest.bmf b/BappManifest.bmf index 58fe6d7..9897925 100644 --- a/BappManifest.bmf +++ b/BappManifest.bmf @@ -8,6 +8,6 @@ MinPlatformVersion: 0 ProOnly: False Author: Portswigger Web Security - Gareth Heyes ShortDescription: Converts data using a tag-based configuration to apply various encoding and escaping operations. -EntryPoint: build/libs/hackvertor-all.jar +EntryPoint: releases/hackvertor-all.jar BuildCommand: ./gradlew fatJar SupportedProducts: Pro, Community diff --git a/build.gradle b/build.gradle index 3769b8a..fde3ffe 100644 --- a/build.gradle +++ b/build.gradle @@ -59,25 +59,4 @@ jar{ tasks.withType(Jar) { destinationDirectory = file("$rootDir/releases/") -} - -/* -task fatJar(type: Jar) { - baseName = project.name + '-all' - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - from { - configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } - } { - exclude 'META-INF/MANIFEST.MF' - exclude 'META-INF/*.SF' - exclude 'META-INF/*.DSA' - exclude 'META-INF/*.RSA' - } - with jar -} -*/ - -/*test { - useJUnitPlatform() -}*/ +} \ No newline at end of file diff --git a/src/main/java/burp/Base58.java b/src/main/java/burp/Base58.java new file mode 100644 index 0000000..bc6c8fb --- /dev/null +++ b/src/main/java/burp/Base58.java @@ -0,0 +1,75 @@ +package burp; + +import java.math.BigInteger; + +public class Base58 { + private static final char[] ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".toCharArray(); + private static final BigInteger BASE = BigInteger.valueOf(58); + + public static String encode(byte[] input) { + if (input.length == 0) { + return ""; + } + + // Convert the input bytes to a BigInteger + BigInteger num = new BigInteger(1, input); + + // Encode the BigInteger as base58 + StringBuilder sb = new StringBuilder(); + while (num.compareTo(BigInteger.ZERO) > 0) { + BigInteger[] qr = num.divideAndRemainder(BASE); + sb.append(ALPHABET[qr[1].intValue()]); + num = qr[0]; + } + + // Add leading '1' characters for each leading zero byte in the input + for (int i = 0; i < input.length && input[i] == 0; i++) { + sb.append(ALPHABET[0]); + } + + return sb.reverse().toString(); + } + + public static byte[] decode(String input) { + if (input.length() == 0) { + return new byte[0]; + } + + // Convert the base58 input to a BigInteger + BigInteger num = BigInteger.ZERO; + for (int i = 0; i < input.length(); i++) { + char c = input.charAt(i); + int digit = -1; + for (int j = 0; j < ALPHABET.length; j++) { + if (ALPHABET[j] == c) { + digit = j; + break; + } + } + if (digit == -1) { + throw new IllegalArgumentException("Invalid character '" + c + "' at position " + i); + } + num = num.multiply(BASE).add(BigInteger.valueOf(digit)); + } + + // Convert the BigInteger to a byte array + byte[] bytes = num.toByteArray(); + + // Remove any leading zero bytes + if (bytes.length > 0 && bytes[0] == 0) { + byte[] tmp = new byte[bytes.length - 1]; + System.arraycopy(bytes, 1, tmp, 0, tmp.length); + bytes = tmp; + } + + // Add leading zero bytes for each leading '1' character in the input + int numZeros = 0; + for (int i = 0; i < input.length() && input.charAt(i) == ALPHABET[0]; i++) { + numZeros++; + } + byte[] result = new byte[numZeros + bytes.length]; + System.arraycopy(bytes, 0, result, numZeros, bytes.length); + + return result; + } +} diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index 60ee724..927aafc 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -200,7 +200,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.42"); + stdout.println("Hackvertor v1.7.43"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); diff --git a/src/main/java/burp/Convertors.java b/src/main/java/burp/Convertors.java index e82d228..5da7df2 100644 --- a/src/main/java/burp/Convertors.java +++ b/src/main/java/burp/Convertors.java @@ -362,6 +362,10 @@ public static String callTag(HashMap variableMap, JSONArray cust return base32_encode(output); case "d_base32": return decode_base32(output); + case "base58": + return base58_encode(output); + case "d_base58": + return decode_base58(output); case "base64": return base64Encode(output); case "d_base64": @@ -1098,6 +1102,14 @@ static String decode_base32(String str) { return new String(base32.decode(str.getBytes())); } + static String base58_encode(String str) { + return Base58.encode(helpers.stringToBytes(str)); + } + + static String decode_base58(String str) { + return helpers.bytesToString(Base58.decode(str)); + } + static String base64Encode(String str) { return helpers.base64Encode(str); } diff --git a/src/main/java/burp/Hackvertor.java b/src/main/java/burp/Hackvertor.java index ce2c53e..281013a 100644 --- a/src/main/java/burp/Hackvertor.java +++ b/src/main/java/burp/Hackvertor.java @@ -146,6 +146,7 @@ void init() { tags.add(new Tag(Tag.Category.Encrypt, "guess_key_length", true, "guess_key_length(String ciphertext)")); tags.add(new Tag(Tag.Category.Encode, "saml", true, "saml(String str)")); tags.add(new Tag(Tag.Category.Encode, "base32", true, "base32_encode(String str)")); + tags.add(new Tag(Tag.Category.Encode, "base58", true, "base58Encode(String str)")); tags.add(new Tag(Tag.Category.Encode, "base64", true, "base64Encode(String str)")); tags.add(new Tag(Tag.Category.Encode, "base64url", true, "base64urlEncode(String str)")); tags.add(new Tag(Tag.Category.Encode, "html_entities", true, "html_entities(String str)")); @@ -178,6 +179,7 @@ void init() { tags.add(new Tag(Tag.Category.Decode, "auto_decode", true, "auto_decode(String str)")); tags.add(new Tag(Tag.Category.Decode, "auto_decode_no_decrypt", true, "auto_decode_no_decrypt(String str)")); tags.add(new Tag(Tag.Category.Decode, "d_base32", true, "decode_base32(String str)")); + tags.add(new Tag(Tag.Category.Decode, "d_base58", true, "decode_base58(String str)")); tags.add(new Tag(Tag.Category.Decode, "d_base64", true, "decode_base64(String str)")); tags.add(new Tag(Tag.Category.Decode, "d_base64url", true, "decode_base64url(String str)")); tags.add(new Tag(Tag.Category.Decode, "d_html_entities", true, "decode_html_entities(String str)")); From e1a5adc4bbb5ae2c71222179d224115005ccb88e Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Fri, 21 Apr 2023 13:08:47 +0100 Subject: [PATCH 09/19] Updated version --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index baf9911..a8fd18e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -38,7 +38,7 @@ jobs: path: ./releases/*.jar name: Downloadable Extension File - name: Release - uses: hackvertor/release-action@v1 + uses: hackvertor/release-action@v1.12.0 with: tag: "latest_builds_by_github" allowUpdates: true From 8df9efcbf9c6ded67c88c14b6e78e57cd6b32990 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Mon, 24 Apr 2023 12:26:35 +0100 Subject: [PATCH 10/19] Updated workflow to include Hackvertor latest release --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a8fd18e..fcd04ad 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -40,6 +40,6 @@ jobs: - name: Release uses: hackvertor/release-action@v1.12.0 with: - tag: "latest_builds_by_github" + tag: "Latest Hackvertor release" allowUpdates: true artifacts: "releases/*.jar" From 06060c1bd8bb9b33cf6fea2e0d27990d5b7f5e6b Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Mon, 24 Apr 2023 12:28:32 +0100 Subject: [PATCH 11/19] Fixed name error --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index fcd04ad..a818f1a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -40,6 +40,6 @@ jobs: - name: Release uses: hackvertor/release-action@v1.12.0 with: - tag: "Latest Hackvertor release" + tag: "Latest_Hackvertor_release" allowUpdates: true artifacts: "releases/*.jar" From 004ef7bdcab207c2e5d4a72c11d7c371cd706310 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Mon, 22 May 2023 12:25:59 +0100 Subject: [PATCH 12/19] Fixed base32 encoder/decoder --- build.gradle | 2 +- src/main/java/burp/BurpExtender.java | 2 +- src/main/java/burp/Convertors.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index fde3ffe..f702a09 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ repositories { dependencies { implementation 'net.portswigger.burp.extender:burp-extender-api:1.7.22' - implementation 'commons-codec:commons-codec:1.10' + implementation 'commons-codec:commons-codec:1.15' implementation 'org.apache.commons:commons-lang3:3.7' implementation 'org.unbescape:unbescape:1.1.5.RELEASE' implementation 'org.bouncycastle:bcpkix-jdk15on:1.60' diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index 927aafc..f1afb3e 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -200,7 +200,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.43"); + stdout.println("Hackvertor v1.7.44"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); diff --git a/src/main/java/burp/Convertors.java b/src/main/java/burp/Convertors.java index 5da7df2..c3a94f2 100644 --- a/src/main/java/burp/Convertors.java +++ b/src/main/java/burp/Convertors.java @@ -1094,12 +1094,12 @@ static String decode_html_entities(String str) { static String base32_encode(String str) { Base32 base32 = new Base32(); - return new String(base32.encode(str.getBytes())); + return helpers.bytesToString(base32.encode(helpers.stringToBytes(str))); } static String decode_base32(String str) { Base32 base32 = new Base32(); - return new String(base32.decode(str.getBytes())); + return helpers.bytesToString(base32.decode(str.getBytes())); } static String base58_encode(String str) { From 202e3712c194ebb0b3f9486ae87e48fce1e9e2ad Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Mon, 22 May 2023 12:41:30 +0100 Subject: [PATCH 13/19] Fixed context header to join further values if they contain colons. --- src/main/java/burp/BurpExtender.java | 2 +- src/main/java/burp/Convertors.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index f1afb3e..736048d 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -200,7 +200,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.44"); + stdout.println("Hackvertor v1.7.45"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); diff --git a/src/main/java/burp/Convertors.java b/src/main/java/burp/Convertors.java index c3a94f2..799db50 100644 --- a/src/main/java/burp/Convertors.java +++ b/src/main/java/burp/Convertors.java @@ -858,7 +858,8 @@ static String context_header(String properties, Hackvertor hackvertor) { for(String header : headers) { String[] nameValue = header.split(":"); if(nameValue.length > 1) { - properties = properties.replace("$" + nameValue[0].trim(), nameValue[1].trim()); + properties = properties.replace("$" + nameValue[0].trim(), nameValue[1].trim() + + (nameValue.length > 2 ? ":" + String.join(":", Arrays.copyOfRange(nameValue, 2, nameValue.length)) : "")); } } return properties; From 8ae7ba0942480680053e133f6ca0962df3e92a73 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Tue, 23 May 2023 12:26:26 +0100 Subject: [PATCH 14/19] Removed loops and added conditions --- src/main/java/burp/BurpExtender.java | 2 +- src/main/java/burp/Convertors.java | 64 +++++++++------------------- src/main/java/burp/Hackvertor.java | 23 ++++------ src/main/java/burp/Tag.java | 2 +- 4 files changed, 30 insertions(+), 61 deletions(-) diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index 736048d..e912619 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -200,7 +200,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.45"); + stdout.println("Hackvertor v1.7.46"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); diff --git a/src/main/java/burp/Convertors.java b/src/main/java/burp/Convertors.java index 799db50..ecea209 100644 --- a/src/main/java/burp/Convertors.java +++ b/src/main/java/burp/Convertors.java @@ -426,6 +426,10 @@ public static String callTag(HashMap variableMap, JSONArray cust return Double.toString(index_of_coincidence(output)); case "guess_key_length": return Integer.toString(guess_key_length(output)); + case "if_regex": + return if_regex(output, getString(arguments, 0), getString(arguments, 1)); + case "if_not_regex": + return if_not_regex(output, getString(arguments, 0), getString(arguments, 1)); case "chunked_dec2hex": return chunked_dec2hex(output); case "dec2hex": @@ -596,14 +600,6 @@ public static String callTag(HashMap variableMap, JSONArray cust return read_url(output, getString(arguments, 0), getBoolean(arguments, 1), getString(arguments, 2)); case "system": return system(output, getBoolean(arguments, 0), getString(arguments, 1)); - case "loop_for": - return loop_for(variableMap, customTags, output, getInt(arguments, 0), getInt(arguments, 1), getInt(arguments, 2), getString(arguments, 3)); - case "loop_letters_lower": - return loop_letters_lower(variableMap, customTags, output, getString(arguments, 0)); - case "loop_letters_upper": - return loop_letters_upper(variableMap, customTags, output, getString(arguments, 0)); - case "loop_numbers": - return loop_letters_numbers(variableMap, customTags, output, getString(arguments, 0)); } } @@ -1991,6 +1987,22 @@ static String dec2hex(String str, String regex) { return regexMatcher.appendTail(result).toString(); } + static String if_regex(String str, String regex, String value) { + Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); + Matcher regexMatcher = pattern.matcher(value); + if(regexMatcher.find()) { + return str; + } + return ""; + } + static String if_not_regex(String str, String regex, String value) { + Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); + Matcher regexMatcher = pattern.matcher(value); + if(!regexMatcher.find()) { + return str; + } + return ""; + } static String chunked_dec2hex(String str) { try { return Integer.toHexString(Integer.parseInt(str)); @@ -3383,40 +3395,4 @@ static String read_url(String input, String charset, Boolean enabled, String exe return "Unable to get response"; } } - - static String loop_for(HashMap variableMap, JSONArray customTags, String input, int start, int end, int increment, String variable) { - String output = ""; - for (int i = start; i < end; i += increment) { - variableMap.put(variable, Integer.toString(i)); - output += convert(variableMap, customTags, input); - } - return output; - } - - static String loop_letters_lower(HashMap variableMap, JSONArray customTags, String input, String variable) { - String output = ""; - for (char letter = 'a'; letter <= 'z'; letter++) { - variableMap.put(variable, Character.toString(letter)); - output += convert(variableMap, customTags, input);; - } - return output; - } - - static String loop_letters_upper(HashMap variableMap, JSONArray customTags, String input, String variable) { - String output = ""; - for (char letter = 'A'; letter <= 'Z'; letter++) { - variableMap.put(variable, Character.toString(letter)); - output += convert(variableMap, customTags, input); - } - return output; - } - - static String loop_letters_numbers(HashMap variableMap, JSONArray customTags, String input, String variable) { - String output = ""; - for (char num = '0'; num <= '9'; num++) { - variableMap.put(variable, Character.toString(num)); - output += convert(variableMap, customTags, input); - } - return output; - } } diff --git a/src/main/java/burp/Hackvertor.java b/src/main/java/burp/Hackvertor.java index 281013a..e8b1575 100644 --- a/src/main/java/burp/Hackvertor.java +++ b/src/main/java/burp/Hackvertor.java @@ -199,6 +199,14 @@ void init() { tag = new Tag(Tag.Category.Decode, "d_jwt_verify", true, "d_jwt_verify(String token, String secret)"); tag.argument1 = new TagArgument("string", "secret"); tags.add(tag); + tag = new Tag(Tag.Category.Conditions, "if_regex", true, "if_regex(String str, String regex, String value)"); + tag.argument1 = new TagArgument("string", "regex"); + tag.argument2 = new TagArgument("string", "value"); + tags.add(tag); + tag = new Tag(Tag.Category.Conditions, "if_not_regex", true, "if_not_regex(String str, String regex, String value)"); + tag.argument1 = new TagArgument("string", "regex"); + tag.argument2 = new TagArgument("string", "value"); + tags.add(tag); tags.add(new Tag(Tag.Category.Convert, "chunked_dec2hex", true, "chunked_dec2hex(String str)")); tag = new Tag(Tag.Category.Convert, "dec2hex", true, "dec2hex(String str, String regex)"); tag.argument1 = new TagArgument("string", "(\\d+)"); @@ -436,21 +444,6 @@ void init() { tag = new Tag(Tag.Category.Variables, "context_param", false, "context_url(String paramName"); tag.argument1 = new TagArgument("string", "$paramName"); tags.add(tag); - tag = new Tag(Tag.Category.Loops, "loop_for", true, "loop_for(String input, int start, int end, int increment, String i)//Does a for loop. Use a Hackvertor variable inside the tags to retrieve the position in the loop."); - tag.argument1 = new TagArgument("int", "0"); - tag.argument2 = new TagArgument("int", "10"); - tag.argument3 = new TagArgument("int", "1"); - tag.argument4 = new TagArgument("string", "i"); - tags.add(tag); - tag = new Tag(Tag.Category.Loops, "loop_letters_lower", true, "loop_letters_lower(String input, String variable)//Loops through all lowecase letters. Use a Hackvertor variable inside the tags to retrieve the letter"); - tag.argument1 = new TagArgument("string", "letter"); - tags.add(tag); - tag = new Tag(Tag.Category.Loops, "loop_letters_upper", true, "loop_letters_upper(String input, String variable)//Loops through all uppercase letters. Use a Hackvertor variable inside the tags to retrieve the letter"); - tag.argument1 = new TagArgument("string", "letter"); - tags.add(tag); - tag = new Tag(Tag.Category.Loops, "loop_numbers", true, "loop_numbers(String input, String variable)//Loops through all numbers. Use a Hackvertor variable inside the tags to retrieve the number"); - tag.argument1 = new TagArgument("string", "number"); - tags.add(tag); tag = new Tag(Tag.Category.Languages, "python", true, "python(String input, String code, String codeExecuteKey)"); tag.argument1 = new TagArgument("string", "output = input.upper()"); tag.argument2 = new TagArgument("string", tagCodeExecutionKey); diff --git a/src/main/java/burp/Tag.java b/src/main/java/burp/Tag.java index 5752d19..4068e3f 100644 --- a/src/main/java/burp/Tag.java +++ b/src/main/java/burp/Tag.java @@ -2,7 +2,7 @@ public class Tag { public enum Category { - Custom, Variables, Encode, Decode, String, Convert, Math, Hash, HMAC, Fake, Charsets, Compression, Date, Loops, Encrypt, Decrypt, Languages, System, XSS + Custom, Variables, Encode, Decode, String, Convert, Conditions, Math, Hash, HMAC, Fake, Charsets, Compression, Date, Encrypt, Decrypt, Languages, System, XSS }; public Category category; From 2af8225a39ec8cbbf596e6f5452680492d3bdbf3 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Tue, 27 Jun 2023 13:00:58 +0100 Subject: [PATCH 15/19] Added increment/decrement tags --- src/main/java/burp/BurpExtender.java | 2 +- src/main/java/burp/Convertors.java | 34 ++++++++++++++++++++++++++ src/main/java/burp/Hackvertor.java | 10 ++++++++ src/main/java/burp/parser/Element.java | 7 +++--- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index e912619..bfe3d06 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -200,7 +200,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.46"); + stdout.println("Hackvertor v1.7.47"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); diff --git a/src/main/java/burp/Convertors.java b/src/main/java/burp/Convertors.java index ecea209..fbc568d 100644 --- a/src/main/java/burp/Convertors.java +++ b/src/main/java/burp/Convertors.java @@ -233,6 +233,10 @@ public static String callTag(HashMap variableMap, JSONArray cust case "get_var": case "get_variable": return variableMap.getOrDefault(getString(arguments,0), StringUtils.isEmpty(output) ? "UNDEFINED" : output); + case "increment_var": + return increment_var(globalVariables, getInt(arguments, 0), getString(arguments, 1), getBoolean(arguments, 2)); + case "decrement_var": + return decrement_var(globalVariables, getInt(arguments, 0), getString(arguments, 1), getBoolean(arguments, 2)); case "context_url": return context_url(getString(arguments,0), hackvertor); case "context_header": @@ -872,6 +876,36 @@ static String context_param(String properties, Hackvertor hackvertor) { return properties; } + static String increment_var(HashMap variableMap, int start, String variableName, Boolean enabled) { + if(!enabled) { + return "This tag is disabled until you enable it in the tag params to prevent unintentional variable declaration."; + } + int value = 0; + if(variableMap.containsKey(variableName)) { + value = Integer.parseInt(variableMap.get(variableName)); + } else { + value = start; + } + String returnValue = String.valueOf(value); + variableMap.put(variableName, String.valueOf(value+1)); + return returnValue; + } + + static String decrement_var(HashMap variableMap, int start, String variableName, Boolean enabled) { + if(!enabled) { + return "This tag is disabled until you enable it in the tag params to prevent unintentional variable declaration."; + } + int value = 0; + if(variableMap.containsKey(variableName)) { + value = Integer.parseInt(variableMap.get(variableName)); + } else { + value = start; + } + String returnValue = String.valueOf(value); + variableMap.put(variableName, String.valueOf(value-1)); + return returnValue; + } + static String context_body(Hackvertor hackvertor) { if(hackvertor == null) { return ""; diff --git a/src/main/java/burp/Hackvertor.java b/src/main/java/burp/Hackvertor.java index e8b1575..7ab8e5c 100644 --- a/src/main/java/burp/Hackvertor.java +++ b/src/main/java/burp/Hackvertor.java @@ -432,6 +432,16 @@ void init() { Tag setTag = new Tag(Tag.Category.Variables, "set_variable1", true, "Special tag that lets you store the results of a conversion. Change variable1 to your own variable name. The argument specifies if the variable is global."); setTag.argument1 = new TagArgument("boolean", "false"); tags.add(setTag); + tag = new Tag(Tag.Category.Variables, "increment_var", false, "increment_var(int start, String variableName, Boolean enabled)//This tag allows you to declare a variable and initialize it and then every subsequent conversion increments it."); + tag.argument1 = new TagArgument("number", "0"); + tag.argument2 = new TagArgument("string", "variable"); + tag.argument3 = new TagArgument("boolean", "false"); + tags.add(tag); + tag = new Tag(Tag.Category.Variables, "decrement_var", false, "decrement_var(int start, String variableName, Boolean enabled)//This tag allows you to declare a variable and initialize it and then every subsequent conversion decrements it."); + tag.argument1 = new TagArgument("number", "0"); + tag.argument2 = new TagArgument("string", "variable"); + tag.argument3 = new TagArgument("boolean", "false"); + tags.add(tag); tags.add(new Tag(Tag.Category.Variables, "get_variable1", false, "Special tag that lets you get a previously set variable. Change var to your own variable name.")); tag = new Tag(Tag.Category.Variables, "context_url", false, "context_url(String properties"); tag.argument1 = new TagArgument("string", "$protocol $host $path $file $query $port"); diff --git a/src/main/java/burp/parser/Element.java b/src/main/java/burp/parser/Element.java index 178aa7c..9dcdd13 100644 --- a/src/main/java/burp/parser/Element.java +++ b/src/main/java/burp/parser/Element.java @@ -57,9 +57,10 @@ public String toString() { sb.append("("); for (int i = 0; i < arguments.size(); i++) { if(i != 0) sb.append(","); - if(StringUtils.isNumeric(arguments.get(i))){ - sb.append(arguments.get(i)); - }else { + String argument = arguments.get(i); + if((argument.startsWith("-") && StringUtils.isNumeric(argument.substring(1))) || StringUtils.isNumeric(argument) || argument.equals("true") || argument.equals("false")) { + sb.append(argument); + } else { sb.append("\"").append(arguments.get(i)).append("\""); } } From be6cf5bb6a18df957818caf8734a1507033f4a76 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Fri, 30 Jun 2023 12:56:55 +0100 Subject: [PATCH 16/19] Fixed font size when changing it in Burp UI. Added the ability to change the font size dynamically by pressing CTL/CMD + or CTL/CMD - --- src/main/java/burp/BurpExtender.java | 2 +- src/main/java/burp/Utils.java | 4 +-- src/main/java/burp/ui/HackvertorInput.java | 40 +++++++++++++++++++--- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index bfe3d06..c1f0ac4 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -200,7 +200,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.47"); + stdout.println("Hackvertor v1.7.48"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); diff --git a/src/main/java/burp/Utils.java b/src/main/java/burp/Utils.java index 304f287..83bfd9e 100644 --- a/src/main/java/burp/Utils.java +++ b/src/main/java/burp/Utils.java @@ -1,6 +1,7 @@ package burp; import burp.parser.Element; +import burp.ui.HackvertorInput; import org.apache.commons.lang3.StringUtils; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.Theme; @@ -185,12 +186,11 @@ public static void fixRSyntaxAreaBurp() { UIManager.put("RTextAreaUI.inputMap", null); } - public static void configureRSyntaxArea(RSyntaxTextArea area) { + public static void configureRSyntaxArea(HackvertorInput area) { area.setLineWrap(true); if(BurpExtender.isDarkTheme) { Utils.applyThemeToRSyntaxTextArea(area, "dark"); } callbacks.customizeUiComponent(area); - area.setFont(new Font("Courier New", Font.PLAIN, area.getFont().getSize())); } } diff --git a/src/main/java/burp/ui/HackvertorInput.java b/src/main/java/burp/ui/HackvertorInput.java index b795912..ba17aa5 100644 --- a/src/main/java/burp/ui/HackvertorInput.java +++ b/src/main/java/burp/ui/HackvertorInput.java @@ -7,14 +7,39 @@ import javax.swing.*; import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; import static burp.BurpExtender.callbacks; public class HackvertorInput extends RSyntaxTextArea { public HackvertorInput() { super(); - callbacks.customizeUiComponent(this); - this.updateFont(); + HackvertorInput that = this; + this.addKeyListener(new KeyListener() { + @Override + public void keyTyped(KeyEvent e) { + + } + + @Override + public void keyPressed(KeyEvent e) { + if ((e.getKeyCode() == KeyEvent.VK_PLUS || e.getKeyCode() == KeyEvent.VK_EQUALS) && (e.isMetaDown() || (e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) { + int fontSize = that.getFont().getSize(); + that.changeFontSize(fontSize + 1); + } else if ((e.getKeyCode() == KeyEvent.VK_MINUS) && (e.isMetaDown() || (e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) { + int fontSize = that.getFont().getSize(); + that.changeFontSize(fontSize - 1); + } else if ((e.isControlDown() || e.isMetaDown()) && (e.getKeyCode() == KeyEvent.VK_0)) { + getFontSizeFromBurp(); + } + } + + @Override + public void keyReleased(KeyEvent e) { + + } + }); } public void updateUI() { super.updateUI(); @@ -25,11 +50,16 @@ public void updateUI() { } else { Utils.applyThemeToRSyntaxTextArea(this, "default"); } + getFontSizeFromBurp(); }); + } + + public void getFontSizeFromBurp() { callbacks.customizeUiComponent(this); - this.updateFont(); + this.changeFontSize(this.getFont().getSize()); } - public void updateFont() { - this.setFont(new Font("Courier New", Font.PLAIN, this.getFont().getSize())); + + public void changeFontSize(int fontSize) { + this.setFont(new Font("Courier New", Font.PLAIN, fontSize)); } } From e1b28324ef235eaef80559d3cf56f05acf06cca0 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Tue, 4 Jul 2023 12:36:45 +0100 Subject: [PATCH 17/19] Updated deps and tidied code --- build.gradle | 18 +++++++++--------- src/main/java/burp/BurpExtender.java | 4 +++- src/main/java/burp/Utils.java | 1 + .../burp/{ => ui}/HackvertorMessageTab.java | 5 ++++- src/main/java/burp/ui/HackvertorPanel.java | 2 -- .../burp/{ => ui}/JTabbedPaneClosable.java | 3 +-- src/main/java/burp/{ => ui}/MenuScroller.java | 2 +- 7 files changed, 19 insertions(+), 16 deletions(-) rename src/main/java/burp/{ => ui}/HackvertorMessageTab.java (97%) rename src/main/java/burp/{ => ui}/JTabbedPaneClosable.java (98%) rename src/main/java/burp/{ => ui}/MenuScroller.java (99%) diff --git a/build.gradle b/build.gradle index f702a09..930a3e9 100644 --- a/build.gradle +++ b/build.gradle @@ -13,21 +13,21 @@ repositories { dependencies { implementation 'net.portswigger.burp.extender:burp-extender-api:1.7.22' implementation 'commons-codec:commons-codec:1.15' - implementation 'org.apache.commons:commons-lang3:3.7' - implementation 'org.unbescape:unbescape:1.1.5.RELEASE' - implementation 'org.bouncycastle:bcpkix-jdk15on:1.60' - implementation 'com.auth0:java-jwt:3.4.0' - implementation 'org.json:json:20190722' - implementation 'commons-io:commons-io:2.6' + implementation 'org.apache.commons:commons-lang3:3.12.0' + implementation 'org.unbescape:unbescape:1.1.6.RELEASE' + implementation 'org.bouncycastle:bcpkix-jdk15on:1.70' + implementation 'com.auth0:java-jwt:4.3.0' + implementation 'org.json:json:20230227' + implementation 'commons-io:commons-io:2.11.0' implementation 'org.apache.commons:commons-compress:1.22' implementation 'org.brotli:dec:0.1.2' - implementation 'org.python:jython-standalone:2.7.0' + implementation 'org.python:jython-standalone:2.7.3b1' implementation 'bsf:bsf:2.4.0' implementation 'org.apache-extras.beanshell:bsh:2.0b6' - implementation 'org.codehaus.groovy:groovy-all:3.0.7' + implementation 'org.codehaus.groovy:groovy-all:3.0.16' implementation 'com.eclipsesource.j2v8:j2v8_macosx_x86_64:4.6.0' implementation 'com.github.javafaker:javafaker:1.0.2' - implementation 'com.fifesoft:rsyntaxtextarea:3.2.2' + implementation 'com.fifesoft:rsyntaxtextarea:3.3.1' implementation 'com.fifesoft:autocomplete:3.3.1' testImplementation 'junit:junit:4.13.2' testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2' diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index c1f0ac4..8e6d8bf 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -2,6 +2,7 @@ import burp.ui.ExtensionPanel; import burp.ui.HackvertorInput; +import burp.ui.HackvertorMessageTab; import org.apache.commons.codec.digest.DigestUtils; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.fife.ui.rsyntaxtextarea.SyntaxConstants; @@ -200,7 +201,7 @@ public void run() { } try { hackvertor = new Hackvertor(); - stdout.println("Hackvertor v1.7.48"); + stdout.println("Hackvertor v1.7.49"); loadCustomTags(); loadGlobalVariables(); registerPayloadProcessors(); @@ -1060,6 +1061,7 @@ public void createCustomTag(String tagName, String language, String code, String public void extensionUnloaded() { hvShutdown = true; burpMenuBar.remove(hvMenuBar); + burpMenuBar.revalidate(); burpMenuBar.repaint(); callbacks.printOutput("Hackvertor unloaded"); } diff --git a/src/main/java/burp/Utils.java b/src/main/java/burp/Utils.java index 83bfd9e..7cd2efb 100644 --- a/src/main/java/burp/Utils.java +++ b/src/main/java/burp/Utils.java @@ -2,6 +2,7 @@ import burp.parser.Element; import burp.ui.HackvertorInput; +import burp.ui.MenuScroller; import org.apache.commons.lang3.StringUtils; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.Theme; diff --git a/src/main/java/burp/HackvertorMessageTab.java b/src/main/java/burp/ui/HackvertorMessageTab.java similarity index 97% rename from src/main/java/burp/HackvertorMessageTab.java rename to src/main/java/burp/ui/HackvertorMessageTab.java index c67b2cc..765807c 100644 --- a/src/main/java/burp/HackvertorMessageTab.java +++ b/src/main/java/burp/ui/HackvertorMessageTab.java @@ -1,5 +1,8 @@ -package burp; +package burp.ui; +import burp.BurpExtender; +import burp.Hackvertor; +import burp.IMessageEditorTab; import burp.ui.HackvertorPanel; import javax.swing.*; diff --git a/src/main/java/burp/ui/HackvertorPanel.java b/src/main/java/burp/ui/HackvertorPanel.java index c0ea160..5b55ff2 100644 --- a/src/main/java/burp/ui/HackvertorPanel.java +++ b/src/main/java/burp/ui/HackvertorPanel.java @@ -47,8 +47,6 @@ public HackvertorPanel(Hackvertor hackvertor, boolean showLogo){ this.inputArea = new HackvertorInput(); this.outputArea = new HackvertorInput(); Utils.fixRSyntaxAreaBurp(); - callbacks.customizeUiComponent(this.inputArea); - callbacks.customizeUiComponent(this.outputArea); this.inputArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML); this.outputArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML); Utils.configureRSyntaxArea(this.inputArea); diff --git a/src/main/java/burp/JTabbedPaneClosable.java b/src/main/java/burp/ui/JTabbedPaneClosable.java similarity index 98% rename from src/main/java/burp/JTabbedPaneClosable.java rename to src/main/java/burp/ui/JTabbedPaneClosable.java index e051220..73081e4 100644 --- a/src/main/java/burp/JTabbedPaneClosable.java +++ b/src/main/java/burp/ui/JTabbedPaneClosable.java @@ -1,7 +1,6 @@ -package burp; +package burp.ui; import javax.swing.*; -import javax.swing.plaf.metal.MetalIconFactory; import java.awt.*; import java.awt.event.*; diff --git a/src/main/java/burp/MenuScroller.java b/src/main/java/burp/ui/MenuScroller.java similarity index 99% rename from src/main/java/burp/MenuScroller.java rename to src/main/java/burp/ui/MenuScroller.java index ddb1256..b1f1d98 100644 --- a/src/main/java/burp/MenuScroller.java +++ b/src/main/java/burp/ui/MenuScroller.java @@ -2,7 +2,7 @@ * @(#)MenuScroller.java 1.5.0 04/02/12 */ -package burp; +package burp.ui; import java.awt.Color; import java.awt.Component; From 6604eb57bdbca687919e8b317da5a9c73e69b4d9 Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Tue, 4 Jul 2023 12:40:23 +0100 Subject: [PATCH 18/19] Updated version in manifest --- BappManifest.bmf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BappManifest.bmf b/BappManifest.bmf index 9897925..c6f52a1 100644 --- a/BappManifest.bmf +++ b/BappManifest.bmf @@ -2,12 +2,12 @@ Uuid: 65033cbd2c344fbabe57ac060b5dd100 ExtensionType: 1 Name: Hackvertor RepoName: hackvertor -ScreenVersion: 1.7.36 +ScreenVersion: 1.7.49 SerialVersion: 35 MinPlatformVersion: 0 ProOnly: False Author: Portswigger Web Security - Gareth Heyes ShortDescription: Converts data using a tag-based configuration to apply various encoding and escaping operations. EntryPoint: releases/hackvertor-all.jar -BuildCommand: ./gradlew fatJar +BuildCommand: ./gradlew jar SupportedProducts: Pro, Community From f16c9dcb24523e4bdce1c034c9d6b97c4d57315c Mon Sep 17 00:00:00 2001 From: Gareth Heyes Date: Fri, 7 Jul 2023 12:43:44 +0100 Subject: [PATCH 19/19] Update maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a818f1a..0b41167 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -40,6 +40,6 @@ jobs: - name: Release uses: hackvertor/release-action@v1.12.0 with: - tag: "Latest_Hackvertor_release" + tag: "latest_hackvertor_release" allowUpdates: true artifacts: "releases/*.jar"