diff --git a/src/knife/FindUrlAndRequest.java b/src/knife/FindUrlAndRequest.java index 5cf8b27..bcbede5 100644 --- a/src/knife/FindUrlAndRequest.java +++ b/src/knife/FindUrlAndRequest.java @@ -40,6 +40,14 @@ public class FindUrlAndRequest extends JMenuItem { * */ private static final long serialVersionUID = 1L; + public static final String[] blackHostList = {"www.w3.org", "ns.adobe.com", "iptc.org", "openoffice.org" + , "schemas.microsoft.com", "schemas.openxmlformats.org", "sheetjs.openxmlformats.org","registry.npmjs.org" + ,"json-schema.org","jmespath.org"}; + + public static final List blackPath = TextUtils.textToLines("text/css\r\n" + + " text/html\r\n" + + " text/plain\r\n" + + " image/pdf\r\n"); //JMenuItem vs. JMenu public FindUrlAndRequest(BurpExtender burp) { @@ -47,6 +55,31 @@ public FindUrlAndRequest(BurpExtender burp) { this.addActionListener(new FindUrl_Action(burp, burp.invocation)); } + + public static List cleanUrls(List urls) { + + urls = TextUtils.deduplicate(urls); + Iterator it = urls.iterator(); + while (it.hasNext()) { + String urlItem = it.next(); + if (UrlUtils.uselessExtension(urlItem)) { + it.remove(); + } + if (blackPath.contains(urlItem)) { + it.remove(); + } + try { + String host = new URL(urlItem).getHost(); + if (Arrays.asList(blackHostList).contains(host)) { + it.remove(); + } + } catch (Exception E) { + continue; + } + } + return urls; + } + public static void main(String[] args) { String url = "./abac/aaa.jpg"; if (url.startsWith("./")) { @@ -63,14 +96,7 @@ class FindUrl_Action implements ActionListener { public PrintWriter stderr; public IBurpExtenderCallbacks callbacks; public BurpExtender burp; - public static final String[] blackHostList = {"www.w3.org", "ns.adobe.com", "iptc.org", "openoffice.org" - , "schemas.microsoft.com", "schemas.openxmlformats.org", "sheetjs.openxmlformats.org","registry.npmjs.org" - ,"json-schema.org","jmespath.org"}; - - public static final List blackPath = TextUtils.textToLines("text/css\r\n" - + " text/html\r\n" - + " text/plain\r\n" - + " image/pdf\r\n"); + private static Proxy proxy; @@ -181,7 +207,7 @@ public void findUrls(IHttpRequestResponse message) { urls.addAll(UrlUtils.grepUrlsWithProtocol(body)); urls.addAll(UrlUtils.grepUrlPathNotStartWithSlashInQuotes(body)); urls.addAll(UrlUtils.grepUrlsInQuotes(body)); - urls = cleanUrls(urls); + urls = FindUrlAndRequest.cleanUrls(urls); baseUrls.addAll(findPossibleBaseURL(urls)); } } @@ -244,29 +270,6 @@ public static Set findPossibleBaseURL(List urls) { return baseURLs; } - public static List cleanUrls(List urls) { - - urls = TextUtils.deduplicate(urls); - Iterator it = urls.iterator(); - while (it.hasNext()) { - String urlItem = it.next(); - if (UrlUtils.uselessExtension(urlItem)) { - it.remove(); - } - if (blackPath.contains(urlItem)) { - it.remove(); - } - try { - String host = new URL(urlItem).getHost(); - if (Arrays.asList(blackHostList).contains(host)) { - it.remove(); - } - } catch (Exception E) { - continue; - } - } - return urls; - } public static String choseAndEditBaseURL(Set inputs) { diff --git a/src/messageTab/Info/InfoTab.java b/src/messageTab/Info/InfoTab.java index 1113e68..deae3ce 100644 --- a/src/messageTab/Info/InfoTab.java +++ b/src/messageTab/Info/InfoTab.java @@ -1,17 +1,22 @@ package messageTab.Info; import java.awt.Component; +import java.util.List; import javax.swing.JPanel; import javax.swing.SwingWorker; import com.bit4woo.utilbox.utils.ByteArrayUtils; +import com.bit4woo.utilbox.utils.EmailUtils; +import com.bit4woo.utilbox.utils.TextUtils; +import com.bit4woo.utilbox.utils.UrlUtils; import burp.BurpExtender; import burp.IBurpExtenderCallbacks; import burp.IExtensionHelpers; import burp.IMessageEditorController; import burp.IMessageEditorTab; +import knife.FindUrlAndRequest; /** * @author bit4woo @@ -59,18 +64,34 @@ public boolean isEnabled(byte[] content, boolean isRequest) * 每次切换到这个tab,都会调用这个函数。应考虑避免重复劳动,根据originContent是否变化来判断。 */ @Override - public void setMessage(byte[] content, boolean isRequest) - { - if (ByteArrayUtils.equals(originContent,content)) { + public void setMessage(byte[] content, boolean isRequest){ + if (content ==null || content.length ==0) { + return; + }else if (ByteArrayUtils.equals(originContent,content)) { return; }else { originContent = content; SwingWorker worker = new SwingWorker() { @Override protected Void doInBackground() throws Exception { - originContent = content; - InfoEntry aaa = new InfoEntry("http://www.baidu.com",InfoEntry.Type_URL); - ((InfoPanel)panel).getTable().getInfoTableModel().addNewInfoEntry(aaa); + String text = new String(content); + text = TextUtils.decodeAll(text); + + List urls = UrlUtils.grepUrlsWithProtocol(text); + urls.addAll(UrlUtils.grepUrlsInQuotes(text)); + urls.addAll(UrlUtils.grepUrlPathNotStartWithSlashInQuotes(text)); + urls = FindUrlAndRequest.cleanUrls(urls); + for (String url:urls) { + InfoEntry aaa = new InfoEntry(url,InfoEntry.Type_URL); + ((InfoPanel)panel).getTable().getInfoTableModel().addNewInfoEntry(aaa); + } + + List emails = EmailUtils.grepEmail(text); + for (String email:emails) { + InfoEntry aaa = new InfoEntry(email,InfoEntry.Type_Email); + ((InfoPanel)panel).getTable().getInfoTableModel().addNewInfoEntry(aaa); + } + return null; } }; diff --git a/src/messageTab/Info/InfoTable.java b/src/messageTab/Info/InfoTable.java index fdcf6a0..aad4790 100644 --- a/src/messageTab/Info/InfoTable.java +++ b/src/messageTab/Info/InfoTable.java @@ -65,6 +65,10 @@ public int[] getSelectedModelRows() { Arrays.sort(rows);//升序 return rows; } + + public InfoEntry getEntryAt(int row) { + return ((InfoTableModel) this.getModel()).getEntryAt(convertRowIndexToModel(row)); + } private void addClickSort() { TableRowSorter sorter = new TableRowSorter<>((InfoTableModel) this.getModel()); @@ -113,19 +117,18 @@ public void mouseClicked(MouseEvent e) { InfoTable target = (InfoTable) e.getSource(); int row = target.getSelectedRow(); int column = target.getSelectedColumn(); - if (titles[column].equals("Enable")) { - boolean value = (boolean) getValueAt(row, column); - setValueAt(!value, row, column); - } + //双击浏览器打开url if (headers[column].equalsIgnoreCase("Value")) {//双击url在浏览器中打开 try { - String url = (String) getValueAt(row, column); - if (url != null && !url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://")) { - url = "http://" + url;//针对DNS记录中URL字段是host的情况 - } - String browserPath = BurpExtender.getConfigTableModel().getConfigValueByKey("browserPath"); - SystemUtils.browserOpen(url, browserPath); + InfoEntry entry = getEntryAt(row); + if (entry.getType().equals(InfoEntry.Type_URL)) { + String url = (String) getValueAt(row, column); + if (url.toLowerCase().startsWith("http://") || url.toLowerCase().startsWith("https://")) { + String browserPath = BurpExtender.getConfigTableModel().getConfigValueByKey("browserPath"); + SystemUtils.browserOpen(url, browserPath); + } + } } catch (Exception e1) { e1.printStackTrace(BurpExtender.getStderr()); } diff --git a/src/messageTab/Info/InfoTableModel.java b/src/messageTab/Info/InfoTableModel.java index c6ec0f8..799aa7b 100644 --- a/src/messageTab/Info/InfoTableModel.java +++ b/src/messageTab/Info/InfoTableModel.java @@ -60,6 +60,11 @@ public String getColumnName(int columnIndex) { public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } + + public InfoEntry getEntryAt(int rowIndex) + { + return infoEntries.get(rowIndex); + } @Override public Object getValueAt(int rowIndex, int columnIndex)