Skip to content

Commit 412abd7

Browse files
authored
Merge pull request #139 from usdAG/develop
Release v1.3.1
2 parents 7814f76 + ccdd76d commit 412abd7

File tree

171 files changed

+6106
-1478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+6106
-1478
lines changed

.github/workflows/develop.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323

2424
- uses: actions/checkout@v2
2525

26-
- name: Set up JDK 1.8
26+
- name: Set up JDK 17
2727
uses: actions/setup-java@v1
2828
with:
29-
java-version: 1.8
29+
java-version: 17
3030

3131
- name: Cache local Maven repository
3232
uses: actions/cache@v2

.github/workflows/master.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323

2424
- uses: actions/checkout@v2
2525

26-
- name: Set up JDK 1.8
26+
- name: Set up JDK 17
2727
uses: actions/setup-java@v1
2828
with:
29-
java-version: 1.8
29+
java-version: 17
3030

3131
- name: Cache local Maven repository
3232
uses: actions/cache@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ buildNumber.properties
1111
.classpath
1212
.project
1313
.settings/
14+
*/launch.json

INTRODUCTION.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# CSTC Introduction
2+
This document serves as a written introduction to the Cyber Security Transformation Chef or in short: CSTC. It starts by giving an overview of the general UI of the tool and after that walking through a demonstrative use-case explaining the core functionalities along the way.
3+
4+
## UI Overview
5+
6+
### Main Panel
7+
8+
<img src="media/introduction/fig01-overview.png" width="75%" height="75%">
9+
10+
The UI can be divided into three functional areas.<br>
11+
On the far left **(1)** is the area for selecting operations, grouped categorically. These are added to the recipe in the appropriate lane via click-and-drag. There is a search bar above the operations tree for quick access.<br>
12+
The recipe panel is located in the middle **(2)**. This is made up of up to 10 lanes, whereby the operations are applied in the order from top to bottom and left to right. Each lane works anew on the input sent to the CSTC. This makes it possible to carry out several transformations on the same input.<br>
13+
Finally, the selection area on the right **(3)** provides an overview of the initial development of a recipe and is used for debugging a recipe. The input to be worked with is shown in the upper area, and the lower area shows the result after the recipe has been applied.
14+
15+
16+
### Filter
17+
18+
<img src="media/introduction/fig02-filter.png" width="75%" height="75%">
19+
20+
The CSTC enables HTTP requests and responses to be changed automatically according to the given recipe. The tabs for which the recipes are to be applied are selected using the ```Filter``` button at the top middle of the recipe panel. This opens the pop-up window for selection.
21+
22+
23+
### Different Recipes
24+
25+
<img src="media/introduction/fig03-different_recipes.png" width="75%" height="75%">
26+
27+
The CSTC enables parallel work with HTTP requests and responses. Exactly one recipe can be created for each of them. Which recipe you are currently working on is controlled via the tab selection in the top left corner. In the tab ```Outgoing Requests``` you work on the HTTP requests, in ```Incoming Responses``` you work analogously on the HTTP responses. The third tab ```Formatting``` offers space to work with data independently of requests and responses and has no effect on regarding automatic transformation of requests/responses. It can be used to test recipes or perform static transformations comparable to the GCHQ CyberChef.
28+
29+
30+
## Example 1 - Response
31+
32+
We will now look at two examples using a demo application. A detailed video demonstration of the CSTC can be found [here](https://www.youtube.com/watch?v=6fjW4iXj5cg).
33+
34+
<img src="media/introduction/fig04-send_to_incoming.png" width="75%" heigth="75%">
35+
36+
In this first example we see a HTTP request and its response in the Repeater tab. The body of the response is encoded and to create a matching recipe with the CSTC, we send the response to the ```Incoming``` tab.<br>
37+
Note here that the menu for sending the HTTP request to the CSTC can also be called up in the Proxy tab and, above all, in the HTTP history.
38+
39+
<img src="media/introduction/fig05-example_1_response.png" width="75%" height="75%">
40+
41+
Now the appropriate recipe must be created. In this case we use two lanes **(1)**: In the first, we extract the body of the HTTP response, decode it and store it in a variable named ```body```. In the second lane, we replace the body of the original HTTP response with the body we have manipulated and stored in the variable. We also add a suitable Content-Type Header so that Burp knows how to display the data in pretty print. We see the result on the right **(2)**. We finally instruct the CSTC to apply this recipe to all incoming responses in the Repeater tab **(3)**.
42+
43+
<img src="media/introduction/fig06-example_1_poc.png" width="75%" height="75%">
44+
45+
If we now resend our request in the Repeater tab, we see that the recipe is working.
46+
47+
48+
## Example 2 - Request
49+
50+
<img src="media/introduction/fig07-example_2.png" width="75%" height="75%">
51+
52+
For a second example, let's take a look at this HTTP POST request. We have three POST parameters and want to test the first parameter for SQL Injection. However, every time the value is changed, the API responds with an error message that the checksum is incorrect. In this case we found out that the values of the first two parameters are concatenated and then the SHA1 value is calculated of the resulting string. The result is cross-checked with the value of the integrity parameter. With the help of the CSTC, this scheme can be automatically applied to all outgoing requests and the testing process is greatly simplified.
53+
54+
<img src="media/introduction/fig08-send_to_outgoing.png" width="75%" height="75%">
55+
56+
As before, we send the data to the CSTC to be able to work with it. This time we work with the HTTP request, so we send it to the ```Outgoing``` tab.
57+
58+
<img src="media/introduction/fig09-load_recipe.png" width="75%" height="75%">
59+
60+
At this point, another feature of the CSTC can be demonstrated. Created recipes can be saved in the local file system and reloaded if necessary. Here, selecting ```Load``` **(1)** opens a pop-up and the saved recipe can be selected **(2)**.
61+
62+
<img src="media/introduction/fig10-example_1_recipe.png" width="75%" heigth="75%">
63+
64+
As you can see in the overview on the right, the value of the integrity parameter is now recalculated dynamically depending on the values of the request.
65+
66+
<img src="media/introduction/fig11-example_2_filter.png" width="75%" height="75%">
67+
68+
We now click on ```Filter``` again to select that the recipe should be applied to outgoing requests in the Repeater tab.
69+
70+
<img src="media/introduction/fig12-example_2_poc.png" width="75%" height="75%">
71+
72+
When resending the request in the Repeater tab, we receive an Internal Server Error, which means that the checksum test was successful and we can start testing the POST parameters.
73+
74+
<img src="media/introduction/fig13-example_2_sqli.png" width="75%" height="75%">
75+
76+
With an appropriately adapted payload, we can now verify and exploit a SQL injection vulnerability in this API endpoint.
77+
78+
### Automation with the help of the CSTC
79+
80+
Suppose we wanted to test the POST parameter using the Burp Scanner. Without adapting the integrity POST parameter, it is almost impossible to carry out a meaningful test. It is useful here that CSTC recipes can also be used for the Scanner.
81+
82+
<img src="media/introduction/fig14-scanner_filter.png" width="75%" height="75%">
83+
84+
First, we activate the use of the CSTC recipe for the Scanner.
85+
86+
<img src="media/introduction/fig15-intruder.png" width="75%" height="75%">
87+
88+
In the Intruder tab we now mark the parameter **(1)** to be tested and select the displayed menu item **(2)**. After selecting a suitable scan configuration, the scan can be started.
89+
90+
<img src="media/introduction/fig16-scan_result.png" width="75%" height="75%">
91+
92+
Using the CSTC recipe for outgoing requests, the Burp Scanner was able to confirm the SQLi as the CSTC transforms all requests containing payloads dynamically by applying the defined recipe shown above. This shows that the good integration of the CSTC can also be chained with other Extensions or builtin functions of Burp Suite.

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ Take a look at our basic tutorial on [YouTube](https://www.youtube.com/watch?v=B
8383
**UPDATE:** Due to some incompatibility issues when installing *CSTC* via *BApp Store*, we had to switch to a new variable prefix.
8484
Variables from other *lanes* have now to be prefixed by ``$`` e.g. like ``$Outgoing_step1``.
8585

86-
87-
## Known Issues
88-
89-
Unfortunately, the GUI of some *CSTC Operations* does not really work well together with the **dark theme** of *Burp Suite*. Therefore,
90-
we recommend to use a **light theme** for the best user experience.
91-
9286
## Feedback
9387

9488
We gladly appreciate all feedback, bug reports and feature requests.

media/introduction/fig01-overview.png

64.6 KB
Loading

media/introduction/fig02-filter.png

70.9 KB
Loading
58.1 KB
Loading
189 KB
Loading
Loading
129 KB
Loading
98.2 KB
Loading
147 KB
Loading
148 KB
Loading
155 KB
Loading
168 KB
Loading
97.1 KB
Loading
134 KB
Loading
94.6 KB
Loading

media/introduction/fig15-intruder.png

97.2 KB
Loading
90.5 KB
Loading

pom.xml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>de.usd.CSTC</groupId>
66
<artifactId>CSTC</artifactId>
7-
<version>1.3.0</version>
7+
<version>1.3.1</version>
88
<name>CSTC</name>
99
<description>CSTC</description>
1010

@@ -17,13 +17,13 @@
1717
<dependency>
1818
<groupId>com.jayway.jsonpath</groupId>
1919
<artifactId>json-path</artifactId>
20-
<version>2.7.0</version>
20+
<version>2.9.0</version>
2121
</dependency>
2222

2323
<dependency>
24-
<groupId>net.portswigger.burp.extender</groupId>
25-
<artifactId>burp-extender-api</artifactId>
26-
<version>2.3</version>
24+
<groupId>net.portswigger.burp.extensions</groupId>
25+
<artifactId>montoya-api</artifactId>
26+
<version>2023.12.1</version>
2727
</dependency>
2828

2929
<dependency>
@@ -35,19 +35,25 @@
3535
<dependency>
3636
<groupId>com.fasterxml.jackson.core</groupId>
3737
<artifactId>jackson-core</artifactId>
38-
<version>2.14.2</version>
38+
<version>2.17.1</version>
3939
</dependency>
4040

4141
<dependency>
4242
<groupId>com.fasterxml.jackson.core</groupId>
4343
<artifactId>jackson-databind</artifactId>
44-
<version>2.14.2</version>
44+
<version>2.17.1</version>
4545
</dependency>
4646

4747
<dependency>
4848
<groupId>org.apache.commons</groupId>
4949
<artifactId>commons-text</artifactId>
50-
<version>1.10.0</version>
50+
<version>1.12.0</version>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>com.auth0</groupId>
55+
<artifactId>java-jwt</artifactId>
56+
<version>4.4.0</version>
5157
</dependency>
5258

5359
<dependency>
@@ -56,6 +62,12 @@
5662
<version>4.13.2</version>
5763
<scope>test</scope>
5864
</dependency>
65+
66+
<dependency>
67+
<groupId>org.javatuples</groupId>
68+
<artifactId>javatuples</artifactId>
69+
<version>1.2</version>
70+
</dependency>
5971

6072
</dependencies>
6173

@@ -80,17 +92,17 @@
8092

8193
<plugin>
8294
<artifactId>maven-compiler-plugin</artifactId>
83-
<version>3.11.0</version>
95+
<version>3.13.0</version>
8496
<configuration>
85-
<source>1.8</source>
86-
<target>1.8</target>
97+
<source>17</source>
98+
<target>17</target>
8799
</configuration>
88100
</plugin>
89101

90102
<plugin>
91103
<groupId>org.apache.maven.plugins</groupId>
92104
<artifactId>maven-surefire-plugin</artifactId>
93-
<version>3.0.0</version>
105+
<version>3.2.5</version>
94106
<configuration>
95107
<trimStackTrace>false</trimStackTrace>
96108
<redirectTestOutputToFile>true</redirectTestOutputToFile>

src/main/java/burp/BurpExtender.java

Lines changed: 41 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,59 @@
11
package burp;
22

3-
import java.awt.Component;
4-
import java.awt.event.ActionEvent;
5-
import java.awt.event.ActionListener;
6-
import java.util.ArrayList;
7-
import java.util.List;
3+
import com.fasterxml.jackson.databind.ObjectMapper;
84

9-
import javax.swing.JMenuItem;
10-
11-
import de.usd.cstchef.view.FormatTab;
12-
import de.usd.cstchef.view.RecipePanel;
5+
import burp.api.montoya.BurpExtension;
6+
import burp.api.montoya.MontoyaApi;
7+
import burp.api.montoya.core.BurpSuiteEdition;
8+
import burp.api.montoya.persistence.PersistedObject;
9+
import de.usd.cstchef.view.RequestFilterDialog;
1310
import de.usd.cstchef.view.View;
11+
import de.usd.cstchef.view.filter.FilterState;
12+
import de.usd.cstchef.view.filter.FilterState.BurpOperation;
1413

15-
public class BurpExtender implements IBurpExtender, ITab, IMessageEditorTabFactory, IHttpListener, IContextMenuFactory {
14+
public class BurpExtender implements BurpExtension {
1615

1716
private final String extensionName = "CSTC";
18-
private IBurpExtenderCallbacks callbacks;
1917
private View view;
2018

2119
@Override
22-
public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks) {
23-
this.callbacks = callbacks;
24-
Logger.getInstance().init(callbacks.getStdout(), callbacks.getStderr());
25-
BurpUtils.getInstance().init(callbacks);
26-
27-
callbacks.setExtensionName(this.extensionName);
28-
callbacks.addSuiteTab(this);
29-
callbacks.registerHttpListener(this);
30-
callbacks.registerContextMenuFactory(this);
31-
callbacks.registerMessageEditorTabFactory(this);
32-
}
33-
34-
35-
@Override
36-
public String getTabCaption() {
37-
return this.extensionName;
38-
}
39-
40-
@Override
41-
public Component getUiComponent() {
20+
public void initialize(MontoyaApi api) {
21+
BurpUtils.getInstance().init(api);
4222
this.view = new View();
43-
return this.view;
44-
}
45-
46-
@Override
47-
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) {
48-
if (messageIsRequest && view.getOutgoingRecipePanel().shouldProcess(toolFlag)) {
49-
byte[] request = messageInfo.getRequest();
50-
byte[] modifiedRequest = view.getOutgoingRecipePanel().bake(request);
51-
Logger.getInstance().log("modified request: \n" + new String(modifiedRequest));
52-
messageInfo.setRequest(modifiedRequest);
53-
} else if (view.getIncomingRecipePanel().shouldProcess(toolFlag)) {
54-
byte[] response = messageInfo.getResponse();
55-
byte[] modifiedResponse = view.getIncomingRecipePanel().bake(response);
56-
messageInfo.setResponse(modifiedResponse);
57-
Logger.getInstance().log("modified response: \n" + new String(modifiedResponse));
23+
BurpUtils.getInstance().setView(view);
24+
api.extension().setName(extensionName);
25+
api.userInterface().registerContextMenuItemsProvider(new CstcContextMenuItemsProvider(api, view));
26+
api.http().registerHttpHandler(new CstcHttpHandler(view));
27+
api.userInterface().registerSuiteTab(extensionName, view);
28+
api.userInterface().registerHttpRequestEditorProvider(new MyHttpRequestEditorProvider(view));
29+
api.userInterface().registerHttpResponseEditorProvider(new MyHttpResponseEditorProvider(view));
30+
31+
if (!api.burpSuite().version().edition().equals(BurpSuiteEdition.COMMUNITY_EDITION)) {
32+
PersistedObject persistence = api.persistence().extensionData();
33+
restoreFilterState(persistence);
34+
restoreRecipe(persistence);
5835
}
36+
view.updateInactiveWarnings();
5937
}
6038

61-
@Override
62-
public List<JMenuItem> createMenuItems(IContextMenuInvocation invoc) {
63-
64-
List<JMenuItem> menuItems = new ArrayList<>();
65-
JMenuItem incomingMenu = new JMenuItem("Send to CSTC (Incoming)");
66-
JMenuItem outgoingMenu = new JMenuItem("Send to CSTC (Outgoing)");
67-
JMenuItem incomingFormatMenu = new JMenuItem("Send to CSTC (Formating)");
68-
69-
menuItems.add(incomingMenu);
70-
menuItems.add(outgoingMenu);
71-
menuItems.add(incomingFormatMenu);
72-
73-
incomingMenu.addActionListener(new ActionListener() {
74-
@Override
75-
public void actionPerformed(ActionEvent e) {
76-
IHttpRequestResponse[] msgs = invoc.getSelectedMessages();
77-
if (msgs != null && msgs.length > 0) {
78-
view.getIncomingRecipePanel().setInput(msgs[0]);
79-
}
80-
}
81-
});
82-
83-
outgoingMenu.addActionListener(new ActionListener() {
84-
@Override
85-
public void actionPerformed(ActionEvent e) {
86-
IHttpRequestResponse[] msgs = invoc.getSelectedMessages();
87-
if (msgs != null && msgs.length > 0) {
88-
view.getOutgoingRecipePanel().setInput(msgs[0]);
89-
}
90-
91-
}
92-
});
93-
94-
incomingFormatMenu.addActionListener(new ActionListener() {
95-
@Override
96-
public void actionPerformed(ActionEvent e) {
97-
IHttpRequestResponse[] msgs = invoc.getSelectedMessages();
98-
if (msgs != null && msgs.length > 0) {
99-
view.getFormatRecipePanel().setInput(msgs[0]);
100-
}
101-
}
102-
});
103-
104-
return menuItems;
39+
private void restoreRecipe(PersistedObject persistence) {
40+
try {
41+
this.view.getFormatRecipePanel().restoreState(persistence.getString(BurpOperation.FORMAT + "Recipe"));
42+
this.view.getIncomingRecipePanel().restoreState(persistence.getString(BurpOperation.INCOMING + "Recipe"));
43+
this.view.getOutgoingRecipePanel().restoreState(persistence.getString(BurpOperation.OUTGOING + "Recipe"));
44+
} catch (Exception e) {
45+
Logger.getInstance().log(
46+
"Could not restore the recipe for one or multiple panels. If this is the first time using CSTC in a project, you can ignore this message.");
47+
}
10548
}
10649

107-
@Override
108-
public IMessageEditorTab createNewInstance(IMessageEditorController controller, boolean editable) {
109-
RecipePanel requestFormatPanel = this.view.getOutgoingRecipePanel();
110-
// TODO do we need the format panel or do we want to use the incoming recipe?
111-
RecipePanel responseFormatPanel = this.view.getFormatRecipePanel();
112-
return new FormatTab(requestFormatPanel, responseFormatPanel, editable);
50+
private void restoreFilterState(PersistedObject persistence) {
51+
try {
52+
BurpUtils.getInstance().setFilterState(new ObjectMapper().readValue(persistence.getString("FilterState"), FilterState.class));
53+
RequestFilterDialog.getInstance().updateFilterSettings();
54+
} catch (Exception e) {
55+
Logger.getInstance().log(
56+
"Could not restore the filter state. If this is the first time using CSTC in a project, you can ignore this message. " + e.getMessage());
57+
}
11358
}
11459
}

0 commit comments

Comments
 (0)