Skip to content

Commit

Permalink
Add Remove HTTP Header Operation
Browse files Browse the repository at this point in the history
  • Loading branch information
felixb1515 committed Nov 15, 2024
1 parent 5266e74 commit 10dd603
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/de/usd/cstchef/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
import de.usd.cstchef.operations.misc.ReadFile;
import de.usd.cstchef.operations.misc.WriteFile;
import de.usd.cstchef.operations.networking.PlainRequest;
import de.usd.cstchef.operations.setter.HttpHeaderRemove;
import de.usd.cstchef.operations.setter.HttpGetSetter;
import de.usd.cstchef.operations.setter.HttpHeaderSetter;
import de.usd.cstchef.operations.setter.HttpJsonSetter;
Expand Down Expand Up @@ -393,7 +394,7 @@ public static Class<? extends Operation>[] getOperationsDevOutgoingFormatting()
RequestBuilder.class,
GetVariable.class, Gost.class, GUnzip.class, Gzip.class, Hmac.class,
HttpBodyExtractor.class, HttpCookieExtractor.class, HttpGetExtractor.class,
HttpGetSetter.class, HttpHeaderExtractor.class, HttpHeaderSetter.class,
HttpGetSetter.class, HttpHeaderExtractor.class, HttpHeaderSetter.class, HttpHeaderRemove.class,
HttpJsonExtractor.class, HttpJsonSetter.class, HttpMethodExtractor.class, HttpMultipartExtractor.class,
HttpMultipartSetter.class,
HttpPostExtractor.class, HttpPostSetter.class, PlainRequest.class, HttpSetBody.class,
Expand Down Expand Up @@ -425,7 +426,7 @@ public static Class<? extends Operation>[] getOperationsDevIncoming() {
Blake.class, Counter.class, DateTime.class, Deflate.class, DesDecryption.class, DesEncryption.class,
Divide.class, DivideList.class, DSTU7564.class, FromBase64.class, FromHex.class, RequestBuilder.class,
GetVariable.class, Gost.class, GUnzip.class, Gzip.class, Hmac.class, HttpBodyExtractor.class,
HttpCookieExtractor.class, HttpHeaderExtractor.class, HttpHeaderSetter.class, HttpJsonExtractor.class,
HttpCookieExtractor.class, HttpHeaderExtractor.class, HttpHeaderSetter.class, HttpHeaderRemove.class, HttpJsonExtractor.class,
HttpJsonSetter.class, HttpMultipartExtractor.class, HttpMultipartSetter.class, PlainRequest.class,
HttpSetBody.class, HttpSetCookie.class, HttpXmlExtractor.class, HttpXmlSetter.class, XmlSetter.class, HtmlEncode.class,
HtmlDecode.class, Inflate.class, JsonExtractor.class, JsonSetter.class, JWTDecode.class, JWTSign.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package de.usd.cstchef.operations.setter;

import burp.api.montoya.core.ByteArray;
import burp.api.montoya.http.message.requests.HttpRequest;
import burp.api.montoya.http.message.responses.HttpResponse;
import de.usd.cstchef.Utils.MessageType;
import de.usd.cstchef.operations.Operation;
import de.usd.cstchef.operations.Operation.OperationInfos;
import de.usd.cstchef.view.ui.VariableTextField;
import de.usd.cstchef.operations.OperationCategory;

@OperationInfos(name = "Remove HTTP Header", category = OperationCategory.SETTER, description = "Remove the specified HTTP Header.")
public class HttpHeaderRemove extends Operation {

private VariableTextField header;

@Override
protected ByteArray perform(ByteArray input, MessageType messageType) throws Exception {
String headerName = header.getText();

if(headerName.isEmpty()) {
return input;
}

if(messageType == MessageType.REQUEST) {
return HttpRequest.httpRequest(input).withRemovedHeader(headerName).toByteArray();
}
else if(messageType == MessageType.RESPONSE) {
return HttpResponse.httpResponse(input).withRemovedHeader(headerName).toByteArray();
}
else {
return parseRawMessage(input);
}
}


@Override
public void createUI() {
this.header = new VariableTextField();

this.addUIElement("Header Name", this.header);
}

}

0 comments on commit 10dd603

Please sign in to comment.