-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Site Map and Decode as new Then Send To target. Require URL for…
… When In Scope constraints used under WebSocket Rules. Added new Then: Read File. Then Run Process: Fixed issue with running commands on UNIX-like systems. Auto-refresh export data lists. Add select all and unselect all functionality to export data lists. Remember last export and import folder location.
- Loading branch information
Showing
35 changed files
with
937 additions
and
229 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
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
35 changes: 35 additions & 0 deletions
35
extension/src/main/java/synfron/reshaper/burp/core/messages/HighlightColor.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,35 @@ | ||
package synfron.reshaper.burp.core.messages; | ||
|
||
import lombok.Getter; | ||
|
||
public enum HighlightColor { | ||
None(null, burp.api.montoya.core.HighlightColor.NONE), | ||
Red("red", burp.api.montoya.core.HighlightColor.RED), | ||
Orange("orange", burp.api.montoya.core.HighlightColor.ORANGE), | ||
Yellow("yellow", burp.api.montoya.core.HighlightColor.YELLOW), | ||
Green("green", burp.api.montoya.core.HighlightColor.GREEN), | ||
Cyan("cyan", burp.api.montoya.core.HighlightColor.CYAN), | ||
Blue("blue", burp.api.montoya.core.HighlightColor.BLUE), | ||
Pink("pink", burp.api.montoya.core.HighlightColor.PINK), | ||
Magenta("magenta", burp.api.montoya.core.HighlightColor.MAGENTA), | ||
Gray("gray", burp.api.montoya.core.HighlightColor.GRAY); | ||
|
||
private final String value; | ||
|
||
@Getter | ||
private final burp.api.montoya.core.HighlightColor highlightColor; | ||
|
||
HighlightColor(String value, burp.api.montoya.core.HighlightColor highlightColor) { | ||
this.value = value; | ||
this.highlightColor = highlightColor; | ||
} | ||
|
||
public String getValue() { | ||
return this.value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.name(); | ||
} | ||
} |
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
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
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
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
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
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
114 changes: 114 additions & 0 deletions
114
extension/src/main/java/synfron/reshaper/burp/core/rules/thens/ThenReadFile.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,114 @@ | ||
package synfron.reshaper.burp.core.rules.thens; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.apache.commons.io.FileUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import synfron.reshaper.burp.core.exceptions.WrappedException; | ||
import synfron.reshaper.burp.core.messages.Encoder; | ||
import synfron.reshaper.burp.core.messages.EventInfo; | ||
import synfron.reshaper.burp.core.rules.IHttpRuleOperation; | ||
import synfron.reshaper.burp.core.rules.IWebSocketRuleOperation; | ||
import synfron.reshaper.burp.core.rules.RuleOperationType; | ||
import synfron.reshaper.burp.core.rules.RuleResponse; | ||
import synfron.reshaper.burp.core.rules.thens.entities.savefile.FileExistsAction; | ||
import synfron.reshaper.burp.core.vars.SetListItemPlacement; | ||
import synfron.reshaper.burp.core.vars.VariableSource; | ||
import synfron.reshaper.burp.core.vars.VariableString; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
|
||
public class ThenReadFile extends Then<ThenReadFile> implements IHttpRuleOperation, IWebSocketRuleOperation { | ||
|
||
@Getter @Setter | ||
private VariableString filePath; | ||
@Getter @Setter | ||
private VariableString encoding; | ||
@Getter @Setter | ||
private boolean breakAfterFailure = true; | ||
@Getter @Setter | ||
private boolean captureAfterFailure; | ||
@Getter @Setter | ||
private VariableSource captureVariableSource = VariableSource.Global; | ||
@Getter @Setter | ||
private VariableString captureVariableName; | ||
@Getter @Setter | ||
private SetListItemPlacement itemPlacement = SetListItemPlacement.Index; | ||
@Getter @Setter | ||
private VariableString delimiter; | ||
@Getter @Setter | ||
private VariableString index; | ||
|
||
@Override | ||
public RuleResponse perform(EventInfo eventInfo) { | ||
boolean hasError = false; | ||
boolean failed = true; | ||
String captureVariableName = null; | ||
String filePathValue = null; | ||
String fileText = ""; | ||
String encodingValue = null; | ||
try { | ||
captureVariableName = getVariableName(eventInfo); | ||
filePathValue = filePath.getText(eventInfo); | ||
try { | ||
Path path = Paths.get(filePathValue); | ||
if (Files.isRegularFile(path) && Files.isReadable(path)) { | ||
encodingValue = VariableString.getTextOrDefault(eventInfo, encoding, Charset.defaultCharset().name()); | ||
Encoder encoder = new Encoder(encodingValue); | ||
fileText = encoder.decode(FileUtils.readFileToByteArray(path.toFile())); | ||
failed = false; | ||
} | ||
} catch (Exception ignored) { | ||
} finally { | ||
if (!failed || captureAfterFailure) { | ||
setVariable( | ||
captureVariableSource, | ||
eventInfo, | ||
captureVariableName, | ||
itemPlacement, | ||
VariableString.getTextOrDefault(eventInfo, delimiter, "\n"), | ||
VariableString.getIntOrDefault(eventInfo, index, 0), | ||
fileText | ||
); | ||
} | ||
} | ||
} catch (Exception e) { | ||
hasError = true; | ||
throw e; | ||
} finally { | ||
if (eventInfo.getDiagnostics().isEnabled()) eventInfo.getDiagnostics().logProperties(this, hasError, List.of( | ||
Pair.of("filePath", filePathValue), | ||
Pair.of("text", fileText), | ||
Pair.of("encoding", encodingValue), | ||
Pair.of("captureVariableSource", captureVariableSource), | ||
Pair.of("captureVariableName", captureVariableName), | ||
Pair.of("itemPlacement", captureVariableSource.isList() ? itemPlacement : null), | ||
Pair.of("delimiter", captureVariableSource.isList() && itemPlacement.isHasDelimiterSetter() ? VariableString.getTextOrDefault(eventInfo, delimiter, null) : null), | ||
Pair.of("index", captureVariableSource.isList() && itemPlacement.isHasIndexSetter() ? VariableString.getTextOrDefault(eventInfo, index, null) : null), | ||
Pair.of("failed", failed) | ||
)); | ||
} | ||
return failed && breakAfterFailure ? RuleResponse.BreakRules : RuleResponse.Continue; | ||
} | ||
|
||
private String getVariableName(EventInfo eventInfo) { | ||
String captureVariableName; | ||
if (StringUtils.isEmpty(captureVariableName = this.captureVariableName.getText(eventInfo))) { | ||
throw new IllegalArgumentException("Invalid variable name"); | ||
} | ||
return captureVariableName; | ||
} | ||
|
||
@Override | ||
public RuleOperationType<ThenReadFile> getType() { | ||
return ThenType.ReadFile; | ||
} | ||
} |
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
Oops, something went wrong.