├── libs ├── zap-2.4.1.jar └── zap-2.4.3.jar ├── scriptgen-zap-plugin ├── src │ └── main │ │ ├── resources │ │ ├── org │ │ │ └── zaproxy │ │ │ │ └── zap │ │ │ │ └── extension │ │ │ │ └── scriptgen │ │ │ │ └── Messages.properties │ │ └── ZapAddOn.xml │ │ └── java │ │ └── org │ │ └── zaproxy │ │ └── zap │ │ └── extension │ │ └── scriptgen │ │ ├── ReissueRequestScripterMenuAction.java │ │ ├── ReissueRequestScripterMenuExtension.java │ │ └── ZapHttpRequestMapper.java └── pom.xml ├── scriptgen-core ├── src │ ├── test │ │ ├── resources │ │ │ └── templates │ │ │ │ └── basic_template.tpl │ │ └── java │ │ │ └── com │ │ │ └── h3xstream │ │ │ └── scriptgen │ │ │ ├── gui │ │ │ ├── GeneratorFrameTestManualGetRequest.java │ │ │ ├── GeneratorFrameTestManualPostRequest.java │ │ │ ├── GeneratorFrameTestManualBrokenRequest.java │ │ │ ├── GeneratorFrameTestManualPostMultiPartRequest.java │ │ │ ├── SaveScriptGuiTest.java │ │ │ └── IntegrationGuiTest.java │ │ │ ├── template │ │ │ ├── TemplateUtilTest.java │ │ │ ├── CodeTemplateBuilderBaseTest.java │ │ │ ├── CodeTemplateBuilderPerlTest.java │ │ │ ├── CodeTemplateBuilderPhpTest.java │ │ │ ├── CodeTemplateBuilderJavascriptXhrTest.java │ │ │ ├── CodeTemplateBuilderJavascriptJqueryTest.java │ │ │ ├── CodeTemplateBuilderPythonSulleyTest.java │ │ │ ├── CodeTemplateBuilderRubyTest.java │ │ │ ├── CodeTemplateBuilderPowershellTest.java │ │ │ ├── CodeTemplateBuilderPythonRequestsTest.java │ │ │ └── CodeTemplateBuilderTest.java │ │ │ └── HttpRequestInfoFixtures.java │ └── main │ │ ├── resources │ │ └── com │ │ │ └── h3xstream │ │ │ └── scriptgen │ │ │ ├── images │ │ │ ├── script_text.png │ │ │ └── images_license.txt │ │ │ ├── templates │ │ │ ├── html_form.tpl │ │ │ ├── javascript_xhr.tpl │ │ │ ├── javascript_jquery.tpl │ │ │ ├── php_curl.tpl │ │ │ ├── psh_webrequest.tpl │ │ │ ├── perl_lwp.tpl │ │ │ ├── python_requests.tpl │ │ │ ├── ruby_nethttp.tpl │ │ │ └── python_sulley.tpl │ │ │ └── themes │ │ │ └── dark.xml │ │ └── java │ │ └── com │ │ └── h3xstream │ │ └── scriptgen │ │ ├── ReissueRequestScripterConstants.java │ │ ├── model │ │ ├── AuthCredential.java │ │ ├── MultiPartParameter.java │ │ ├── DisplaySettings.java │ │ └── HttpRequestInfo.java │ │ ├── template │ │ ├── XmlUtil.java │ │ ├── CodeTemplateBuilder.java │ │ ├── HttpRequestUtil.java │ │ └── TemplateUtil.java │ │ ├── ReissueRequestScripter.java │ │ ├── gui │ │ ├── ScriptFileChooser.java │ │ ├── SettingsPanel.java │ │ ├── GeneratorController.java │ │ └── GeneratorFrame.java │ │ └── LanguageOption.java └── pom.xml ├── .gitignore ├── .travis.yml ├── BappManifest.bmf ├── burp-api ├── pom.xml └── src │ └── main │ └── java │ └── burp │ ├── IScopeChangeListener.java │ ├── IIntruderAttack.java │ ├── IHttpRequestResponsePersisted.java │ ├── ITempFile.java │ ├── IExtensionStateListener.java │ ├── IBurpExtender.java │ ├── IScannerListener.java │ ├── IHttpService.java │ ├── ITab.java │ ├── IMenuItemHandler.java │ ├── IProxyListener.java │ ├── IContextMenuFactory.java │ ├── IScannerInsertionPointProvider.java │ ├── IIntruderPayloadGeneratorFactory.java │ ├── IHttpListener.java │ ├── IMessageEditorTabFactory.java │ ├── ICookie.java │ ├── IHttpRequestResponseWithMarkers.java │ ├── IIntruderPayloadProcessor.java │ ├── IIntruderPayloadGenerator.java │ ├── IMessageEditorController.java │ ├── IMessageEditor.java │ ├── ISessionHandlingAction.java │ ├── IResponseInfo.java │ ├── IScanQueueItem.java │ ├── IRequestInfo.java │ ├── ITextEditor.java │ ├── IHttpRequestResponse.java │ ├── IParameter.java │ ├── IMessageEditorTab.java │ ├── IScanIssue.java │ ├── IScannerCheck.java │ ├── IInterceptedProxyMessage.java │ ├── IScannerInsertionPoint.java │ └── IContextMenuInvocation.java ├── BappDescription.html ├── README.md ├── scriptgen-burp-plugin ├── pom.xml └── src │ └── main │ └── java │ └── burp │ ├── BurpExtender.java │ └── BurpHttpRequestMapper.java └── pom.xml /libs/zap-2.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PortSwigger/reissue-request-scripter/HEAD/libs/zap-2.4.1.jar -------------------------------------------------------------------------------- /libs/zap-2.4.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PortSwigger/reissue-request-scripter/HEAD/libs/zap-2.4.3.jar -------------------------------------------------------------------------------- /scriptgen-zap-plugin/src/main/resources/org/zaproxy/zap/extension/scriptgen/Messages.properties: -------------------------------------------------------------------------------- 1 | ext.scriptgen.menu=Generate Script 2 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/resources/templates/basic_template.tpl: -------------------------------------------------------------------------------- 1 | <#list requests as req> 2 | 3 | url = "${req.url}" //Unescape 4 | url = "${util.pythonStr(req.url)}" //Escape 5 | 6 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/images/script_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PortSwigger/reissue-request-scripter/HEAD/scriptgen-core/src/main/resources/com/h3xstream/scriptgen/images/script_text.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #Eclipse 2 | .classpath 3 | .project 4 | test-output 5 | .settings 6 | 7 | #IntelliJ 8 | *.iml 9 | *.ipr 10 | *.iws 11 | .idea/ 12 | 13 | #Gradle 14 | .gradle 15 | 16 | #Build directories 17 | bin/ 18 | build/ 19 | target/ 20 | libs/ 21 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | #install: mvn install:install-file -Dfile=libs/zap-2.4.3.jar -DgroupId=org.zaproxy -DartifactId=zaproxy -Dversion=2.4.3 -Dpackaging=jar 3 | jdk: 4 | - oraclejdk7 5 | before_install: 6 | - "export DISPLAY=:99.0" 7 | - "sh -e /etc/init.d/xvfb start" 8 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/ReissueRequestScripterConstants.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen; 2 | 3 | public class ReissueRequestScripterConstants { 4 | 5 | public static String PLUGIN_NAME = "Reissue Request Scripter 6.0"; 6 | public static String AUTHOR = "Philippe Arteau (h3xstream)"; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/images/images_license.txt: -------------------------------------------------------------------------------- 1 | script_text.png 2 | License: Creative Commons 3.0 (http://creativecommons.org/licenses/by/3.0/) 3 | Download from: http://findicons.com/icon/116928/script_text?id=395788 4 | Author: Yusuke Kamiyamane 5 | Author website: http://p.yusukekamiyamane.com/ 6 | -------------------------------------------------------------------------------- /BappManifest.bmf: -------------------------------------------------------------------------------- 1 | Uuid: 6e0b53d8c801471c9dc614a016d8a20d 2 | ExtensionType: 1 3 | Name: Reissue Request Scripter 4 | RepoName: reissue-request-scripter 5 | ScreenVersion: 6.1.1 6 | SerialVersion: 10 7 | MinPlatformVersion: 0 8 | ProOnly: False 9 | Author: Philippe Arteau 10 | ShortDescription: This extension generates scripts to reissue selected requests. 11 | EntryPoint: scriptgen-burp-plugin/target/scriptgen-burp-plugin-6.jar 12 | BuildCommand: mvn package -DskipTests=true -Dmaven.javadoc.skip=true -B 13 | SupportedProducts: Pro, Community 14 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/model/AuthCredential.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.model; 2 | 3 | public class AuthCredential { 4 | 5 | private final String username; 6 | private final String password; 7 | 8 | public AuthCredential(String username, String password) { 9 | this.username = username; 10 | this.password = password; 11 | } 12 | 13 | public String getUsername() { 14 | return username; 15 | } 16 | 17 | public String getPassword() { 18 | return password; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/gui/GeneratorFrameTestManualGetRequest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.gui; 2 | 3 | import com.esotericsoftware.minlog.Log; 4 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 5 | import com.h3xstream.scriptgen.HttpRequestInfoFixtures; 6 | import com.h3xstream.scriptgen.ReissueRequestScripter; 7 | 8 | public class GeneratorFrameTestManualGetRequest { 9 | 10 | public static void main(String[] args) { 11 | Log.set(Log.LEVEL_DEBUG); 12 | HttpRequestInfo req = HttpRequestInfoFixtures.getGetRequest(); 13 | new ReissueRequestScripter(req).openDialogWindow(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/gui/GeneratorFrameTestManualPostRequest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.gui; 2 | 3 | import com.esotericsoftware.minlog.Log; 4 | import com.h3xstream.scriptgen.ReissueRequestScripter; 5 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 6 | import com.h3xstream.scriptgen.HttpRequestInfoFixtures; 7 | 8 | public class GeneratorFrameTestManualPostRequest { 9 | 10 | public static void main(String[] args) { 11 | Log.set(Log.LEVEL_DEBUG); 12 | HttpRequestInfo req = HttpRequestInfoFixtures.getPostRequest(); 13 | new ReissueRequestScripter(req).openDialogWindow(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/gui/GeneratorFrameTestManualBrokenRequest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.gui; 2 | 3 | import com.esotericsoftware.minlog.Log; 4 | import com.h3xstream.scriptgen.HttpRequestInfoFixtures; 5 | import com.h3xstream.scriptgen.ReissueRequestScripter; 6 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 7 | 8 | public class GeneratorFrameTestManualBrokenRequest { 9 | 10 | public static void main(String[] args) { 11 | Log.set(Log.LEVEL_DEBUG); 12 | HttpRequestInfo req = HttpRequestInfoFixtures.getBrokenRequest(); 13 | new ReissueRequestScripter(req).openDialogWindow(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /burp-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | scriptgen-root-pom 7 | com.h3xstream.scriptgen 8 | 6.1.0 9 | 10 | 4.0.0 11 | 12 | burp-api 13 | 14 | 15 | Code taken from : http://portswigger.net/burp/extender/ 16 | 17 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/gui/GeneratorFrameTestManualPostMultiPartRequest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.gui; 2 | 3 | import com.esotericsoftware.minlog.Log; 4 | import com.h3xstream.scriptgen.HttpRequestInfoFixtures; 5 | import com.h3xstream.scriptgen.ReissueRequestScripter; 6 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 7 | 8 | public class GeneratorFrameTestManualPostMultiPartRequest { 9 | 10 | public static void main(String[] args) { 11 | Log.set(Log.LEVEL_DEBUG); 12 | HttpRequestInfo req = HttpRequestInfoFixtures.getPostMultiPartRequest(); 13 | new ReissueRequestScripter(req).openDialogWindow(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /scriptgen-zap-plugin/src/main/resources/ZapAddOn.xml: -------------------------------------------------------------------------------- 1 | 2 | Reissue Request Scripter 3 | 5 4 | Generate script to reproduce the HTTP request selected. 5 | Philippe Arteau (h3xStream) 6 | https://github.com/h3xstream/http-script-generator 7 | 8 | 9 | 10 | org.zaproxy.zap.extension.scriptgen.ReissueRequestScripterMenuExtension 11 | 12 | 13 | 14 | 15 | 16 | 2.4.3 17 | 18 | 19 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/template/TemplateUtilTest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | import org.testng.annotations.BeforeClass; 4 | import org.testng.annotations.Test; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | public class TemplateUtilTest { 10 | 11 | private TemplateUtil util = new TemplateUtil(); 12 | 13 | @Test 14 | public void pythonUtilMethods() { 15 | Map p = new HashMap(); 16 | p.put("a","12345"); 17 | p.put("b","\"test\""); 18 | p.put("uni","'%\u0001\u0002\u0003\u0000abc"); 19 | String dictRepr = util.pythonDict(p); 20 | System.out.println("======="); 21 | System.out.println(dictRepr); 22 | System.out.println("======="); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/template/CodeTemplateBuilderBaseTest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 4 | 5 | import java.util.Arrays; 6 | 7 | import static org.testng.Assert.assertTrue; 8 | 9 | public abstract class CodeTemplateBuilderBaseTest { 10 | 11 | public void testTemplateContains(String tpl, String shouldContains,HttpRequestInfo req) throws Exception { 12 | 13 | String output = new CodeTemplateBuilder().request(Arrays.asList(req)).templatePath(tpl).build(); 14 | 15 | System.out.println("====="); 16 | System.out.println(output); 17 | System.out.println("====="); 18 | 19 | assertTrue(output.contains(shouldContains),"The template should contains the string : "+shouldContains); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IScopeChangeListener.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IScopeChangeListener.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * Extensions can implement this interface and then call 14 | * IBurpExtenderCallbacks.registerScopeChangeListener() to register 15 | * a scope change listener. The listener will be notified whenever a change 16 | * occurs to Burp's suite-wide target scope. 17 | */ 18 | public interface IScopeChangeListener 19 | { 20 | /** 21 | * This method is invoked whenever a change occurs to Burp's suite-wide 22 | * target scope. 23 | */ 24 | void scopeChanged(); 25 | } 26 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/model/MultiPartParameter.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.model; 2 | 3 | public class MultiPartParameter { 4 | private final String name; 5 | private final String value; 6 | private final String contentType; 7 | private final String fileName; 8 | 9 | public MultiPartParameter(String name, String value, String contentType, String fileName) { 10 | this.name = name; 11 | this.value = value; 12 | this.contentType = contentType; 13 | this.fileName = fileName; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public String getValue() { 21 | return value; 22 | } 23 | 24 | public String getContentType() { 25 | return contentType; 26 | } 27 | 28 | public String getFileName() { 29 | return fileName; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/template/CodeTemplateBuilderPerlTest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 4 | import com.h3xstream.scriptgen.HttpRequestInfoFixtures; 5 | import org.testng.annotations.Test; 6 | 7 | public class CodeTemplateBuilderPerlTest extends CodeTemplateBuilderBaseTest { 8 | HttpRequestInfo reqGet = HttpRequestInfoFixtures.getGetRequest(); 9 | HttpRequestInfo reqPost = HttpRequestInfoFixtures.getPostRequest(); 10 | 11 | @Test 12 | public void testGetTemplate() throws Exception { 13 | testTemplateContains("com/h3xstream/scriptgen/templates/perl_lwp.tpl","my $req = GET",reqGet); 14 | } 15 | 16 | @Test 17 | public void testPostTemplate() throws Exception { 18 | testTemplateContains("com/h3xstream/scriptgen/templates/perl_lwp.tpl","my $req = POST",reqPost); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/template/CodeTemplateBuilderPhpTest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 4 | import com.h3xstream.scriptgen.HttpRequestInfoFixtures; 5 | import org.testng.annotations.Test; 6 | 7 | public class CodeTemplateBuilderPhpTest extends CodeTemplateBuilderBaseTest { 8 | 9 | 10 | HttpRequestInfo reqGet = HttpRequestInfoFixtures.getGetRequest(); 11 | HttpRequestInfo reqPost = HttpRequestInfoFixtures.getPostRequest(); 12 | 13 | @Test 14 | public void testGetTemplate() throws Exception { 15 | testTemplateContains("com/h3xstream/scriptgen/templates/php_curl.tpl","IHttpRequestResponse object whose request and response messages 15 | * have been saved to temporary files using 16 | * IBurpExtenderCallbacks.saveBuffersToTempFiles(). 17 | */ 18 | public interface IHttpRequestResponsePersisted extends IHttpRequestResponse 19 | { 20 | /** 21 | * This method is used to permanently delete the saved temporary files. It 22 | * will no longer be possible to retrieve the request or response for this 23 | * item. 24 | */ 25 | void deleteTempFiles(); 26 | } 27 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/template/CodeTemplateBuilderRubyTest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 4 | import com.h3xstream.scriptgen.HttpRequestInfoFixtures; 5 | import org.testng.annotations.Test; 6 | 7 | import static org.testng.Assert.assertTrue; 8 | 9 | public class CodeTemplateBuilderRubyTest extends CodeTemplateBuilderBaseTest { 10 | 11 | 12 | HttpRequestInfo reqGet = HttpRequestInfoFixtures.getGetRequest(); 13 | HttpRequestInfo reqPost = HttpRequestInfoFixtures.getPostRequest(); 14 | 15 | @Test 16 | public void testGetTemplate() throws Exception { 17 | testTemplateContains("com/h3xstream/scriptgen/templates/ruby_nethttp.tpl","Net::HTTP::Get",reqGet); 18 | } 19 | 20 | @Test 21 | public void testPostTemplate() throws Exception { 22 | testTemplateContains("com/h3xstream/scriptgen/templates/ruby_nethttp.tpl","Net::HTTP::Post",reqPost); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/templates/html_form.tpl: -------------------------------------------------------------------------------- 1 | <#list requests as req> 2 |
3 | <#if req.parametersPost??> 4 | <#list req.parametersPost?keys as p> 5 | 6 | 7 | <#elseif req.parametersGet??> 8 | <#list req.parametersGet?keys as p> 9 | 10 | 11 | 12 | <#if req.parametersMultipart??> 13 | <#list req.parametersMultipart as mp> 14 | 15 | 16 | 17 | 18 | 19 |
20 | 23 | 24 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/template/CodeTemplateBuilderPowershellTest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 4 | import com.h3xstream.scriptgen.HttpRequestInfoFixtures; 5 | import org.testng.annotations.Test; 6 | 7 | import static org.testng.Assert.assertTrue; 8 | 9 | public class CodeTemplateBuilderPowershellTest extends CodeTemplateBuilderBaseTest { 10 | 11 | HttpRequestInfo reqGet = HttpRequestInfoFixtures.getGetRequest(); 12 | HttpRequestInfo reqPost = HttpRequestInfoFixtures.getPostRequest(); 13 | 14 | @Test 15 | public void testGetTemplate() throws Exception { 16 | testTemplateContains("com/h3xstream/scriptgen/templates/psh_webrequest.tpl","-Body $paramsGet",reqGet); 17 | } 18 | 19 | @Test 20 | public void testPostTemplate() throws Exception { 21 | testTemplateContains("com/h3xstream/scriptgen/templates/psh_webrequest.tpl","-Body $paramsPost",reqPost); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/templates/javascript_xhr.tpl: -------------------------------------------------------------------------------- 1 | <#list requests as req> 2 | var http = new XMLHttpRequest(); 3 | <#if req.parametersPost??> 4 | var params = "${util.jsUrlParam(req.parametersPost)}"; 5 | 6 | <#if req.postData??> 7 | var params = "${util.jsStr(req.postData)}"; 8 | 9 | http.open("${util.jsStr(req.method?upper_case)}", "${util.jsStr(req.queryString)}<#if req.parametersGet??>?${util.jsUrlParam(req.parametersGet)}", true); 10 | 11 | <#if req.postData??> 12 | http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 13 | 14 | <#if req.headers??> 15 | <#list req.headers?keys as h> 16 | http.setRequestHeader("${util.jsStr(h)}","${util.jsStr(req.headers[h])}"); 17 | 18 | 19 | 20 | http.onreadystatechange = function() { 21 | if(http.readyState == 4 && http.status == 200) { 22 | console.info(http.status); 23 | console.info(http.responseText); 24 | } 25 | } 26 | http.send(params); 27 | 28 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/template/CodeTemplateBuilderPythonRequestsTest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 4 | import com.h3xstream.scriptgen.HttpRequestInfoFixtures; 5 | import org.testng.annotations.Test; 6 | 7 | import static org.testng.Assert.assertTrue; 8 | 9 | public class CodeTemplateBuilderPythonRequestsTest extends CodeTemplateBuilderBaseTest { 10 | 11 | 12 | HttpRequestInfo reqGet = HttpRequestInfoFixtures.getGetRequest(); 13 | HttpRequestInfo reqPost = HttpRequestInfoFixtures.getPostRequest(); 14 | 15 | @Test 16 | public void testGetTemplate() throws Exception { 17 | testTemplateContains("com/h3xstream/scriptgen/templates/python_requests.tpl","session.get(",reqGet); 18 | } 19 | 20 | @Test 21 | public void testPostTemplate() throws Exception { 22 | testTemplateContains("com/h3xstream/scriptgen/templates/python_requests.tpl","session.post(",reqPost); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/ITempFile.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)ITempFile.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * This interface is used to hold details of a temporary file that has been 14 | * created via a call to 15 | * IBurpExtenderCallbacks.saveToTempFile(). 16 | * 17 | */ 18 | public interface ITempFile 19 | { 20 | /** 21 | * This method is used to retrieve the contents of the buffer that was saved 22 | * in the temporary file. 23 | * 24 | * @return The contents of the buffer that was saved in the temporary file. 25 | */ 26 | byte[] getBuffer(); 27 | 28 | /** 29 | * This method is used to permanently delete the temporary file when it is 30 | * no longer required. 31 | */ 32 | void delete(); 33 | } 34 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/model/DisplaySettings.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.model; 2 | 3 | public class DisplaySettings { 4 | private boolean proxy = false; 5 | private boolean minimalHeaders = false; 6 | private boolean disableSsl = false; 7 | 8 | 9 | public boolean isProxy() { 10 | return proxy; 11 | } 12 | 13 | public void setProxy(boolean proxy) { 14 | this.proxy = proxy; 15 | } 16 | 17 | public boolean isMinimalHeaders() { 18 | return minimalHeaders; 19 | } 20 | 21 | public void setMinimalHeaders(boolean minimalHeaders) { 22 | this.minimalHeaders = minimalHeaders; 23 | } 24 | 25 | public boolean isDisableSsl() { 26 | return disableSsl; 27 | } 28 | 29 | public void setDisableSsl(boolean disableSsl) { 30 | this.disableSsl = disableSsl; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "[proxy=" + proxy + ",minimalHeaders=" + minimalHeaders + ",disableSsl=" + disableSsl + "]"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IExtensionStateListener.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IExtensionStateListener.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * Extensions can implement this interface and then call 14 | * IBurpExtenderCallbacks.registerExtensionStateListener() to 15 | * register an extension state listener. The listener will be notified of 16 | * changes to the extension's state. Note: Any extensions that start 17 | * background threads or open system resources (such as files or database 18 | * connections) should register a listener and terminate threads / close 19 | * resources when the extension is unloaded. 20 | */ 21 | public interface IExtensionStateListener 22 | { 23 | /** 24 | * This method is called when the extension is unloaded. 25 | */ 26 | void extensionUnloaded(); 27 | } 28 | -------------------------------------------------------------------------------- /BappDescription.html: -------------------------------------------------------------------------------- 1 |

This extension generates scripts to reissue a selected request. The scripts can be run outside of Burp.

2 |

It can be useful to script attacks such as second order SQL injection, padding oracle, fuzzing encoded value, etc.

3 | 4 |

Features

5 | 10 | 11 |

Limitations

12 | 16 | 17 |

Usage

18 | 24 | 25 |

Requires Java version 7.

26 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IBurpExtender.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IBurpExtender.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * All extensions must implement this interface. 14 | * 15 | * Implementations must be called BurpExtender, in the package burp, must be 16 | * declared public, and must provide a default (public, no-argument) 17 | * constructor. 18 | */ 19 | public interface IBurpExtender 20 | { 21 | /** 22 | * This method is invoked when the extension is loaded. It registers an 23 | * instance of the 24 | * IBurpExtenderCallbacks interface, providing methods that may 25 | * be invoked by the extension to perform various actions. 26 | * 27 | * @param callbacks An 28 | * IBurpExtenderCallbacks object. 29 | */ 30 | void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks); 31 | } 32 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IScannerListener.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IScannerListener.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * Extensions can implement this interface and then call 14 | * IBurpExtenderCallbacks.registerScannerListener() to register a 15 | * Scanner listener. The listener will be notified of new issues that are 16 | * reported by the Scanner tool. Extensions can perform custom analysis or 17 | * logging of Scanner issues by registering a Scanner listener. 18 | */ 19 | public interface IScannerListener 20 | { 21 | /** 22 | * This method is invoked when a new issue is added to Burp Scanner's 23 | * results. 24 | * 25 | * @param issue An 26 | * IScanIssue object that the extension can query to obtain 27 | * details about the new issue. 28 | */ 29 | void newScanIssue(IScanIssue issue); 30 | } 31 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/gui/SaveScriptGuiTest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.gui; 2 | 3 | import static org.mockito.Matchers.eq; 4 | 5 | public class SaveScriptGuiTest { 6 | 7 | // FrameFixture window; 8 | // 9 | // GeneratorController controller; 10 | // GeneratorFrame frame; 11 | // 12 | // public void prepareWindow() { 13 | // //Spy version to do verification on calls 14 | // controller = spy(new GeneratorController()); 15 | // frame = new GeneratorFrame(LanguageOption.values); 16 | // 17 | // HttpRequestInfo req = HttpRequestInfoFixtures.getPostRequest(); 18 | // ReissueRequestScripter scriptGen = new ReissueRequestScripter(req,controller,frame); 19 | // window = new FrameFixture(scriptGen.openDialogWindow()); 20 | // window.show(); 21 | // } 22 | // 23 | // @BeforeClass 24 | // public void beforeAllTests() { 25 | // //The same window is reused for all tests 26 | // prepareWindow(); 27 | // } 28 | // 29 | // 30 | // @AfterClass 31 | // public void afterClass() { 32 | // window.close(); 33 | // } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/template/CodeTemplateBuilderTest.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 4 | import com.h3xstream.scriptgen.HttpRequestInfoFixtures; 5 | import org.testng.annotations.Test; 6 | 7 | import java.util.Arrays; 8 | 9 | import static org.mockito.Mockito.mock; 10 | import static org.mockito.Mockito.spy; 11 | import static org.mockito.Mockito.when; 12 | import static org.testng.Assert.assertEquals; 13 | import static org.testng.Assert.assertTrue; 14 | 15 | public class CodeTemplateBuilderTest { 16 | 17 | @Test 18 | public void basicTemplate() throws Exception { 19 | HttpRequestInfo req1 = spy(HttpRequestInfoFixtures.getPostRequest()); 20 | 21 | String testUrl = "http://blog.h3xstream.com/secret.txt"; 22 | when(req1.getUrl()).thenReturn(testUrl); 23 | String output = new CodeTemplateBuilder().request(Arrays.asList(req1)).templatePath("templates/basic_template.tpl").build(); 24 | 25 | assertTrue(output.contains(testUrl),"The url bind to the model was not include in the template."); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IHttpService.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IHttpService.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * This interface is used to provide details about an HTTP service, to which 14 | * HTTP requests can be sent. 15 | */ 16 | public interface IHttpService 17 | { 18 | /** 19 | * This method returns the hostname or IP address for the service. 20 | * 21 | * @return The hostname or IP address for the service. 22 | */ 23 | String getHost(); 24 | 25 | /** 26 | * This method returns the port number for the service. 27 | * 28 | * @return The port number for the service. 29 | */ 30 | int getPort(); 31 | 32 | /** 33 | * This method returns the protocol for the service. 34 | * 35 | * @return The protocol for the service. Expected values are "http" or 36 | * "https". 37 | */ 38 | String getProtocol(); 39 | } 40 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/templates/javascript_jquery.tpl: -------------------------------------------------------------------------------- 1 | //JQuery preload (optional) 2 | (function(){ 3 | var s = document.createElement('script');s.type = 'text/javascript';s.async = true;s.src = 'https://code.jquery.com/jquery-2.1.4.min.js'; 4 | (document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(s); 5 | })(); 6 | 7 | <#list requests as req> 8 | $.ajax({ 9 | url: "${util.jsStr(req.queryString)}<#if req.parametersGet?? && req.parametersPost??>?${util.jsUrlParam(req.parametersGet)}", 10 | type: "${util.jsStr(req.method?lower_case)}", 11 | data: 12 | <#if req.parametersPost??> 13 | ${util.jsMap(req.parametersPost)} 14 | <#elseif req.parametersGet?? && !req.parametersPost??> 15 | ${util.jsMap(req.parametersGet)} 16 | <#else> 17 | {} 18 | 19 | , 20 | <#if req.headers??>headers: { 21 | <#list req.headers?keys as h> 22 | "${util.jsStr(h)}":"${util.jsStr(req.headers[h])}"<#if h_has_next>, 23 | 24 | }, 25 | success: function (data) { 26 | console.info(data); 27 | } 28 | }); 29 | 30 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/ITab.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)ITab.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | import java.awt.Component; 13 | 14 | /** 15 | * This interface is used to provide Burp with details of a custom tab that will 16 | * be added to Burp's UI, using a method such as 17 | * IBurpExtenderCallbacks.addSuiteTab(). 18 | */ 19 | public interface ITab 20 | { 21 | /** 22 | * Burp uses this method to obtain the caption that should appear on the 23 | * custom tab when it is displayed. 24 | * 25 | * @return The caption that should appear on the custom tab when it is 26 | * displayed. 27 | */ 28 | String getTabCaption(); 29 | 30 | /** 31 | * Burp uses this method to obtain the component that should be used as the 32 | * contents of the custom tab when it is displayed. 33 | * 34 | * @return The component that should be used as the contents of the custom 35 | * tab when it is displayed. 36 | */ 37 | Component getUiComponent(); 38 | } 39 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IMenuItemHandler.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IMenuItemHandler.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * Extensions can implement this interface and then call 14 | * IBurpExtenderCallbacks.registerMenuItem() to register a custom 15 | * context menu item. 16 | * 17 | * @deprecated Use 18 | * IContextMenuFactory instead. 19 | */ 20 | @Deprecated 21 | public interface IMenuItemHandler 22 | { 23 | /** 24 | * This method is invoked by Burp Suite when the user clicks on a custom 25 | * menu item which the extension has registered with Burp. 26 | * 27 | * @param menuItemCaption The caption of the menu item which was clicked. 28 | * This parameter enables extensions to provide a single implementation 29 | * which handles multiple different menu items. 30 | * @param messageInfo Details of the HTTP message(s) for which the context 31 | * menu was displayed. 32 | */ 33 | void menuItemClicked( 34 | String menuItemCaption, 35 | IHttpRequestResponse[] messageInfo); 36 | } 37 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IProxyListener.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IProxyListener.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * Extensions can implement this interface and then call 14 | * IBurpExtenderCallbacks.registerProxyListener() to register a 15 | * Proxy listener. The listener will be notified of requests and responses being 16 | * processed by the Proxy tool. Extensions can perform custom analysis or 17 | * modification of these messages, and control in-UI message interception, by 18 | * registering a proxy listener. 19 | */ 20 | public interface IProxyListener 21 | { 22 | /** 23 | * This method is invoked when an HTTP message is being processed by the 24 | * Proxy. 25 | * 26 | * @param messageIsRequest Indicates whether the HTTP message is a request 27 | * or a response. 28 | * @param message An 29 | * IInterceptedProxyMessage object that extensions can use to 30 | * query and update details of the message, and control whether the message 31 | * should be intercepted and displayed to the user for manual review or 32 | * modification. 33 | */ 34 | void processProxyMessage( 35 | boolean messageIsRequest, 36 | IInterceptedProxyMessage message); 37 | } 38 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/template/XmlUtil.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | public class XmlUtil { 4 | 5 | public static String escapeValue(String originalUnprotectedString) { 6 | if (originalUnprotectedString == null) { 7 | return null; 8 | } 9 | boolean anyCharactersProtected = false; 10 | 11 | StringBuffer stringBuffer = new StringBuffer(); 12 | for (int i = 0; i < originalUnprotectedString.length(); i++) { 13 | char ch = originalUnprotectedString.charAt(i); 14 | 15 | boolean controlCharacter = ch < 32; 16 | boolean unicodeButNotAscii = ch > 126; 17 | boolean characterWithSpecialMeaningInXML = ch == '<' || ch == '&' || ch == '>' || ch == '"' || ch == '\'' || ch == '\\'; 18 | 19 | if (characterWithSpecialMeaningInXML || unicodeButNotAscii || controlCharacter) { 20 | stringBuffer.append("&#" + (int) ch + ";"); 21 | anyCharactersProtected = true; 22 | } else { 23 | stringBuffer.append(ch); 24 | } 25 | } 26 | if (anyCharactersProtected == false) { 27 | return originalUnprotectedString; 28 | } 29 | 30 | return stringBuffer.toString(); 31 | } 32 | 33 | public static void main(String[] args) { 34 | System.out.println(escapeValue("test")); 35 | System.out.println(escapeValue("\"abc")); 36 | System.out.println(escapeValue("\\")); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/templates/php_curl.tpl: -------------------------------------------------------------------------------- 1 | 3 | <#if req.parametersPost?? || req.parametersMultipart??> 4 | $paramsPost = ${util.phpMergePostMultipart(req.parametersPost,req.parametersMultipart)}; 5 | 6 | 7 | <#if req.postData??> 8 | $postData = "${util.phpStr(req.postData)}"; 9 | 10 | 11 | $req = curl_init("${util.phpStr(req.urlWithQuery)}"); 12 | curl_setopt($req, CURLOPT_RETURNTRANSFER, true); 13 | <#if req.parametersPost?? || req.parametersMultipart??> 14 | curl_setopt($req, CURLOPT_POSTFIELDS, $paramsPost); 15 | 16 | <#if req.postData??> 17 | curl_setopt($req, CURLOPT_POSTFIELDS, $postData); 18 | 19 | <#if req.headers??> 20 | curl_setopt($req, CURLOPT_HTTPHEADER, ${util.phpHeadersList(req.headers)}); 21 | 22 | <#if req.cookies??> 23 | curl_setopt($req, CURLOPT_COOKIE,"${util.phpCookies(req.cookies)}"); 24 | 25 | <#if req.basicAuth??> 26 | curl_setopt($req, CURLOPT_USERPWD, '${util.phpStr(req.basicAuth.username)}:${util.phpStr(req.basicAuth.password)}'); 27 | curl_setopt($req, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 28 | 29 | <#if req.ssl && settings.disableSsl> 30 | curl_setopt($req, CURLOPT_SSL_VERIFYHOST, false); 31 | curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false); 32 | 33 | <#if settings.proxy> 34 | curl_setopt($req, CURLOPT_PROXY, '127.0.0.1:8080'); 35 | 36 | $result = curl_exec($req); 37 | 38 | echo "Status code: ".curl_getinfo($req, CURLINFO_HTTP_CODE)."\n"; 39 | echo "Response body: ".$result."\n"; 40 | 41 | curl_close($req); 42 | 43 | 44 | ?> -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IContextMenuFactory.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IContextMenuFactory.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | import java.util.List; 13 | import javax.swing.JMenuItem; 14 | 15 | /** 16 | * Extensions can implement this interface and then call 17 | * IBurpExtenderCallbacks.registerContextMenuFactory() to register 18 | * a factory for custom context menu items. 19 | */ 20 | public interface IContextMenuFactory 21 | { 22 | /** 23 | * This method will be called by Burp when the user invokes a context menu 24 | * anywhere within Burp. The factory can then provide any custom context 25 | * menu items that should be displayed in the context menu, based on the 26 | * details of the menu invocation. 27 | * 28 | * @param invocation An object that implements the 29 | * IMessageEditorTabFactory interface, which the extension can 30 | * query to obtain details of the context menu invocation. 31 | * @return A list of custom menu items (which may include sub-menus, 32 | * checkbox menu items, etc.) that should be displayed. Extensions may 33 | * return 34 | * null from this method, to indicate that no menu items are 35 | * required. 36 | */ 37 | List createMenuItems(IContextMenuInvocation invocation); 38 | } 39 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IScannerInsertionPointProvider.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IScannerInsertionPointProvider.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | import java.util.List; 13 | 14 | /** 15 | * Extensions can implement this interface and then call 16 | * IBurpExtenderCallbacks.registerScannerInsertionPointProvider() 17 | * to register a factory for custom Scanner insertion points. 18 | */ 19 | public interface IScannerInsertionPointProvider 20 | { 21 | /** 22 | * When a request is actively scanned, the Scanner will invoke this method, 23 | * and the provider should provide a list of custom insertion points that 24 | * will be used in the scan. Note: these insertion points are used in 25 | * addition to those that are derived from Burp Scanner's configuration, and 26 | * those provided by any other Burp extensions. 27 | * 28 | * @param baseRequestResponse The base request that will be actively 29 | * scanned. 30 | * @return A list of 31 | * IScannerInsertionPoint objects that should be used in the 32 | * scanning, or 33 | * null if no custom insertion points are applicable for this 34 | * request. 35 | */ 36 | List getInsertionPoints( 37 | IHttpRequestResponse baseRequestResponse); 38 | } 39 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IIntruderPayloadGeneratorFactory.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IIntruderPayloadGeneratorFactory.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * Extensions can implement this interface and then call 14 | * IBurpExtenderCallbacks.registerIntruderPayloadGeneratorFactory() 15 | * to register a factory for custom Intruder payloads. 16 | */ 17 | public interface IIntruderPayloadGeneratorFactory 18 | { 19 | /** 20 | * This method is used by Burp to obtain the name of the payload generator. 21 | * This will be displayed as an option within the Intruder UI when the user 22 | * selects to use extension-generated payloads. 23 | * 24 | * @return The name of the payload generator. 25 | */ 26 | String getGeneratorName(); 27 | 28 | /** 29 | * This method is used by Burp when the user starts an Intruder attack that 30 | * uses this payload generator. 31 | * 32 | * @param attack An 33 | * IIntruderAttack object that can be queried to obtain details 34 | * about the attack in which the payload generator will be used. 35 | * @return A new instance of 36 | * IIntruderPayloadGenerator that will be used to generate 37 | * payloads for the attack. 38 | */ 39 | IIntruderPayloadGenerator createNewInstance(IIntruderAttack attack); 40 | } 41 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IHttpListener.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IHttpListener.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * Extensions can implement this interface and then call 14 | * IBurpExtenderCallbacks.registerHttpListener() to register an 15 | * HTTP listener. The listener will be notified of requests and responses made 16 | * by any Burp tool. Extensions can perform custom analysis or modification of 17 | * these messages by registering an HTTP listener. 18 | */ 19 | public interface IHttpListener 20 | { 21 | /** 22 | * This method is invoked when an HTTP request is about to be issued, and 23 | * when an HTTP response has been received. 24 | * 25 | * @param toolFlag A flag indicating the Burp tool that issued the request. 26 | * Burp tool flags are defined in the 27 | * IBurpExtenderCallbacks interface. 28 | * @param messageIsRequest Flags whether the method is being invoked for a 29 | * request or response. 30 | * @param messageInfo Details of the request / response to be processed. 31 | * Extensions can call the setter methods on this object to update the 32 | * current message and so modify Burp's behavior. 33 | */ 34 | void processHttpMessage(int toolFlag, 35 | boolean messageIsRequest, 36 | IHttpRequestResponse messageInfo); 37 | } 38 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IMessageEditorTabFactory.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IMessageEditorTabFactory.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * Extensions can implement this interface and then call 14 | * IBurpExtenderCallbacks.registerMessageEditorTabFactory() to 15 | * register a factory for custom message editor tabs. This allows extensions to 16 | * provide custom rendering or editing of HTTP messages, within Burp's own HTTP 17 | * editor. 18 | */ 19 | public interface IMessageEditorTabFactory 20 | { 21 | /** 22 | * Burp will call this method once for each HTTP message editor, and the 23 | * factory should provide a new instance of an 24 | * IMessageEditorTab object. 25 | * 26 | * @param controller An 27 | * IMessageEditorController object, which the new tab can query 28 | * to retrieve details about the currently displayed message. This may be 29 | * null for extension-invoked message editors where the 30 | * extension has not provided an editor controller. 31 | * @param editable Indicates whether the hosting editor is editable or 32 | * read-only. 33 | * @return A new 34 | * IMessageEditorTab object for use within the message editor. 35 | */ 36 | IMessageEditorTab createNewInstance(IMessageEditorController controller, 37 | boolean editable); 38 | } 39 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/ICookie.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)ICookie.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | import java.util.Date; 13 | 14 | /** 15 | * This interface is used to hold details about an HTTP cookie. 16 | */ 17 | public interface ICookie 18 | { 19 | /** 20 | * This method is used to retrieve the domain for which the cookie is in 21 | * scope. 22 | * 23 | * @return The domain for which the cookie is in scope. Note: For 24 | * cookies that have been analyzed from responses (by calling 25 | * IExtensionHelpers.analyzeResponse() and then 26 | * IResponseInfo.getCookies(), the domain will be 27 | * null if the response did not explicitly set a domain 28 | * attribute for the cookie. 29 | */ 30 | String getDomain(); 31 | 32 | /** 33 | * This method is used to retrieve the expiration time for the cookie. 34 | * 35 | * @return The expiration time for the cookie, or 36 | * null if none is set (i.e., for non-persistent session 37 | * cookies). 38 | */ 39 | Date getExpiration(); 40 | 41 | /** 42 | * This method is used to retrieve the name of the cookie. 43 | * 44 | * @return The name of the cookie. 45 | */ 46 | String getName(); 47 | 48 | /** 49 | * This method is used to retrieve the value of the cookie. 50 | * @return The value of the cookie. 51 | */ 52 | String getValue(); 53 | } 54 | -------------------------------------------------------------------------------- /scriptgen-zap-plugin/src/main/java/org/zaproxy/zap/extension/scriptgen/ReissueRequestScripterMenuAction.java: -------------------------------------------------------------------------------- 1 | package org.zaproxy.zap.extension.scriptgen; 2 | 3 | import com.h3xstream.scriptgen.ReissueRequestScripter; 4 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 5 | import org.parosproxy.paros.network.HttpMessage; 6 | import org.zaproxy.zap.view.PopupMenuHttpMessage; 7 | import org.zaproxy.zap.view.popup.PopupMenuItemHttpMessageContainer; 8 | 9 | import java.io.IOException; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | public class ReissueRequestScripterMenuAction extends PopupMenuItemHttpMessageContainer { 14 | 15 | private ReissueRequestScripterMenuExtension extension; 16 | 17 | public ReissueRequestScripterMenuAction(String label) { 18 | super(label, true); //true == the action can be done on multiple items 19 | } 20 | 21 | protected void performActions(List httpMessages) { 22 | try { 23 | List req = ZapHttpRequestMapper.buildRequestInfo(httpMessages); 24 | new ReissueRequestScripter(req).openDialogWindow(); 25 | } catch (IOException e) { 26 | throw new RuntimeException(e); 27 | } 28 | } 29 | 30 | @Override 31 | public void performAction(HttpMessage httpMessage) { 32 | try { 33 | List req = ZapHttpRequestMapper.buildRequestInfo(Arrays.asList(httpMessage)); 34 | new ReissueRequestScripter(req).openDialogWindow(); 35 | } catch (IOException e) { 36 | throw new RuntimeException(e); 37 | } 38 | } 39 | 40 | 41 | public void setExtension(ReissueRequestScripterMenuExtension extension) { 42 | this.extension = extension; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/templates/psh_webrequest.tpl: -------------------------------------------------------------------------------- 1 | <#if util.atLeastOneSsl(requests) && settings.disableSsl> 2 | add-type @" 3 | using System.Net; 4 | using System.Security.Cryptography.X509Certificates; 5 | public class TrustAllCertsPolicy : ICertificatePolicy { 6 | public bool CheckValidationResult( 7 | ServicePoint srvPoint, X509Certificate certificate, 8 | WebRequest request, int certificateProblem) { 9 | return true; 10 | } 11 | } 12 | "@ 13 | [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy 14 | 15 | 16 | <#list requests as req> 17 | <#if req.parametersGet??> 18 | $paramsGet = ${util.powershellDict(req.parametersGet)} 19 | 20 | <#if req.parametersPost??> 21 | $paramsPost = ${util.powershellDict(req.parametersPost)} 22 | 23 | <#if req.headers??> 24 | $headers = ${util.powershellDict(req.headers)} 25 | 26 | 27 | <#if req.cookies??> 28 | $cc = New-Object System.Net.CookieContainer 29 | <#list req.cookies?keys as c> 30 | $cc.Add( $(New-Object Uri( $uri )), $(New-Object System.Net.Cookie("${util.powershellStr(c)}", "${util.powershellStr(req.cookies[c])}")) ) 31 | 32 | $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession 33 | $session.Cookies = $cc 34 | 35 | 36 | $response = Invoke-WebRequest -Method "${util.powershellStr(req.method)}" -Uri "${util.powershellStr(req.url)}"<#if req.headers??> -Headers $headers<#if req.cookies??> -WebSession $session<#if req.parametersPost??> -Body $paramsPost<#if req.parametersGet??> -Body $paramsGet<#if settings.proxy> -Proxy 'http://127.0.0.1:8080' 37 | 38 | Write-Host "Status code: $($response.StatusCode)" 39 | Write-host "Response body: $($response.Content)" 40 | 41 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IHttpRequestResponseWithMarkers.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IHttpRequestResponseWithMarkers.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | import java.util.List; 13 | 14 | /** 15 | * This interface is used for an 16 | * IHttpRequestResponse object that has had markers applied. 17 | * Extensions can create instances of this interface using 18 | * IBurpExtenderCallbacks.applyMarkers(), or provide their own 19 | * implementation. Markers are used in various situations, such as specifying 20 | * Intruder payload positions, Scanner insertion points, and highlights in 21 | * Scanner issues. 22 | */ 23 | public interface IHttpRequestResponseWithMarkers extends IHttpRequestResponse 24 | { 25 | /** 26 | * This method returns the details of the request markers. 27 | * 28 | * @return A list of index pairs representing the offsets of markers for the 29 | * request message. Each item in the list is an int[2] array containing the 30 | * start and end offsets for the marker. The method may return 31 | * null if no request markers are defined. 32 | */ 33 | List getRequestMarkers(); 34 | 35 | /** 36 | * This method returns the details of the response markers. 37 | * 38 | * @return A list of index pairs representing the offsets of markers for the 39 | * response message. Each item in the list is an int[2] array containing the 40 | * start and end offsets for the marker. The method may return 41 | * null if no response markers are defined. 42 | */ 43 | List getResponseMarkers(); 44 | } 45 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IIntruderPayloadProcessor.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IIntruderPayloadProcessor.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * Extensions can implement this interface and then call 14 | * IBurpExtenderCallbacks.registerIntruderPayloadProcessor() to 15 | * register a custom Intruder payload processor. 16 | */ 17 | public interface IIntruderPayloadProcessor 18 | { 19 | /** 20 | * This method is used by Burp to obtain the name of the payload processor. 21 | * This will be displayed as an option within the Intruder UI when the user 22 | * selects to use an extension-provided payload processor. 23 | * 24 | * @return The name of the payload processor. 25 | */ 26 | String getProcessorName(); 27 | 28 | /** 29 | * This method is invoked by Burp each time the processor should be applied 30 | * to an Intruder payload. 31 | * 32 | * @param currentPayload The value of the payload to be processed. 33 | * @param originalPayload The value of the original payload prior to 34 | * processing by any already-applied processing rules. 35 | * @param baseValue The base value of the payload position, which will be 36 | * replaced with the current payload. 37 | * @return The value of the processed payload. This may be 38 | * null to indicate that the current payload should be skipped, 39 | * and the attack will move directly to the next payload. 40 | */ 41 | byte[] processPayload( 42 | byte[] currentPayload, 43 | byte[] originalPayload, 44 | byte[] baseValue); 45 | } 46 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/ReissueRequestScripter.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen; 2 | 3 | import com.h3xstream.scriptgen.gui.GeneratorController; 4 | import com.h3xstream.scriptgen.gui.GeneratorFrame; 5 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 6 | 7 | import javax.swing.*; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | public class ReissueRequestScripter { 12 | private List requests; 13 | private GeneratorFrame frame; 14 | 15 | private GeneratorController controller; 16 | 17 | public ReissueRequestScripter(HttpRequestInfo req) { 18 | requests = new ArrayList<>(); 19 | requests.add(req); 20 | 21 | this.controller = new GeneratorController(); 22 | this.frame = new GeneratorFrame(LanguageOption.values); 23 | } 24 | public ReissueRequestScripter(List requests) { 25 | this.requests = requests; 26 | 27 | this.controller = new GeneratorController(); 28 | this.frame = new GeneratorFrame(LanguageOption.values); 29 | } 30 | 31 | /** 32 | * Constructor intend for testing purpose. 33 | * @param requests 34 | * @param controller 35 | * @param frame 36 | */ 37 | public ReissueRequestScripter(List requests, GeneratorController controller, GeneratorFrame frame) { 38 | this.requests = requests; 39 | 40 | this.controller = controller; 41 | this.frame = frame; 42 | } 43 | 44 | public JFrame openDialogWindow() { 45 | this.controller.setHttpRequest(requests); 46 | 47 | this.frame.setController(controller); //Controller need to be set prior setting 48 | this.frame.setTitleSuffix(requests.get(0).getUrl()); 49 | this.frame.setVisible(true); 50 | this.frame.updateLanguageSelection(0); 51 | return frame; 52 | } 53 | 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/templates/perl_lwp.tpl: -------------------------------------------------------------------------------- 1 | use LWP::UserAgent; 2 | use HTTP::Request::Common; 3 | <#if util.atLeastOneCookie(requests)> 4 | use HTTP::Cookies; 5 | 6 | 7 | <#list requests as req> 8 | my $url = URI->new("${util.perlStr(req.url)}"); 9 | <#if req.parametersGet??> 10 | $url->query_form(${util.perlMap(req.parametersGet)}); 11 | 12 | 13 | <#if req.cookies??> 14 | my $cookies = HTTP::Cookies->new(); 15 | <#list req.cookies?keys as c> 16 | $cookies->set_cookie(0,"${util.perlStr(c)}", "${util.perlStr(req.cookies[c])}","/","${util.perlStr(req.hostname)}"); 17 | 18 | 19 | 20 | my $ua = LWP::UserAgent->new(); 21 | <#if req.cookies??> 22 | $ua->cookie_jar($cookies); 23 | 24 | <#if req.basicAuth??> 25 | $ua->credentials("${util.perlStr(req.hostname)}", "realm-name", '${util.perlStr(req.basicAuth.username)}', '${util.perlStr(req.basicAuth.password)}'); 26 | 27 | <#if req.ssl && settings.disableSsl> 28 | $ua->ssl_opts( verify_hostnames => 0 ); 29 | 30 | <#if settings.proxy> 31 | $ua->proxy(['http'], 'http://127.0.0.1:8080/'); 32 | 33 | 34 | <#if req.parametersMultipart??> 35 | @multipartParams = ${util.perlMergePostMultipart(req.parametersPost,req.parametersMultipart)}; 36 | my $req = POST $url, Content_Type=>'form-data', Content=> @multipartParams; 37 | <#elseif req.parametersPost??> 38 | my $req = POST $url<#if req.parametersPost??>, ${util.perlMap(req.parametersPost)}; 39 | <#else> 40 | my $req = ${util.perlStr(req.method?upper_case)} $url; 41 | 42 | <#if req.headers??> 43 | <#list req.headers?keys as h> 44 | $req->header("${util.perlStr(h)}" => "${util.perlStr(req.headers[h])}"); 45 | 46 | 47 | <#if req.postData??> 48 | $req->content("${util.perlStr(req.postData)}"); 49 | 50 | my $resp = $ua->request($req); 51 | 52 | print "Status code : ".$resp->code."\n"; 53 | print "Response body : ".$resp->content."\n"; 54 | 55 | -------------------------------------------------------------------------------- /scriptgen-zap-plugin/src/main/java/org/zaproxy/zap/extension/scriptgen/ReissueRequestScripterMenuExtension.java: -------------------------------------------------------------------------------- 1 | package org.zaproxy.zap.extension.scriptgen; 2 | 3 | import com.h3xstream.scriptgen.ReissueRequestScripterConstants; 4 | import org.parosproxy.paros.Constant; 5 | import org.parosproxy.paros.extension.ExtensionAdaptor; 6 | import org.parosproxy.paros.extension.ExtensionHook; 7 | 8 | import java.util.ResourceBundle; 9 | 10 | public class ReissueRequestScripterMenuExtension extends ExtensionAdaptor { 11 | 12 | private ReissueRequestScripterMenuAction menuItem; 13 | private ResourceBundle messages = null; 14 | 15 | 16 | public ReissueRequestScripterMenuExtension(String msg) { 17 | super(msg); 18 | initExtension(); 19 | } 20 | 21 | public ReissueRequestScripterMenuExtension() { 22 | initExtension(); 23 | } 24 | 25 | private void initExtension() { 26 | messages = ResourceBundle.getBundle(this.getClass().getPackage().getName() + ".Messages", Constant.getLocale()); 27 | } 28 | 29 | @Override 30 | public String getAuthor() { 31 | return ReissueRequestScripterConstants.AUTHOR; 32 | } 33 | 34 | @Override 35 | public void hook(ExtensionHook extensionHook) { 36 | super.hook(extensionHook); 37 | 38 | if (getView() != null) { 39 | // Register our popup menu item, as long as we're not running as a daemon 40 | extensionHook.getHookMenu().addPopupMenuItem(getPopupMsgMenu()); 41 | } 42 | } 43 | 44 | public String getMessage(String msgId) { 45 | return messages.getString(msgId); 46 | } 47 | 48 | private ReissueRequestScripterMenuAction getPopupMsgMenu() { 49 | if (menuItem == null) { 50 | menuItem = new ReissueRequestScripterMenuAction(getMessage("ext.scriptgen.menu")); 51 | menuItem.setExtension(this); 52 | } 53 | return menuItem; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IIntruderPayloadGenerator.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IIntruderPayloadGenerator.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * This interface is used for custom Intruder payload generators. Extensions 14 | * that have registered an 15 | * IIntruderPayloadGeneratorFactory must return a new instance of 16 | * this interface when required as part of a new Intruder attack. 17 | */ 18 | public interface IIntruderPayloadGenerator 19 | { 20 | /** 21 | * This method is used by Burp to determine whether the payload generator is 22 | * able to provide any further payloads. 23 | * 24 | * @return Extensions should return 25 | * false when all the available payloads have been used up, 26 | * otherwise 27 | * true. 28 | */ 29 | boolean hasMorePayloads(); 30 | 31 | /** 32 | * This method is used by Burp to obtain the value of the next payload. 33 | * 34 | * @param baseValue The base value of the current payload position. This 35 | * value may be 36 | * null if the concept of a base value is not applicable (e.g. 37 | * in a battering ram attack). 38 | * @return The next payload to use in the attack. 39 | */ 40 | byte[] getNextPayload(byte[] baseValue); 41 | 42 | /** 43 | * This method is used by Burp to reset the state of the payload generator 44 | * so that the next call to 45 | * getNextPayload() returns the first payload again. This 46 | * method will be invoked when an attack uses the same payload generator for 47 | * more than one payload position, for example in a sniper attack. 48 | */ 49 | void reset(); 50 | } 51 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/templates/python_requests.tpl: -------------------------------------------------------------------------------- 1 | import requests 2 | <#if util.atLeastOneBasicAuth(requests)> 3 | from requests.auth import HTTPBasicAuth 4 | 5 | <#if settings.proxy> 6 | 7 | proxies = { 8 | "http": "http://127.0.0.1:8080", 9 | "https": "http://127.0.0.1:8080", 10 | } 11 | 12 | 13 | session = requests.Session() 14 | 15 | <#list requests as req> 16 | <#if req.parametersGet??> 17 | paramsGet = ${util.pythonDict(req.parametersGet)} 18 | 19 | <#if req.parametersPost?? && !util.hasSpecialCharsPyRequest(req.parametersPost)> 20 | paramsPost = ${util.pythonDict(req.parametersPost)} 21 | 22 | <#if util.hasSpecialCharsPyRequest(req.parametersPost)> 23 | paramsPostDict = ${util.pythonDict(req.parametersPost)} 24 | paramsPost = "&".join("%s=%s" % (k,v) for k,v in paramsPostDict.items()) #Manually concatenated to avoid some encoded characters 25 | 26 | <#if req.parametersMultipart??> 27 | paramsMultipart = ${util.pythonDictMultipart(req.parametersMultipart)} 28 | 29 | <#if req.postData??> 30 | rawBody = "${util.pythonStr(req.postData)}" 31 | 32 | <#if req.headers??> 33 | headers = ${util.pythonDict(req.headers)} 34 | 35 | <#if req.cookies??> 36 | cookies = ${util.pythonDict(req.cookies)} 37 | 38 | response = session.${util.alphaOnly(req.method?lower_case)}("${util.pythonStr(req.url)}"<#if req.parametersPost??>, data=paramsPost<#if req.parametersMultipart??>, files=paramsMultipart<#if req.postData??>, data=rawBody<#if req.parametersGet??>, params=paramsGet<#if req.headers??>, headers=headers<#if req.cookies??>, cookies=cookies<#if req.basicAuth??>, auth=HTTPBasicAuth("${util.pythonStr(req.basicAuth.username)}","${util.pythonStr(req.basicAuth.password)}")<#if settings.proxy>, proxies=proxies<#if req.ssl && settings.disableSsl>, verify=False) 39 | 40 | print("Status code: %i" % response.status_code) 41 | print("Response body: %s" % response.content) 42 | 43 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IMessageEditorController.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IMessageEditorController.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * This interface is used by an 14 | * IMessageEditor to obtain details about the currently displayed 15 | * message. Extensions that create instances of Burp's HTTP message editor can 16 | * optionally provide an implementation of 17 | * IMessageEditorController, which the editor will invoke when it 18 | * requires further information about the current message (for example, to send 19 | * it to another Burp tool). Extensions that provide custom editor tabs via an 20 | * IMessageEditorTabFactory will receive a reference to an 21 | * IMessageEditorController object for each tab instance they 22 | * generate, which the tab can invoke if it requires further information about 23 | * the current message. 24 | */ 25 | public interface IMessageEditorController 26 | { 27 | /** 28 | * This method is used to retrieve the HTTP service for the current message. 29 | * 30 | * @return The HTTP service for the current message. 31 | */ 32 | IHttpService getHttpService(); 33 | 34 | /** 35 | * This method is used to retrieve the HTTP request associated with the 36 | * current message (which may itself be a response). 37 | * 38 | * @return The HTTP request associated with the current message. 39 | */ 40 | byte[] getRequest(); 41 | 42 | /** 43 | * This method is used to retrieve the HTTP response associated with the 44 | * current message (which may itself be a request). 45 | * 46 | * @return The HTTP response associated with the current message. 47 | */ 48 | byte[] getResponse(); 49 | } 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Reissue Request Scripter (Burp plugin) [![Build Status](https://travis-ci.org/h3xstream/http-script-generator.png)](https://travis-ci.org/h3xstream/http-script-generator) 2 | 3 | This extension generates scripts to reissue a selected request. The scripts can be run outside of Burp. It can be useful to script attacks such as second order SQL injection, padding oracle, fuzzing encoded value, etc. 4 | 5 | ## License 6 | 7 | This software is release under [LGPL](http://www.gnu.org/licenses/lgpl.html). 8 | 9 | ## Downloads 10 | 11 | (Last updated : December 12, 2016) 12 | 13 | ZAP plugin : [Download](https://github.com/h3xstream/http-script-generator/blob/gh-pages/releases/zap/scriptgen-alpha-6.zap?raw=true) 14 | 15 | Burp Suite Pro plugin : [Download](https://github.com/h3xstream/http-script-generator/blob/gh-pages/releases/burp/scriptgen-burp-plugin-6.jar?raw=true) 16 | 17 | ## Contributors 18 | 19 | - [mattpresson](https://github.com/mattpresson) : Addition of [PowerShell support](https://github.com/h3xstream/http-script-generator/commit/37cdbbb8e4bcd9ab47ec8b0f5974e29b24737e64) 20 | 21 | ## Screenshots 22 | 23 | ### Context Menu 24 | 25 | ![Reissue Request Scripter: Context Menu](http://h3xstream.github.io/http-script-generator/screenshots/1_context_menu.png) 26 | 27 | ### Main Window 28 | 29 | ![Reissue Request Scripter: Main Window](http://h3xstream.github.io/http-script-generator/screenshots/2_main_window.png) 30 | 31 | ### Language Options 32 | 33 | Scripts can be generated for various languages : Python, Ruby, Perl, PHP, PowerShell and JavaScript. 34 | 35 | ![Reissue Request Scripter: Language Options](http://h3xstream.github.io/http-script-generator/screenshots/3_languages.png) 36 | 37 | ### More Options 38 | 39 | Since version 4.0, common script variations can be applied. These variation include: proxy redirection, reduction of "noisy" headers and disabling SSL/TLS verification. 40 | 41 | ![Reissue Request Scripter: Language Options](http://h3xstream.github.io/http-script-generator/screenshots/4_settings.png) 42 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/template/CodeTemplateBuilder.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | import com.h3xstream.scriptgen.model.DisplaySettings; 4 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 5 | import freemarker.template.Configuration; 6 | import freemarker.template.Template; 7 | 8 | import java.io.*; 9 | import java.util.HashMap; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | /** 14 | * This utility class is a wrapper of the template engine chosen (FreeMarker). 15 | */ 16 | public class CodeTemplateBuilder { 17 | 18 | private List requests; 19 | private String templatePath; 20 | private DisplaySettings displaySettings = new DisplaySettings(); 21 | 22 | public CodeTemplateBuilder request(List requests) { 23 | this.requests = requests; 24 | return this; 25 | } 26 | 27 | public CodeTemplateBuilder templatePath(String templatePath) { 28 | this.templatePath = templatePath; 29 | return this; 30 | } 31 | 32 | 33 | public CodeTemplateBuilder displaySettings(DisplaySettings displaySettings) { 34 | this.displaySettings = displaySettings; 35 | return this; 36 | } 37 | 38 | public String build() throws Exception { 39 | 40 | Configuration cfg = new Configuration(); 41 | cfg.setClassForTemplateLoading(this.getClass(), "/"); 42 | Template tpl = cfg.getTemplate(templatePath); 43 | 44 | 45 | Map ctxData = new HashMap(); 46 | if(displaySettings.isMinimalHeaders()) { 47 | ctxData.put("requests", HttpRequestUtil.withMinimalHeaders(requests)); 48 | } 49 | else { 50 | ctxData.put("requests", requests); 51 | } 52 | ctxData.put("settings",displaySettings); 53 | ctxData.put("util", new TemplateUtil()); 54 | 55 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 56 | tpl.process(ctxData, new OutputStreamWriter(out)); 57 | out.flush(); 58 | 59 | return new String(out.toByteArray()); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/gui/ScriptFileChooser.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.gui; 2 | 3 | import com.esotericsoftware.minlog.Log; 4 | import com.h3xstream.scriptgen.LanguageOption; 5 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 6 | 7 | import javax.swing.*; 8 | import java.awt.*; 9 | import java.io.File; 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.io.OutputStream; 13 | import java.util.List; 14 | 15 | public class ScriptFileChooser { 16 | 17 | public static String FILE_CHOOSER = "FILE_CHOOSER"; 18 | 19 | public void saveScriptToFile(String code, final LanguageOption lang, Component parent, List requests, GeneratorController cont) { 20 | 21 | JFileChooser fileChooser = new JFileChooser(); 22 | 23 | fileChooser.setDialogTitle("Save to file"); 24 | String currentDirectory = new File(".").getAbsolutePath(); 25 | 26 | fileChooser.setSelectedFile(new File(currentDirectory,requests.get(0).getHostname().replace('.','-')+"_http_script." + lang.getExtension())); 27 | fileChooser.setName(FILE_CHOOSER); 28 | 29 | //Extension filter 30 | // while(fileChooser.getChoosableFileFilters().length > 0) { 31 | // fileChooser.removeChoosableFileFilter(fileChooser.getChoosableFileFilters()[0]); 32 | // } 33 | // fileChooser.addChoosableFileFilter(new FileNameExtensionFilter(lang.getLanguage(), lang.getExtension())); 34 | 35 | if (fileChooser.showSaveDialog(parent) == JFileChooser.APPROVE_OPTION) { 36 | File file = fileChooser.getSelectedFile(); 37 | 38 | try { 39 | if(file.createNewFile()) { 40 | OutputStream out = new FileOutputStream(file); 41 | out.write(code.getBytes()); 42 | out.close(); 43 | 44 | cont.fileSaveSuccess(file.getAbsolutePath()); 45 | } 46 | } catch (IOException e) { 47 | Log.warn("Unable to save the script file : "+e.getMessage()); 48 | cont.fileSaveError(file.getAbsolutePath()); 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IMessageEditor.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IMessageEditor.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | import java.awt.Component; 13 | 14 | /** 15 | * This interface is used to provide extensions with an instance of Burp's HTTP 16 | * message editor, for the extension to use in its own UI. Extensions should 17 | * call 18 | * IBurpExtenderCallbacks.createMessageEditor() to obtain an 19 | * instance of this interface. 20 | */ 21 | public interface IMessageEditor 22 | { 23 | /** 24 | * This method returns the UI component of the editor, for extensions to add 25 | * to their own UI. 26 | * 27 | * @return The UI component of the editor. 28 | */ 29 | Component getComponent(); 30 | 31 | /** 32 | * This method is used to display an HTTP message in the editor. 33 | * 34 | * @param message The HTTP message to be displayed. 35 | * @param isRequest Flags whether the message is an HTTP request or 36 | * response. 37 | */ 38 | void setMessage(byte[] message, boolean isRequest); 39 | 40 | /** 41 | * This method is used to retrieve the currently displayed message, which 42 | * may have been modified by the user. 43 | * 44 | * @return The currently displayed HTTP message. 45 | */ 46 | byte[] getMessage(); 47 | 48 | /** 49 | * This method is used to determine whether the current message has been 50 | * modified by the user. 51 | * 52 | * @return An indication of whether the current message has been modified by 53 | * the user since it was first displayed. 54 | */ 55 | boolean isMessageModified(); 56 | 57 | /** 58 | * This method returns the data that is currently selected by the user. 59 | * 60 | * @return The data that is currently selected by the user, or 61 | * null if no selection is made. 62 | */ 63 | byte[] getSelectedData(); 64 | } 65 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/templates/ruby_nethttp.tpl: -------------------------------------------------------------------------------- 1 | require "net/http" 2 | require "uri" 3 | <#if util.atLeastOneSsl(requests)> 4 | require "openssl" 5 | 6 | <#if util.atLeastOneMultipart(requests)> 7 | require "net/http/post/multipart" 8 | # Psst! It require an additional gem : gem install multipart-post 9 | 10 | 11 | <#list requests as req> 12 | uri = URI.parse("${util.rubyStr(req.url)}") 13 | <#if req.parametersGet??> 14 | uri.query = URI.encode_www_form(${util.rubyMap(req.parametersGet)}) 15 | 16 | http = Net::HTTP.new(uri.host, uri.port) 17 | <#if req.ssl && !settings.proxy> 18 | http.use_ssl = true 19 | <#if settings.disableSsl> 20 | http.verify_mode = OpenSSL::SSL::VERIFY_NONE 21 | 22 | 23 | 24 | <#if req.parametersMultipart??> 25 | multipartParams = {${util.rubyDictMultipart(req.parametersMultipart)}} 26 | <#if req.parametersPost??> 27 | multipartParams = multipartParams.merge(${util.rubyMap(req.parametersPost)}) 28 | 29 | 30 | request = Net::HTTP::${util.alphaOnly(req.method)?capitalize}<#if req.parametersMultipart??>::Multipart.new(uri.request_uri<#if req.parametersMultipart??>, multipartParams) 31 | <#if req.headers??> 32 | <#list req.headers?keys as h> 33 | request["${util.rubyStr(h)}"] = "${util.rubyStr(req.headers[h])}" 34 | 35 | 36 | <#if req.cookies??> 37 | request["Cookie"] = "${util.phpCookies(req.cookies)}" 38 | 39 | <#if req.parametersPost?? && !req.parametersMultipart??> 40 | request.set_form_data(${util.rubyMap(req.parametersPost)}) 41 | 42 | <#if req.postData??> 43 | request.body = "${util.rubyStr(req.postData)}" 44 | 45 | <#if req.basicAuth??> 46 | request.basic_auth("${util.rubyStr(req.basicAuth.username)}","${util.rubyStr(req.basicAuth.password)}") 47 | 48 | <#if settings.proxy> 49 | 50 | Net::HTTP::Proxy('127.0.0.1', 8080).start("${util.rubyStr(req.hostname)}"<#if req.ssl>, :use_ssl => true<#if settings.disableSsl>, :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http| 51 | 52 | response = http.request(request) 53 | 54 | puts "Status code: "+response.code 55 | puts "Response body: "+response.body 56 | <#if settings.proxy> 57 | } 58 | 59 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/templates/python_sulley.tpl: -------------------------------------------------------------------------------- 1 | from sulley import * 2 | from urllib import quote 3 | 4 | <#list requests as req> 5 | s_initialize("HTTP request to ${util.pythonStr(req.url)}") 6 | 7 | #Query string 8 | s_static("${util.pythonStr(req.method?upper_case)} ") 9 | s_string("${util.pythonStr(req.queryString)}") 10 | <#if req.parametersGet??> 11 | s_delim("?") 12 | <#list (req.parametersGet)?keys as param_name> 13 | if s_block_start("get_param_${param_name_index + 1}",encoder=quote): 14 | s_static(quote("${util.pythonStr(param_name)}")) 15 | s_delim("=") 16 | s_string("${util.pythonStr(req.parametersGet[param_name])}") 17 | s_block_end() 18 | <#if param_name_has_next> 19 | s_delim("&") 20 | 21 | 22 | 23 | s_static(" HTTP/1.1\r\n") 24 | 25 | #Headers 26 | <#if req.headers??> 27 | <#list (req.headers)?keys as header_name> 28 | s_static("${header_name}: ") 29 | s_string("${util.pythonStr(req.headers[header_name])}") 30 | s_static("\r\n") 31 | 32 | 33 | <#if req.cookies??> 34 | s_static("Cookie: ") 35 | <#list (req.cookies)?keys as cookie_name> 36 | s_static("${util.pythonStr(cookie_name)}") 37 | s_delim("=") 38 | s_string("${util.pythonStr(req.cookies[cookie_name])}") 39 | <#if cookie_name_has_next> 40 | s_delim("; ") 41 | 42 | 43 | 44 | <#if req.postData?? || req.parametersPost??> 45 | s_static("Content-Length: ") 46 | s_size("post_data", format="ascii", signed=True, fuzzable=True) 47 | s_static("\r\n") 48 | <#else> 49 | s_static("Content-Length: 0\r\n") 50 | 51 | 52 | s_static("\r\n") 53 | <#if req.postData?? || req.parametersPost??> 54 | 55 | #Post data 56 | if s_block_start("post_data"): 57 | <#if req.postData??> 58 | s_string("${util.pythonStr(req.postData)}") 59 | 60 | <#if req.parametersPost??> 61 | <#list (req.parametersPost)?keys as param_name> 62 | if s_block_start("post_param_${param_name_index + 1}",encoder=quote): 63 | s_static(quote("${util.pythonStr(param_name)}")) 64 | s_delim("=") 65 | s_string("${util.pythonStr(req.parametersPost[param_name])}") 66 | s_block_end() 67 | <#if param_name_has_next> 68 | s_delim("&") 69 | 70 | 71 | 72 | s_block_end() 73 | 74 | 75 | -------------------------------------------------------------------------------- /scriptgen-core/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | com.h3xstream.scriptgen 7 | scriptgen-root-pom 8 | 6.1.0 9 | 10 | 11 | 4.0.0 12 | 13 | scriptgen-core 14 | 15 | jar 16 | 17 | 18 | This project contains the rules that identify code signatures. 19 | 20 | 21 | 22 | 23 | 24 | com.fifesoft 25 | rsyntaxtextarea 26 | 27 | 28 | 29 | javax.xml.bind 30 | jaxb-api 31 | 32 | 33 | 34 | org.freemarker 35 | freemarker 36 | 37 | 38 | 39 | com.miglayout 40 | miglayout-swing 41 | 42 | 43 | 44 | 45 | commons-fileupload 46 | commons-fileupload 47 | 48 | 49 | 50 | com.esotericsoftware 51 | minlog 52 | 53 | 54 | 55 | org.easytesting 56 | fest-swing 57 | test 58 | 59 | 60 | 61 | org.testng 62 | testng 63 | test 64 | 65 | 66 | 67 | 68 | org.mockito 69 | mockito-all 70 | test 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/ISessionHandlingAction.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)ISessionHandlingAction.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * Extensions can implement this interface and then call 14 | * IBurpExtenderCallbacks.registerSessionHandlingAction() to 15 | * register a custom session handling action. Each registered action will be 16 | * available within the session handling rule UI for the user to select as a 17 | * rule action. Users can choose to invoke an action directly in its own right, 18 | * or following execution of a macro. 19 | */ 20 | public interface ISessionHandlingAction 21 | { 22 | /** 23 | * This method is used by Burp to obtain the name of the session handling 24 | * action. This will be displayed as an option within the session handling 25 | * rule editor when the user selects to execute an extension-provided 26 | * action. 27 | * 28 | * @return The name of the action. 29 | */ 30 | String getActionName(); 31 | 32 | /** 33 | * This method is invoked when the session handling action should be 34 | * executed. This may happen as an action in its own right, or as a 35 | * sub-action following execution of a macro. 36 | * 37 | * @param currentRequest The base request that is currently being processed. 38 | * The action can query this object to obtain details about the base 39 | * request. It can issue additional requests of its own if necessary, and 40 | * can use the setter methods on this object to update the base request. 41 | * @param macroItems If the action is invoked following execution of a 42 | * macro, this parameter contains the result of executing the macro. 43 | * Otherwise, it is 44 | * null. Actions can use the details of the macro items to 45 | * perform custom analysis of the macro to derive values of non-standard 46 | * session handling tokens, etc. 47 | */ 48 | void performAction( 49 | IHttpRequestResponse currentRequest, 50 | IHttpRequestResponse[] macroItems); 51 | } 52 | -------------------------------------------------------------------------------- /scriptgen-burp-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | com.h3xstream.scriptgen 7 | scriptgen-root-pom 8 | 6.1.0 9 | 10 | 11 | 4.0.0 12 | 13 | scriptgen-burp-plugin 14 | 15 | Reissue Request Scripter (Burp Proxy Plugin) 16 | 17 | jar 18 | 19 | 20 | 21 | 22 | 23 | maven-assembly-plugin 24 | 2.3 25 | 26 | 27 | jar-with-dependencies 28 | package 29 | 30 | single 31 | 32 | 33 | 34 | jar-with-dependencies 35 | 36 | scriptgen-burp-plugin-6 37 | false 38 | 39 | false 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | com.h3xstream.scriptgen 53 | scriptgen-core 54 | 55 | 56 | 57 | com.h3xstream.scriptgen 58 | burp-api 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /scriptgen-core/src/test/java/com/h3xstream/scriptgen/HttpRequestInfoFixtures.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen; 2 | 3 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 4 | import com.h3xstream.scriptgen.model.MultiPartParameter; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public class HttpRequestInfoFixtures { 12 | 13 | static Map getParams = new HashMap(); 14 | static { 15 | getParams.put("id", "12345"); 16 | getParams.put("hash", "3012451c92c89ed9b48dcdc817d6a527"); 17 | } 18 | static Map postParams = new HashMap(); 19 | static { 20 | postParams.put("username", "admin"); 21 | postParams.put("password", "admin'--**\n\\"); 22 | postParams.put("bug18[test]", "abcdef"); //Use to test fallback with Python Requests 23 | } 24 | static List multipartParams = new ArrayList(); 25 | static { 26 | multipartParams.add(new MultiPartParameter("file1", "This is a test!","text/plain","test.txt")); 27 | multipartParams.add(new MultiPartParameter("file2", "PNG1234567890","image/png","test.png")); 28 | } 29 | static Map headers = new HashMap(); 30 | static { 31 | headers.put("Cookie", "SID=Aualz4Rx0_8t3GJda; LANG=en-US"); 32 | headers.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"); 33 | headers.put("Accept", "*/*"); 34 | } 35 | 36 | public static HttpRequestInfo getGetRequest() { 37 | return new HttpRequestInfo("GET", "https://httpbin.org/get?a=b", getParams, null, null, headers, null); 38 | } 39 | 40 | public static HttpRequestInfo getPostRequest() { 41 | return new HttpRequestInfo("POST", "http://httpbin.org/post?a=1", getParams, postParams, null, headers, null); 42 | } 43 | 44 | public static HttpRequestInfo getPostMultiPartRequest() { 45 | return new HttpRequestInfo("POST", "http://httpbin.org/post?test=1", getParams, null, null, headers, multipartParams); 46 | } 47 | 48 | public static HttpRequestInfo getBrokenRequest() { 49 | return new HttpRequestInfo("SPECIAL\"')(\\", "http://httpbin.org/brokentest=1${php}#{ruby}\"')(aaaaaaaa\\", getParams, null, null, headers, multipartParams); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/gui/SettingsPanel.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.gui; 2 | 3 | import com.esotericsoftware.minlog.Log; 4 | import com.h3xstream.scriptgen.model.DisplaySettings; 5 | 6 | import javax.swing.*; 7 | import java.awt.*; 8 | import java.awt.event.ItemEvent; 9 | import java.awt.event.ItemListener; 10 | 11 | public class SettingsPanel extends JPanel { 12 | 13 | private JCheckBox chkProxy; 14 | private JCheckBox chkMinimalHeaders; 15 | private JCheckBox chkDisableSsl; 16 | private GeneratorController controller; 17 | private GeneratorFrame parent; 18 | 19 | public SettingsPanel(GeneratorFrame parent) { 20 | this.parent = parent; 21 | 22 | setLayout(new FlowLayout()); 23 | 24 | UpdateCode updateCodeListener = new UpdateCode(); 25 | 26 | chkProxy = new JCheckBox("Proxy redirection"); 27 | chkProxy.setToolTipText("The requests will be redirected to Burp proxy"); 28 | chkProxy.addItemListener(updateCodeListener); 29 | add(chkProxy); 30 | 31 | chkMinimalHeaders = new JCheckBox("Minimal headers"); 32 | chkMinimalHeaders.setToolTipText("Potentially optional headers will be removed"); 33 | chkMinimalHeaders.addItemListener(updateCodeListener); 34 | add(chkMinimalHeaders); 35 | 36 | chkDisableSsl = new JCheckBox("Disable SSL/TLS verification"); 37 | chkDisableSsl.setToolTipText("The validation of the TLS certificate will be skipped."); 38 | chkDisableSsl.addItemListener(updateCodeListener); 39 | add(chkDisableSsl); 40 | 41 | } 42 | 43 | public void setController(GeneratorController controller) { 44 | this.controller = controller; 45 | } 46 | 47 | public DisplaySettings getDisplaySettings() { 48 | DisplaySettings settings = new DisplaySettings(); 49 | settings.setProxy(chkProxy.isSelected()); 50 | settings.setMinimalHeaders(chkMinimalHeaders.isSelected()); 51 | settings.setDisableSsl(chkDisableSsl.isSelected()); 52 | return settings; 53 | } 54 | 55 | 56 | 57 | private class UpdateCode implements ItemListener { 58 | 59 | @Override 60 | public void itemStateChanged(ItemEvent e) { 61 | try { 62 | controller.updateDisplaySettings(parent, getDisplaySettings()); 63 | } catch (Exception ex) { 64 | Log.error("Error occurs while updating the code: "+ex.getMessage()); 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IResponseInfo.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IResponseInfo.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | import java.util.List; 13 | 14 | /** 15 | * This interface is used to retrieve key details about an HTTP response. 16 | * Extensions can obtain an 17 | * IResponseInfo object for a given response by calling 18 | * IExtensionHelpers.analyzeResponse(). 19 | */ 20 | public interface IResponseInfo 21 | { 22 | /** 23 | * This method is used to obtain the HTTP headers contained in the response. 24 | * 25 | * @return The HTTP headers contained in the response. 26 | */ 27 | List getHeaders(); 28 | 29 | /** 30 | * This method is used to obtain the offset within the response where the 31 | * message body begins. 32 | * 33 | * @return The offset within the response where the message body begins. 34 | */ 35 | int getBodyOffset(); 36 | 37 | /** 38 | * This method is used to obtain the HTTP status code contained in the 39 | * response. 40 | * 41 | * @return The HTTP status code contained in the response. 42 | */ 43 | short getStatusCode(); 44 | 45 | /** 46 | * This method is used to obtain details of the HTTP cookies set in the 47 | * response. 48 | * 49 | * @return A list of ICookie objects representing the cookies 50 | * set in the response, if any. 51 | */ 52 | List getCookies(); 53 | 54 | /** 55 | * This method is used to obtain the MIME type of the response, as stated in 56 | * the HTTP headers. 57 | * 58 | * @return A textual label for the stated MIME type, or an empty String if 59 | * this is not known or recognized. The possible labels are the same as 60 | * those used in the main Burp UI. 61 | */ 62 | String getStatedMimeType(); 63 | 64 | /** 65 | * This method is used to obtain the MIME type of the response, as inferred 66 | * from the contents of the HTTP message body. 67 | * 68 | * @return A textual label for the inferred MIME type, or an empty String if 69 | * this is not known or recognized. The possible labels are the same as 70 | * those used in the main Burp UI. 71 | */ 72 | String getInferredMimeType(); 73 | } 74 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/gui/GeneratorController.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.gui; 2 | 3 | import com.esotericsoftware.minlog.Log; 4 | import com.h3xstream.scriptgen.model.DisplaySettings; 5 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 6 | import com.h3xstream.scriptgen.LanguageOption; 7 | import com.h3xstream.scriptgen.template.CodeTemplateBuilder; 8 | 9 | import java.awt.*; 10 | import java.awt.datatransfer.Clipboard; 11 | import java.awt.datatransfer.StringSelection; 12 | import java.util.List; 13 | 14 | 15 | public class GeneratorController { 16 | 17 | 18 | List requests; 19 | 20 | LanguageOption latestLanguage; 21 | DisplaySettings latestDisplaySettings = new DisplaySettings(); 22 | 23 | public void setHttpRequest(List requests) { 24 | this.requests = requests; 25 | } 26 | 27 | 28 | public void updateLanguage(GeneratorFrame frame, LanguageOption newLanguage) throws Exception { 29 | latestLanguage = newLanguage; 30 | 31 | Log.debug("Updating the language to "+newLanguage.getLanguage()); 32 | 33 | String codeGenerated = new CodeTemplateBuilder().request(requests) 34 | .templatePath(newLanguage.getTemplate()) 35 | .displaySettings(latestDisplaySettings).build(); 36 | 37 | frame.updateCode(codeGenerated, newLanguage.getSyntax()); 38 | } 39 | 40 | public void updateDisplaySettings(GeneratorFrame frame, DisplaySettings newDisplay) throws Exception { 41 | latestDisplaySettings = newDisplay; 42 | 43 | Log.debug("Updating the settings to "+newDisplay.toString()); 44 | 45 | String codeGenerated = new CodeTemplateBuilder().request(requests) 46 | .templatePath(latestLanguage.getTemplate()) 47 | .displaySettings(newDisplay).build(); 48 | 49 | frame.updateCode(codeGenerated, latestLanguage.getSyntax()); 50 | } 51 | 52 | public void copyToClipboard(String code) { 53 | Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard (); 54 | clip.setContents(new StringSelection(code), null); 55 | } 56 | 57 | public void saveScriptToFile(String code, final LanguageOption lang,Component parent) { 58 | new ScriptFileChooser().saveScriptToFile(code,lang,parent,requests,this); 59 | } 60 | 61 | public void fileSaveSuccess(String fileName) { 62 | Log.info(String.format("Script '%s' saved with success!\n", fileName)); 63 | } 64 | 65 | public void fileSaveError(String fileName) { 66 | Log.info(String.format("Unable to save '%s'\n", fileName)); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/template/HttpRequestUtil.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen.template; 2 | 3 | import com.esotericsoftware.minlog.Log; 4 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Arrays; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | public class HttpRequestUtil { 13 | 14 | /** 15 | * The plugin is intended to generated exact representation of the request captured. Sometime, the code generated 16 | * is fill with optional headers that are probably added by the HTTP library. Removing the following header can 17 | * make a the code slightly cleaner. 18 | * Ref: http://en.wikipedia.org/wiki/List_of_HTTP_header_fields 19 | */ 20 | private static final List COMMON_HEADERS = Arrays.asList("accept-language", "accept-encoding", 21 | "cache-control", "connection", "if-match", "if-modified-since", "if-none-match", "if-range", 22 | "if-unmodified-since", "proxy-connection", "referer", "user-agent", "via"); 23 | 24 | /** 25 | * Hide optional headers 26 | * @param requests 27 | * @return 28 | */ 29 | public static List withMinimalHeaders(List requests) { 30 | List transformRequests = new ArrayList<>(); 31 | for(HttpRequestInfo req : requests) { 32 | Map newHeaders = hideCommonHeaders(req.getHeaders()); 33 | try { 34 | HttpRequestInfo cloneReq = req.clone(); 35 | cloneReq.setHeaders(hideCommonHeaders(req.getHeaders())); 36 | transformRequests.add(cloneReq); 37 | } catch (CloneNotSupportedException e) { 38 | Log.error("Error during the clone operation : "+e.getMessage()); 39 | throw new RuntimeException(e); 40 | } 41 | } 42 | return transformRequests; 43 | } 44 | 45 | private static Map hideCommonHeaders(Map origHeaders) { 46 | Map selectedHeaders = new HashMap(); 47 | for(Map.Entry entry : origHeaders.entrySet()) { 48 | String headerName = entry.getKey().toLowerCase(); 49 | 50 | if("accept".equals(headerName) && entry.getValue().contains("*")) { 51 | continue; //Remove Accept header unless targeting a specific content-type "application/json", "application/xml", ... 52 | } 53 | if(!COMMON_HEADERS.contains(headerName)) { 54 | selectedHeaders.put(entry.getKey(), entry.getValue()); 55 | } 56 | 57 | } 58 | return selectedHeaders.size() == 0 ? null : selectedHeaders; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IScanQueueItem.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IScanQueueItem.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * This interface is used to retrieve details of items in the Burp Scanner 14 | * active scan queue. Extensions can obtain references to scan queue items by 15 | * calling 16 | * IBurpExtenderCallbacks.doActiveScan(). 17 | */ 18 | public interface IScanQueueItem 19 | { 20 | /** 21 | * This method returns a description of the status of the scan queue item. 22 | * 23 | * @return A description of the status of the scan queue item. 24 | */ 25 | String getStatus(); 26 | 27 | /** 28 | * This method returns an indication of the percentage completed for the 29 | * scan queue item. 30 | * 31 | * @return An indication of the percentage completed for the scan queue 32 | * item. 33 | */ 34 | byte getPercentageComplete(); 35 | 36 | /** 37 | * This method returns the number of requests that have been made for the 38 | * scan queue item. 39 | * 40 | * @return The number of requests that have been made for the scan queue 41 | * item. 42 | */ 43 | int getNumRequests(); 44 | 45 | /** 46 | * This method returns the number of network errors that have occurred for 47 | * the scan queue item. 48 | * 49 | * @return The number of network errors that have occurred for the scan 50 | * queue item. 51 | */ 52 | int getNumErrors(); 53 | 54 | /** 55 | * This method returns the number of attack insertion points being used for 56 | * the scan queue item. 57 | * 58 | * @return The number of attack insertion points being used for the scan 59 | * queue item. 60 | */ 61 | int getNumInsertionPoints(); 62 | 63 | /** 64 | * This method allows the scan queue item to be canceled. 65 | */ 66 | void cancel(); 67 | 68 | /** 69 | * This method returns details of the issues generated for the scan queue 70 | * item. Note: different items within the scan queue may contain 71 | * duplicated versions of the same issues - for example, if the same request 72 | * has been scanned multiple times. Duplicated issues are consolidated in 73 | * the main view of scan results. Extensions can register an 74 | * IScannerListener to get details only of unique, newly 75 | * discovered Scanner issues post-consolidation. 76 | * 77 | * @return Details of the issues generated for the scan queue item. 78 | */ 79 | IScanIssue[] getIssues(); 80 | } 81 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IRequestInfo.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IRequestInfo.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | import java.net.URL; 13 | import java.util.List; 14 | 15 | /** 16 | * This interface is used to retrieve key details about an HTTP request. 17 | * Extensions can obtain an 18 | * IRequestInfo object for a given request by calling 19 | * IExtensionHelpers.analyzeRequest(). 20 | */ 21 | public interface IRequestInfo 22 | { 23 | /** 24 | * Used to indicate that there is no content. 25 | */ 26 | static final byte CONTENT_TYPE_NONE = 0; 27 | /** 28 | * Used to indicate URL-encoded content. 29 | */ 30 | static final byte CONTENT_TYPE_URL_ENCODED = 1; 31 | /** 32 | * Used to indicate multi-part content. 33 | */ 34 | static final byte CONTENT_TYPE_MULTIPART = 2; 35 | /** 36 | * Used to indicate XML content. 37 | */ 38 | static final byte CONTENT_TYPE_XML = 3; 39 | /** 40 | * Used to indicate JSON content. 41 | */ 42 | static final byte CONTENT_TYPE_JSON = 4; 43 | /** 44 | * Used to indicate AMF content. 45 | */ 46 | static final byte CONTENT_TYPE_AMF = 5; 47 | /** 48 | * Used to indicate unknown content. 49 | */ 50 | static final byte CONTENT_TYPE_UNKNOWN = -1; 51 | 52 | /** 53 | * This method is used to obtain the HTTP method used in the request. 54 | * 55 | * @return The HTTP method used in the request. 56 | */ 57 | String getMethod(); 58 | 59 | /** 60 | * This method is used to obtain the URL in the request. 61 | * 62 | * @return The URL in the request. 63 | */ 64 | URL getUrl(); 65 | 66 | /** 67 | * This method is used to obtain the HTTP headers contained in the request. 68 | * 69 | * @return The HTTP headers contained in the request. 70 | */ 71 | List getHeaders(); 72 | 73 | /** 74 | * This method is used to obtain the parameters contained in the request. 75 | * 76 | * @return The parameters contained in the request. 77 | */ 78 | List getParameters(); 79 | 80 | /** 81 | * This method is used to obtain the offset within the request where the 82 | * message body begins. 83 | * 84 | * @return The offset within the request where the message body begins. 85 | */ 86 | int getBodyOffset(); 87 | 88 | /** 89 | * This method is used to obtain the content type of the message body. 90 | * 91 | * @return An indication of the content type of the message body. Available 92 | * types are defined within this interface. 93 | */ 94 | byte getContentType(); 95 | } 96 | -------------------------------------------------------------------------------- /scriptgen-zap-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | com.h3xstream.scriptgen 7 | scriptgen-root-pom 8 | 6.1.0 9 | 10 | 11 | 4.0.0 12 | 13 | scriptgen-zap-plugin 14 | 15 | Reissue Request Scripter (Zed Attack Proxy Plugin) 16 | 17 | jar 18 | 19 | 20 | 21 | 22 | 23 | 24 | maven-assembly-plugin 25 | 2.3 26 | 27 | 28 | jar-with-dependencies 29 | package 30 | 31 | single 32 | 33 | 34 | 35 | jar-with-dependencies 36 | 37 | scriptgen-alpha-6 38 | false 39 | 40 | false 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | com.h3xstream.scriptgen 55 | scriptgen-core 56 | 57 | 58 | 59 | commons-httpclient 60 | commons-httpclient 61 | provided 62 | 63 | 64 | org.zaproxy 65 | zap 66 | 67 | 68 | org.apache.logging.log4j 69 | log4j-core 70 | 2.16.0 71 | provided 72 | 73 | 74 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/ITextEditor.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)ITextEditor.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | import java.awt.Component; 13 | 14 | /** 15 | * This interface is used to provide extensions with an instance of Burp's raw 16 | * text editor, for the extension to use in its own UI. Extensions should call 17 | * IBurpExtenderCallbacks.createTextEditor() to obtain an instance 18 | * of this interface. 19 | */ 20 | public interface ITextEditor 21 | { 22 | /** 23 | * This method returns the UI component of the editor, for extensions to add 24 | * to their own UI. 25 | * 26 | * @return The UI component of the editor. 27 | */ 28 | Component getComponent(); 29 | 30 | /** 31 | * This method is used to control whether the editor is currently editable. 32 | * This status can be toggled on and off as required. 33 | * 34 | * @param editable Indicates whether the editor should be currently 35 | * editable. 36 | */ 37 | void setEditable(boolean editable); 38 | 39 | /** 40 | * This method is used to update the currently displayed text in the editor. 41 | * 42 | * @param text The text to be displayed. 43 | */ 44 | void setText(byte[] text); 45 | 46 | /** 47 | * This method is used to retrieve the currently displayed text. 48 | * 49 | * @return The currently displayed text. 50 | */ 51 | byte[] getText(); 52 | 53 | /** 54 | * This method is used to determine whether the user has modified the 55 | * contents of the editor. 56 | * 57 | * @return An indication of whether the user has modified the contents of 58 | * the editor since the last call to 59 | * setText(). 60 | */ 61 | boolean isTextModified(); 62 | 63 | /** 64 | * This method is used to obtain the currently selected text. 65 | * 66 | * @return The currently selected text, or 67 | * null if the user has not made any selection. 68 | */ 69 | byte[] getSelectedText(); 70 | 71 | /** 72 | * This method can be used to retrieve the bounds of the user's selection 73 | * into the displayed text, if applicable. 74 | * 75 | * @return An int[2] array containing the start and end offsets of the 76 | * user's selection within the displayed text. If the user has not made any 77 | * selection in the current message, both offsets indicate the position of 78 | * the caret within the editor. 79 | */ 80 | int[] getSelectionBounds(); 81 | 82 | /** 83 | * This method is used to update the search expression that is shown in the 84 | * search bar below the editor. The editor will automatically highlight any 85 | * regions of the displayed text that match the search expression. 86 | * 87 | * @param expression The search expression. 88 | */ 89 | void setSearchExpression(String expression); 90 | } 91 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/java/com/h3xstream/scriptgen/LanguageOption.java: -------------------------------------------------------------------------------- 1 | package com.h3xstream.scriptgen; 2 | 3 | import org.fife.ui.rsyntaxtextarea.SyntaxConstants; 4 | 5 | /** 6 | * This class can be seen as an Enum. It contains all the languages supported. 7 | */ 8 | public class LanguageOption { 9 | 10 | private static final String BASE_TPL_CLASSPATH = "com/h3xstream/scriptgen/templates/"; 11 | 12 | //List of script templates available 13 | public static final LanguageOption PYTHON_REQUEST = new LanguageOption("Python (Requests)", "python", BASE_TPL_CLASSPATH + "python_requests.tpl", SyntaxConstants.SYNTAX_STYLE_PYTHON, "py"); 14 | public static final LanguageOption RUBY_NET_HTTP = new LanguageOption("Ruby (Net::HTTP)", "ruby", BASE_TPL_CLASSPATH + "ruby_nethttp.tpl", SyntaxConstants.SYNTAX_STYLE_RUBY , "rb"); 15 | public static final LanguageOption PERL_LWP = new LanguageOption("Perl (LWP)", "perl", BASE_TPL_CLASSPATH + "perl_lwp.tpl", SyntaxConstants.SYNTAX_STYLE_PERL, "pl"); 16 | public static final LanguageOption PHP_CURL = new LanguageOption("PHP (cURL)", "php", BASE_TPL_CLASSPATH + "php_curl.tpl", SyntaxConstants.SYNTAX_STYLE_PHP, "php"); 17 | public static final LanguageOption POWERSHELL = new LanguageOption("PowerShell (WebRequest)", "powershell", BASE_TPL_CLASSPATH + "psh_webrequest.tpl", SyntaxConstants.SYNTAX_STYLE_UNIX_SHELL, "ps1"); 18 | public static final LanguageOption PYTHON_SULLEY = new LanguageOption("Python (Sulley) - Experimental", "sulley", BASE_TPL_CLASSPATH + "python_sulley.tpl", SyntaxConstants.SYNTAX_STYLE_PYTHON, "py"); 19 | public static final LanguageOption JAVASCRIPT_XHR = new LanguageOption("Javascript (XMLHttpRequest)", "javascript", BASE_TPL_CLASSPATH + "javascript_xhr.tpl", SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, "js"); 20 | public static final LanguageOption JAVASCRIPT_JQUERY = new LanguageOption("Javascript (JQuery)", "javascript", BASE_TPL_CLASSPATH + "javascript_jquery.tpl", SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, "js"); 21 | public static final LanguageOption HTML_FORM = new LanguageOption("HTML form", "html", BASE_TPL_CLASSPATH + "html_form.tpl", SyntaxConstants.SYNTAX_STYLE_HTML, "html"); 22 | 23 | public static final LanguageOption[] values = {PYTHON_REQUEST, RUBY_NET_HTTP, PERL_LWP, PHP_CURL, POWERSHELL, 24 | PYTHON_SULLEY, JAVASCRIPT_XHR, JAVASCRIPT_JQUERY, HTML_FORM}; 25 | 26 | //Properties of each language 27 | private final String title; 28 | private final String language; 29 | private final String template; 30 | private final String syntax; 31 | private final String extension; 32 | 33 | private LanguageOption(String title, String language, String template, String syntax,String extension) { 34 | this.title = title; 35 | this.language = language; 36 | this.template = template; 37 | this.syntax = syntax; 38 | this.extension = extension; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return title; 44 | } 45 | 46 | public String getTitle() { 47 | return title; 48 | } 49 | 50 | public String getLanguage() { 51 | return language; 52 | } 53 | 54 | public String getTemplate() { 55 | return template; 56 | } 57 | 58 | public String getSyntax() { 59 | return syntax; 60 | } 61 | 62 | 63 | public String getExtension() { 64 | return extension; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IHttpRequestResponse.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IHttpRequestResponse.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * This interface is used to retrieve and update details about HTTP messages. 14 | * 15 | * Note: The setter methods generally can only be used before the message 16 | * has been processed, and not in read-only contexts. The getter methods 17 | * relating to response details can only be used after the request has been 18 | * issued. 19 | */ 20 | public interface IHttpRequestResponse 21 | { 22 | /** 23 | * This method is used to retrieve the request message. 24 | * 25 | * @return The request message. 26 | */ 27 | byte[] getRequest(); 28 | 29 | /** 30 | * This method is used to update the request message. 31 | * 32 | * @param message The new request message. 33 | */ 34 | void setRequest(byte[] message); 35 | 36 | /** 37 | * This method is used to retrieve the response message. 38 | * 39 | * @return The response message. 40 | */ 41 | byte[] getResponse(); 42 | 43 | /** 44 | * This method is used to update the response message. 45 | * 46 | * @param message The new response message. 47 | */ 48 | void setResponse(byte[] message); 49 | 50 | /** 51 | * This method is used to retrieve the user-annotated comment for this item, 52 | * if applicable. 53 | * 54 | * @return The user-annotated comment for this item, or null if none is set. 55 | */ 56 | String getComment(); 57 | 58 | /** 59 | * This method is used to update the user-annotated comment for this item. 60 | * 61 | * @param comment The comment to be assigned to this item. 62 | */ 63 | void setComment(String comment); 64 | 65 | /** 66 | * This method is used to retrieve the user-annotated highlight for this 67 | * item, if applicable. 68 | * 69 | * @return The user-annotated highlight for this item, or null if none is 70 | * set. 71 | */ 72 | String getHighlight(); 73 | 74 | /** 75 | * This method is used to update the user-annotated highlight for this item. 76 | * 77 | * @param color The highlight color to be assigned to this item. Accepted 78 | * values are: red, orange, yellow, green, cyan, blue, pink, magenta, gray, 79 | * or a null String to clear any existing highlight. 80 | */ 81 | void setHighlight(String color); 82 | 83 | /** 84 | * This method is used to retrieve the HTTP service for this request / 85 | * response. 86 | * 87 | * @return An 88 | * IHttpService object containing details of the HTTP service. 89 | */ 90 | IHttpService getHttpService(); 91 | 92 | /** 93 | * This method is used to update the HTTP service for this request / 94 | * response. 95 | * 96 | * @param httpService An 97 | * IHttpService object containing details of the new HTTP 98 | * service. 99 | */ 100 | void setHttpService(IHttpService httpService); 101 | 102 | } 103 | -------------------------------------------------------------------------------- /scriptgen-burp-plugin/src/main/java/burp/BurpExtender.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | 4 | import com.esotericsoftware.minlog.Log; 5 | import com.h3xstream.scriptgen.ReissueRequestScripterConstants; 6 | import com.h3xstream.scriptgen.model.HttpRequestInfo; 7 | import com.h3xstream.scriptgen.ReissueRequestScripter; 8 | 9 | import javax.swing.*; 10 | import java.awt.event.ActionEvent; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | import java.util.ArrayList; 14 | import java.util.Arrays; 15 | import java.util.List; 16 | 17 | public class BurpExtender implements IBurpExtender, IContextMenuFactory { 18 | 19 | private IExtensionHelpers helpers; 20 | 21 | 22 | @Override 23 | public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks) { 24 | this.helpers = callbacks.getHelpers(); 25 | 26 | PrintWriter stdout = new PrintWriter(callbacks.getStdout(), true); 27 | stdout.println("== Reissue Request Scripter plugin =="); 28 | stdout.println("Plugin that generate script to reproduce a specific HTTP request."); 29 | stdout.println(" - Github : https://github.com/h3xstream/http-script-generator"); 30 | stdout.println(""); 31 | stdout.println("== License =="); 32 | stdout.println("Reissue Request Scripter Burp plugin is release under LGPL."); 33 | stdout.println(""); 34 | 35 | Log.setLogger(new Log.Logger() { 36 | @Override 37 | protected void print(String message) { 38 | try { 39 | if (message.contains("ERROR:")) { //Not the most elegant way, but should be effective. 40 | callbacks.issueAlert(message); 41 | } 42 | callbacks.getStdout().write(message.getBytes()); 43 | callbacks.getStdout().write('\n'); 44 | } catch (IOException e) { 45 | System.err.println("Error while printing the log : " + e.getMessage()); //Very unlikely 46 | } 47 | } 48 | }); 49 | Log.DEBUG(); 50 | 51 | //Register context menu 52 | callbacks.registerContextMenuFactory(this); 53 | 54 | callbacks.setExtensionName(ReissueRequestScripterConstants.PLUGIN_NAME); 55 | } 56 | 57 | 58 | @Override 59 | public List createMenuItems(IContextMenuInvocation invocation) { 60 | IHttpRequestResponse[] responsesSelected = invocation.getSelectedMessages(); 61 | 62 | return Arrays.asList(new JMenuItem(new GenerateScriptAction(responsesSelected))); 63 | } 64 | 65 | private class GenerateScriptAction extends AbstractAction { 66 | private IHttpRequestResponse[] requestSelected; 67 | 68 | public GenerateScriptAction(IHttpRequestResponse[] requestSelected) { 69 | super("Generate Script"); 70 | this.requestSelected = requestSelected; 71 | } 72 | 73 | @Override 74 | public void actionPerformed(ActionEvent e) { 75 | 76 | try { 77 | List req = BurpHttpRequestMapper.buildListRequestInfo(requestSelected, helpers); 78 | new ReissueRequestScripter(req).openDialogWindow(); 79 | } 80 | catch (Exception ex) { 81 | Log.error("Unexpected error while building the request entity. "+ex.getMessage()); 82 | ex.printStackTrace(); 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /burp-api/src/main/java/burp/IParameter.java: -------------------------------------------------------------------------------- 1 | package burp; 2 | 3 | /* 4 | * @(#)IParameter.java 5 | * 6 | * Copyright PortSwigger Ltd. All rights reserved. 7 | * 8 | * This code may be used to extend the functionality of Burp Suite Free Edition 9 | * and Burp Suite Professional, provided that this usage does not violate the 10 | * license terms for those products. 11 | */ 12 | /** 13 | * This interface is used to hold details about an HTTP request parameter. 14 | */ 15 | public interface IParameter 16 | { 17 | /** 18 | * Used to indicate a parameter within the URL query string. 19 | */ 20 | static final byte PARAM_URL = 0; 21 | /** 22 | * Used to indicate a parameter within the message body. 23 | */ 24 | static final byte PARAM_BODY = 1; 25 | /** 26 | * Used to indicate an HTTP cookie. 27 | */ 28 | static final byte PARAM_COOKIE = 2; 29 | /** 30 | * Used to indicate an item of data within an XML structure. 31 | */ 32 | static final byte PARAM_XML = 3; 33 | /** 34 | * Used to indicate the value of a tag attribute within an XML structure. 35 | */ 36 | static final byte PARAM_XML_ATTR = 4; 37 | /** 38 | * Used to indicate the value of a parameter attribute within a multi-part 39 | * message body (such as the name of an uploaded file). 40 | */ 41 | static final byte PARAM_MULTIPART_ATTR = 5; 42 | /** 43 | * Used to indicate an item of data within a JSON structure. 44 | */ 45 | static final byte PARAM_JSON = 6; 46 | 47 | /** 48 | * This method is used to retrieve the parameter type. 49 | * 50 | * @return The parameter type. The available types are defined within this 51 | * interface. 52 | */ 53 | byte getType(); 54 | 55 | /** 56 | * This method is used to retrieve the parameter name. 57 | * 58 | * @return The parameter name. 59 | */ 60 | String getName(); 61 | 62 | /** 63 | * This method is used to retrieve the parameter value. 64 | * 65 | * @return The parameter value. 66 | */ 67 | String getValue(); 68 | 69 | /** 70 | * This method is used to retrieve the start offset of the parameter name 71 | * within the HTTP request. 72 | * 73 | * @return The start offset of the parameter name within the HTTP request, 74 | * or -1 if the parameter is not associated with a specific request. 75 | */ 76 | int getNameStart(); 77 | 78 | /** 79 | * This method is used to retrieve the end offset of the parameter name 80 | * within the HTTP request. 81 | * 82 | * @return The end offset of the parameter name within the HTTP request, or 83 | * -1 if the parameter is not associated with a specific request. 84 | */ 85 | int getNameEnd(); 86 | 87 | /** 88 | * This method is used to retrieve the start offset of the parameter value 89 | * within the HTTP request. 90 | * 91 | * @return The start offset of the parameter value within the HTTP request, 92 | * or -1 if the parameter is not associated with a specific request. 93 | */ 94 | int getValueStart(); 95 | 96 | /** 97 | * This method is used to retrieve the end offset of the parameter value 98 | * within the HTTP request. 99 | * 100 | * @return The end offset of the parameter value within the HTTP request, or 101 | * -1 if the parameter is not associated with a specific request. 102 | */ 103 | int getValueEnd(); 104 | } 105 | -------------------------------------------------------------------------------- /scriptgen-core/src/main/resources/com/h3xstream/scriptgen/themes/dark.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |