-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathExtractorMainTab.java
More file actions
94 lines (77 loc) · 2.92 KB
/
ExtractorMainTab.java
File metadata and controls
94 lines (77 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package burp;
import burp.persistence.ExtractorTabState;
import burp.persistence.Persistor;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
public class ExtractorMainTab implements ITab {
private HashMap<Integer, ExtractorTab> extractorTabMap;
private ExtractorSelectorTab selectorTab;
private int tabNum = 0;
static int tabsRemoved = 0;
private JTabbedPane tabbedPane;
public ExtractorMainTab(IBurpExtenderCallbacks callbacks) {
this.extractorTabMap = new HashMap<Integer, ExtractorTab>();
this.tabbedPane = new JTabbedPane();
callbacks.customizeUiComponent(this.tabbedPane);
callbacks.addSuiteTab(ExtractorMainTab.this);
// Create selection tab
this.selectorTab = new ExtractorSelectorTab(this, callbacks);
this.tabbedPane.add(selectorTab.getUiComponent());
this.tabbedPane.setTabComponentAt(0, new JLabel("Selection"));
}
public void addMessageFromMenu(IHttpRequestResponse message) {
this.selectorTab.addMessageFromMenu(message);
this.tabbedPane.setSelectedIndex(0);
}
public ExtractorTab createExtractorTab(byte[] response, byte[] request, String responseHost, String requestHost, IBurpExtenderCallbacks callbacks) {
this.tabNum++;
int index = (this.tabNum) - this.tabsRemoved;
// Pause Persistor so that we don't write values before the tab loads
Persistor.pause();
ExtractorTab extractorTab = new ExtractorTab(response, request, responseHost, requestHost, callbacks);
this.tabbedPane.add(extractorTab.getUiComponent());
this.tabbedPane.setTabComponentAt(index, new ButtonTabComponent(this, this.tabNum));
this.tabbedPane.setSelectedIndex(index);
this.extractorTabMap.put(this.tabNum, extractorTab);
// Now unpause, and write the addition
Persistor.unpause();
Persistor.persistExtractor();
return extractorTab;
}
public ExtractorTab createExtractorTab(ExtractorTabState tabState, IBurpExtenderCallbacks callbacks) {
ExtractorTab extractorTab = this.createExtractorTab(tabState.responseState.content.getBytes(),
tabState.requestState.content.getBytes(),
tabState.requestState.targetHost,
tabState.responseState.targetHost,
callbacks);
// Pause Persistor so that we don't have unnecessary writes for each change we make
Persistor.pause();
extractorTab.setState(tabState);
Persistor.unpause();
Persistor.persistExtractor();
return extractorTab;
}
public ArrayList<ExtractorTab> getExtractorTabs() {
return new ArrayList<ExtractorTab>(this.extractorTabMap.values());
}
public int getIndexOfTabComponent(ButtonTabComponent button) {
return this.tabbedPane.indexOfTabComponent(button);
}
public void removeTab(int index) {
this.tabbedPane.remove(index);
}
public void removeExtractor(int tabNum) {
this.extractorTabMap.remove(tabNum);
Persistor.persistExtractor();
}
@Override
public String getTabCaption() {
return "Extractor";
}
@Override
public Component getUiComponent() {
return this.tabbedPane;
}
}