-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5266e74
commit 10dd603
Showing
2 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/de/usd/cstchef/operations/setter/HttpHeaderRemove.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |