diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..eb46c11 Binary files /dev/null and b/.DS_Store differ diff --git a/HaE/HaE.py b/HaE/HaE.py index f276723..be818f9 100644 --- a/HaE/HaE.py +++ b/HaE/HaE.py @@ -111,14 +111,14 @@ class BurpExtender(IBurpExtender, ITab,IHttpListener, IMessageEditorTabFactory): if colorText in colors: with open(configFile, 'r+') as content: dicts = json.load(content) - # 解决r+写入问题 - content.seek(0,0) - content.truncate() if nameText in dicts: self.tipString.setText("Name is existed!") elif not(isHighlight or isExtract): self.tipString.setText("Highlight or Extract?") else: + # 解决r+写入问题 + content.seek(0,0) + content.truncate() dicts[nameText] = {"regex": regexText, "highlight": isHighlight, "extract": isExtract, "color": colorText} content.write(jsbeautifier.beautify(json.dumps(dicts))) #print(dicts) @@ -127,9 +127,18 @@ class BurpExtender(IBurpExtender, ITab,IHttpListener, IMessageEditorTabFactory): self.tipString.setText("Not in colors list.") def reloadConfig(self, event): + # 重新载入配置文件 with open(configFile, 'r') as content: self.configTextArea.setText(content.read()) + def saveConfig(self, event): + # 保存配置文件 + text = self.configTextArea.getText() + if text != "": + with open(configFile, 'w') as content: + content.write(text) + self.reloadConfig() + def getUiComponent(self): self.HaEPanel = JPanel() self.HaEPanel.setBorder(None) @@ -172,11 +181,8 @@ class BurpExtender(IBurpExtender, ITab,IHttpListener, IMessageEditorTabFactory): self.configPanel = JPanel() self.tabbedPane.addTab("Config", None, self.configPanel, None) self.configPanel.setLayout(BorderLayout(0, 0)) - self.configString = JLabel("This is config file content.") - self.configString.setHorizontalAlignment(SwingConstants.CENTER) - self.configPanel.add(self.configString, BorderLayout.NORTH) self.configTextArea = JTextArea() - self.configTextArea.setEnabled(False) + # self.configTextArea.setEnabled(False) self.configTextArea.setTabSize(4) self.configTextArea.setLineWrap(True) self.configTextArea.setRows(20) @@ -184,7 +190,9 @@ class BurpExtender(IBurpExtender, ITab,IHttpListener, IMessageEditorTabFactory): self.scrollPane = JScrollPane(self.configTextArea) self.configPanel.add(self.scrollPane, BorderLayout.SOUTH) self.reloadButton = JButton("Reload", actionPerformed=self.reloadConfig) - self.configPanel.add(self.reloadButton, BorderLayout.CENTER) + self.configPanel.add(self.reloadButton, BorderLayout.NORTH) + self.saveButton = JButton("Save", actionPerformed=self.saveConfig) + self.configPanel.add(self.saveButton, BorderLayout.CENTER) return self.HaEPanel class MarkINFOTab(IMessageEditorTab):