Burp Suite User Forum

Create new post

setHighlight: shows in http history, but not my own table. How do I make it show in my table?

gnothi | Last updated: Jul 24, 2020 12:13AM UTC

I wrote an extension, that after some checking, marks certain ((IHttpRequestResponse) messages, using message.getMessageInfo().setHighlight('red') What I don't fully grasp is: The marked messages show correctly 'red' in the Proxy -> HttpHistory tab. However, in my own table (JTable), no colors are shown. Question is: what do I need to do to have my table to show those colors as well? It's awesome to have 'messages' uniformly marked throughout burp, and it would kinda suck to do individual coloring on my own tables. So how can my table show from the colors that are given to these messages? -- Some relevant code (obviously not complete, the whole program is over 500 lines) Short summary of the below code: * I create a JTable * In that table I show an ID and an URL. The ID is just based on an autoincrement. In my database I do store the 'message.getMessageReference()'. Maybe that has something to do with it? * I included the complete tablemodel and table code --- self._urlTable = TableUrls(UrlsTableModel(self)) callbacks.customizeUiComponent(self._urlTable) def addUrlLog(self, message): messageReferenceId = message.getMessageReference() url = self._helpers.analyzeRequest(message.getMessageInfo()).getUrl() _id = len(self._db) request_response = message.getMessageInfo() self._lock.acquire() self._db[messageReferenceId] = {'id': _id, 'url': url, 'message': self._callbacks.saveBuffersToTempFiles(request_response), 'vulnerabilityscans': {}} self._lock.release() #Complete tabelmodel class UrlsTableModel(AbstractTableModel): def __init__(self, extender): self._extender = extender self._db = extender._db def getRowCount(self): try: return self._db.urlLogsCount() except: return 0 def getColumnCount(self): return 2 def getColumnName(self, columnIndex): if columnIndex == 0: return "#" if columnIndex == 1: return "URL" return "" def getValueAt(self, rowIndex, columnIndex): urlId = self._db.urlLogByIndex(rowIndex) if columnIndex == 0: return self._db.urlLog(urlId)['id'] if columnIndex == 1: return self._db.urlLog(urlId)['url'] return "" # # extend JTable to handle cell selection # class TableUrls(JTable): def __init__(self, model): self.setModel(model) def changeSelection(self, row, col, toggle, extend): # show the log entry for the selected row urlId = self.getModel()._db.urlLogByIndex(row) self.getModel()._db.setCurrentSelectedUrlLog(urlId) self.getModel()._extender._vulnerabilityScanTable.redraw() JTable.changeSelection(self, row, col, toggle, extend)

Hannah, PortSwigger Agent | Last updated: Jul 24, 2020 01:16PM UTC

Have you had a look at how other extensions have implemented this behavior? For example, Flow and Logger++ You can find the source code for all BApp Store extensions available on our GitHub: https://github.com/portswigger

gnothi | Last updated: Aug 15, 2020 06:49AM UTC

I'll answer my own question, in case it might help anyone: In the 'class BurpExtender', after your components are defined, add this line: self._urlTable.setDefaultRenderer(Object, UserEnabledRenderer(self._urlTable.getDefaultRenderer(Object))) So basically: give a renderer to your table. Then define that renderer, by: class UserEnabledRenderer(TableCellRenderer): def __init__(self, defaultCellRender): self._defaultCellRender = defaultCellRender def getTableCellRendererComponent(self, table, value, isSelected, hasFocus, row, column): cell = self._defaultCellRender.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column) if value == 'Vulnerable': cell.setBackground(Color.RED) return cell So basically: when a table is drawn, the renderer will go over each cell, come to this class, test it's value and if it find the value you're looking for, it will apply a bg-color to that cell. Things get a bit more complicated if you like to highlight rows, but it's the same process. Only in that case you can't rely on 'value' of the cell... but you might do something like: if table.getModel().getValueAt(table.convertRowIndexToModel(row), self.columnContainingAnalysis) == 'Vulnerable' cell.setBackground(Color.RED) So as far as I'm aware of, there is no way to color an entire row, but you'll need to test each individual cell if it happens to be on the row that contains a value and if it does, color it. Hope that helps

You must be an existing, logged-in customer to reply to a thread. Please email us for additional support.