Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed May 15, 2024
1 parent 82a97e8 commit 0a28498
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 48 deletions.
67 changes: 35 additions & 32 deletions src/knife/FindUrlAndRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,46 @@ 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<String> 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) {
this.setText("^_^ Find URL And Request");
this.addActionListener(new FindUrl_Action(burp, burp.invocation));
}


public static List<String> cleanUrls(List<String> urls) {

urls = TextUtils.deduplicate(urls);
Iterator<String> 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("./")) {
Expand All @@ -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<String> blackPath = TextUtils.textToLines("text/css\r\n"
+ " text/html\r\n"
+ " text/plain\r\n"
+ " image/pdf\r\n");


private static Proxy proxy;

Expand Down Expand Up @@ -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));
}
}
Expand Down Expand Up @@ -244,29 +270,6 @@ public static Set<String> findPossibleBaseURL(List<String> urls) {
return baseURLs;
}

public static List<String> cleanUrls(List<String> urls) {

urls = TextUtils.deduplicate(urls);
Iterator<String> 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<String> inputs) {
Expand Down
33 changes: 27 additions & 6 deletions src/messageTab/Info/InfoTab.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<Void, Void> worker = new SwingWorker<Void, Void>() {
@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<String> 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<String> emails = EmailUtils.grepEmail(text);
for (String email:emails) {
InfoEntry aaa = new InfoEntry(email,InfoEntry.Type_Email);
((InfoPanel)panel).getTable().getInfoTableModel().addNewInfoEntry(aaa);
}

return null;
}
};
Expand Down
23 changes: 13 additions & 10 deletions src/messageTab/Info/InfoTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<InfoTableModel> sorter = new TableRowSorter<>((InfoTableModel) this.getModel());
Expand Down Expand Up @@ -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());
}
Expand Down
5 changes: 5 additions & 0 deletions src/messageTab/Info/InfoTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0a28498

Please sign in to comment.