Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package burp;

import burp.ImportATOR;
import javax.swing.*;
import java.awt.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.Map;
import java.io.File;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;


public class BurpExtender implements IBurpExtender, IContextMenuFactory, ITab, IHttpListener {
Expand Down Expand Up @@ -40,8 +46,18 @@ public void registerExtenderCallbacks(IBurpExtenderCallbacks iBurpExtenderCallba
extension.append("[*] ");
extension.append(EXTENSION_NAME);

// Load default JSON config, if available
ImportATOR importer = new ImportATOR(callbacks);
String filepath = System.getenv().get("ATOR_CONFIG_FILEPATH");
if(filepath != null) {
File f = new File(filepath);
if(f.exists() && !f.isDirectory()) {
importer.loadJSONFile(filepath);
callbacks.printOutput("ATOR configuration loaded successfully from " + filepath);
}
}
callbacks.printOutput("ATOR loaded successfully");
}
}

public BurpExtender getComponent() {
return BurpExtender.this;
Expand Down
57 changes: 29 additions & 28 deletions src/main/java/burp/ImportATOR.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,37 @@ public ImportATOR(IBurpExtenderCallbacks callbacks) {

public void readJSONFile() {
String filePath = null;
JFileChooser fileSelector = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());
int fileChoosenState = fileSelector.showOpenDialog(null);
if (fileChoosenState == JFileChooser.APPROVE_OPTION)
filePath = fileSelector.getSelectedFile().getAbsolutePath();
if(filePath != null)
{
SetttingsTab.importATORFile.setText(filePath);
JSONParser jsonParser = new JSONParser();

try (FileReader reader = new FileReader(filePath))
{
JSONObject jsonObject = (JSONObject) jsonParser.parse(reader);

JSONObject errorCondition = (JSONObject) jsonObject.get("errorCondition");

parseErrorCondition(errorCondition);

JSONObject obtainToken = (JSONObject) jsonObject.get("obtainToken");
parseObtainToken(obtainToken);
JSONObject errorConditionReplacement = (JSONObject) jsonObject.get("errorConditionReplacement");
parseErrorConditionReplacement(errorConditionReplacement);

}
catch(Exception exp) {
callbacks.printOutput("Exception while importing file.."+ exp.getMessage());
}
}

JFileChooser fileSelector = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());
int fileChoosenState = fileSelector.showOpenDialog(null);
if (fileChoosenState == JFileChooser.APPROVE_OPTION)
filePath = fileSelector.getSelectedFile().getAbsolutePath();
if(filePath != null)
{
loadJSONFile(filePath);
}
}

public void loadJSONFile(String filePath) {
SetttingsTab.importATORFile.setText(filePath);
JSONParser jsonParser = new JSONParser();

try (FileReader reader = new FileReader(filePath))
{
JSONObject jsonObject = (JSONObject) jsonParser.parse(reader);

JSONObject errorCondition = (JSONObject) jsonObject.get("errorCondition");

parseErrorCondition(errorCondition);

JSONObject obtainToken = (JSONObject) jsonObject.get("obtainToken");
parseObtainToken(obtainToken);
JSONObject errorConditionReplacement = (JSONObject) jsonObject.get("errorConditionReplacement");
parseErrorConditionReplacement(errorConditionReplacement);
}
catch(Exception exp) {
callbacks.printOutput("Exception while importing file.."+ exp.getMessage());
}
}

public void parseErrorCondition(JSONObject jsonObject) {

Expand Down