autochrome icon indicating copy to clipboard operation
autochrome copied to clipboard

Burp Extension Java versions mismatch

Open jandr opened this issue 6 years ago • 4 comments

When compiling the Burp extension, it is compiled for java 9 (major version 53), as some files define this as the desired/required version. When trying to add the extension in Burp, if running from the Burp installer and launcher (which uses the bundled Java 8 instance included with Burp), the extension cannot be loaded due to the major version mismatch (53 vs 52).

Attempts to compile the extension for "-target 8" fail, because the code requires to be targeted for Java 9.

One can workaround the issue by running Burp manually with "java -jar burp.jar", using Java 9. However, when this is done, Burp "complains" that it has not been tested in Java other than 8, which is the recommended, and "things could fail or go wrong".

Thus, the only way of using the Extension is to use Burp with a "non-recommended" Java.

The following files require major version 53:

burp/IBurpExtender.class burp/IBurpExtenderCallbacks.class com/nccgroup/autochrome/useragenttag/BurpExtender.class

jandr avatar Apr 04 '18 11:04 jandr

There shouldn't be anything in the code that requires Java 9. (It builds cleanly for me using javac 1.8.0_92 from Homebrew on macOS, for example.)

Can you try compiling using -release 8 instead of -target 8, and see if that works? If it doesn't, please let me know what compiler + version you're using, and what specific errors you get when compiling and/or loading the extension? Thanks.

RyanKoppenhaver-NCC avatar Apr 09 '18 20:04 RyanKoppenhaver-NCC

I am using Linux. I tried using both Openjdk 8 and Oracle Java 8. However, both javac binaries do not have a -release, but only a -target, as stated in the -help command:

-target <release> Generate class files for specific VM version

The output when trying to compile it with -release is the following:

$ /usr/lib/jvm/oracle-java8-jdk-amd64/bin/javac -target 8 burp/BurpExtender.java 
warning: ./burp/IBurpExtender.class: major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: ./burp/IBurpExtenderCallbacks.class: major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: ./com/nccgroup/autochrome/useragenttag/BurpExtender.class: major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
3 warnings

The Java 8 versions I am using are the following:

$ /usr/lib/jvm/oracle-java8-jdk-amd64/bin/java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

and

$ /usr/lib/jvm/java-8-openjdk-amd64/bin/java -version
openjdk version "1.8.0_162"
OpenJDK Runtime Environment (build 1.8.0_162-8u162-b12-1-b12)
OpenJDK 64-Bit Server VM (build 25.162-b12, mixed mode)

jandr avatar Apr 11 '18 11:04 jandr

Yes, the -release flag is new with the Java 9 javac. If you're compiling with Java 8, no flags should be necessary.

I'm sorry, but I haven't been able to reproduce the major version warning that you're seeing, on multiple platforms and Java versions. Maybe try running javac under env -i, to ensure you don't have any environment variables related to other Java versions affecting things?

In any case, I've released a binary JAR of the extension for anyone who's having difficulty building it themselves. Hope that's helpful: https://github.com/nccgroup/autochrome/releases/download/20180411-burp-ext-snapshot/autochrome-useragenttag.jar

RyanKoppenhaver-NCC avatar Apr 11 '18 18:04 RyanKoppenhaver-NCC

I saw this on Ubuntu, it is fairly simple to fix your environment though in order to correctly build the jar. First check what versions of Java you have installed:

# update-java-alternatives -l
java-1.9.0-openjdk-amd64       1091       /usr/lib/jvm/java-1.9.0-openjdk-amd64
java-8-oracle                  1081       /usr/lib/jvm/java-8-oracle
java-9-oracle                  1091       /usr/lib/jvm/java-9-oracle

Set to Java 8(I'm using Oracle Java here, if you installed from the repos then the openjdk 8 name will be different):

# sudo update-java-alternatives -s java-8-oracle

If you have already ran javac under Java 9, then rebuilding will generate some warnings:

warning: ./burp/IBurpExtender.class: major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: ./burp/IBurpExtenderCallbacks.class: major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: ./com/nccgroup/autochrome/useragenttag/BurpExtender.class: major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.

To get rid of those, you can either clean up all the class files from the previous build or revert to put src folder in a clean state.

redNixon avatar May 28 '18 06:05 redNixon

Closing, please re-open the issue if it still exists.

peter-h-ncc avatar Feb 27 '23 04:02 peter-h-ncc