diff --git a/src/main/java/de/usd/cstchef/Utils.java b/src/main/java/de/usd/cstchef/Utils.java index 4c733c8..a42952b 100644 --- a/src/main/java/de/usd/cstchef/Utils.java +++ b/src/main/java/de/usd/cstchef/Utils.java @@ -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; @@ -393,7 +394,7 @@ public static Class[] 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, @@ -425,7 +426,7 @@ public static Class[] 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, diff --git a/src/main/java/de/usd/cstchef/operations/setter/HttpHeaderRemove.java b/src/main/java/de/usd/cstchef/operations/setter/HttpHeaderRemove.java new file mode 100644 index 0000000..b5cad7e --- /dev/null +++ b/src/main/java/de/usd/cstchef/operations/setter/HttpHeaderRemove.java @@ -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); + } + +}