A free, open-source alternative to Burp Suite: an intercepting proxy and web app security testing suite with Repeater, Intruder, Collaborator and a built-in OWASP ZAP scanner. Linux, AGPL-3.0.
Java application-securityappsecbug-bountyburp-alternativeburp-suitedasthttp-proxyinfosecintercepting-proxyjavaowaspowasp-zappenetration-testingpentestingsecuritysecurity-toolsvulnerability-scannerweb-application-securityweb-security
Decoder: a tinted pane keeps its tint when it is scrolled
scottsturrock5f4374df727e
diff --git a/src/opensuite/decoder/DecoderTool.java b/src/opensuite/decoder/DecoderTool.javaindex d85be10..a8f147c 100644--- a/src/opensuite/decoder/DecoderTool.java+++ b/src/opensuite/decoder/DecoderTool.java@@ -207,6 +207,26 @@ public class DecoderTool implements ToolModule {};}+ /** How strongly a transform's colour shows on the pane it was applied to, out of 255. */+ private static final int TINT_STRENGTH = 60;++ /**+ * The background of a pane the named transform was applied to: the transform's colour laid+ * lightly over the pane's own ground, or the ground itself when the transform has no colour.+ * Always one solid colour. A see-through background on a text area is painted over what is+ * already on screen, so the text smeared and the tint grew stronger each time the pane scrolled.+ */+ static Color paneColour(String opName, Color ground) {+ Color c = opColour(opName);+ if (c == null) return ground;+ return new Color(mix(c.getRed(), ground.getRed()), mix(c.getGreen(), ground.getGreen()),+ mix(c.getBlue(), ground.getBlue()));+ }++ private static int mix(int over, int under) {+ return Math.round((over * TINT_STRENGTH + under * (255 - TINT_STRENGTH)) / 255f);+ }+/** Dropdown rows tinted by their transform's colour. */private static final class OpRenderer extends DefaultListCellRenderer {@Override public Component getListCellRendererComponent(JList<?> list, Object v, int i, boolean sel, boolean f) {@@ -346,8 +366,12 @@ public class DecoderTool implements ToolModule {apply(this, kind, name);// The combo returns to its prompt; the colour of the pane below says what was applied.reset(combo);- Color c = opColour(name);- if (c != null) area.setBackground(new Color(c.getRed(), c.getGreen(), c.getBlue(), 60));+ showOpColour();+ }++ /** Tint the pane for the transform now applied to it, or clear the tint when it has no colour. */+ private void showOpColour() {+ area.setBackground(paneColour(opName, opensuite.ui.Theme.CONTENT));}private void smartDecode() {@@ -361,6 +385,7 @@ public class DecoderTool implements ToolModule {reset(encode);reset(hash);apply(this, Transforms.DECODE, guess);+ showOpColour();}void showError(String message) {diff --git a/tests/opensuite/decoder/DecoderTransformsTest.java b/tests/opensuite/decoder/DecoderTransformsTest.javaindex a6bc015..1e17aa2 100644--- a/tests/opensuite/decoder/DecoderTransformsTest.java+++ b/tests/opensuite/decoder/DecoderTransformsTest.java@@ -32,6 +32,26 @@ public final class DecoderTransformsTest {Expect.isTrue(Arrays.equals(data, dec("deflate", enc("deflate", data))), "deflate");});+ Harness.test("a transform tints its pane with a solid colour", () -> {+ java.awt.Color white = new java.awt.Color(0xFF, 0xFF, 0xFF), dark = new java.awt.Color(0x2B, 0x2B, 0x2B);+ for (java.awt.Color ground : new java.awt.Color[] { white, dark }) {+ for (String op : new String[] { "URL", "HTML", "Base64", "ASCII hex", "Hex", "Octal", "Binary", "Gzip" }) {+ java.awt.Color c = DecoderTool.paneColour(op, ground);+ // A see-through background smears when the pane scrolls.+ Expect.equal(c.getAlpha(), 255, op + " alpha");+ Expect.isTrue(!c.equals(ground), op + " is tinted");+ }+ }+ // The same shade the old see-through colour gave: base64 yellow at 60/255 over white.+ Expect.equal(DecoderTool.paneColour("Base64", white), new java.awt.Color(0xF5, 0xF1, 0xC3), "base64 over white");+ });++ Harness.test("a transform with no colour leaves the pane on its own ground", () -> {+ java.awt.Color ground = new java.awt.Color(0x2B, 0x2B, 0x2B);+ Expect.equal(DecoderTool.paneColour("SHA-256", ground), ground, "hash");+ Expect.equal(DecoderTool.paneColour(null, ground), ground, "none");+ });+Harness.test("smart-decode recognises gzip by its magic number", () -> {byte[] gz = enc("gzip", Bytes.bytes("some compressible text text text"));Expect.equal(Transforms.guess(gz), " gzip", "guess gzip");