The Burp Extender APIs in Java/Jython/JRuby are deprecated. In Burp Suite, click on Extensions->APIs for Burp Extender APIs documentation. Use the Montoya API in Java (only supported language, but Kotlin is compatible) instead.
- Creating Burp extension (PortSwigger)
- burp-extensions-montoya-api-examples (GitHub, PortSwigger)
- Interface MontoyaApi (GitHub.io, PortSwigger)
- KotlinBurpExtensionBase (GitHub) – template
Build Burp Extensions with Kotlin
See Kotlin Cheat Sheet.
Installation & Setup
Install Java SDK
Download Java JDK 21 (Oracle, latest Long-Term Support (LTS) release of the Java SE Platform).
Add or set the environment variables (on Windows):
- JAVA_HOME (SYSTEM): “C:\Program Files\Java\jdk-21”
- PATH (USER): “%PATH%;%JAVA_HOME\bin”
Install extension Gradle for Java in Visual Studio Code
Use Gradle to install dependencies and build the project.
Restart Visual Studio Code if needed (for the Java environment variables).
In Visual Studio Code, click on Extensions and search for Gradle for Java. Click on Install. By default, if you have installed the Gradle for Java extension, the Gradle Build Server is used to import Gradle projects.
Project Setup
Download the Kotlin extension template
Download the ZIP file from KotlinBurpExtensionBase (GitHub).
settings.gradle.kts
Change your project name.
rootProject.name = "KotlinBurpExtensionBase"
rootProject.name = "myProject"
build.gradle.kts
Configurations about Kotlin and the build system. Important to build JAR files (needed to build Burp Suite extensions):
id("com.github.johnrengelman.shadow") version "8.1.1"
Change this to your package name.
group = "com.yournamehere.montoya"
Edit code
Edit code in Project Name folder->src\main\kotlin. Rename this file (in Gradle, right-click, Refactor->Rename. Not sure how in Visual Studio Code).
Rename the file YourBurpKotlinExtensionName.kt AND the class name in the code. Like myExtension.kt and in the code:
class myExtension : BurpExtension {
Replace this code with your extension name that will be displayed in the Burp Suite Extension tab.
api.extension().setName("Your Plugin Name Here")
api.extension().setName("My Extension")
Build
In Visual Studio Code, click on the elephant icon (Gradle).
When you change configurations files (like settings.gradle.kts, build.gradle.kts), you need to click on “…”->Refresh Gradle Project View button (beside Gradle Projects).
To build the extension, double-click on Tasks->shadow->shadowJar. It will build the shadowJar and all the dependencies. It will generate a JAR file under:
Project Name folder->build->libs->myProject-0.1.0-all.jar
The generated JAR file name MUST contain “-all” to contain all the dependencies.
Add the extension in Burp Suite
- Click on the Extensions tab in Burp Suite
- Click on Add
- Extension type: Java
- Extension file (.jar): click on Select file, and select Project Name-0.1.0-all.jar
- Click Next
- Click Close