diff --git a/src/InternetSearch/SearchResultEntry.java b/src/InternetSearch/SearchResultEntry.java index 87e71911..7b809af0 100644 --- a/src/InternetSearch/SearchResultEntry.java +++ b/src/InternetSearch/SearchResultEntry.java @@ -220,8 +220,11 @@ public String getTitle() { public void setTitle(String title) { this.title = title; } - public void AddToTarget() { + AddToTarget(null); + } + + public void AddToTarget(String trustLevel) { DomainManager domainResult = BurpExtender.getGui().getDomainPanel().getDomainResult(); if (IPAddressUtils.isValidIPv4NoPort(this.host)) { domainResult.getSpecialPortTargets().add(this.host); @@ -233,12 +236,12 @@ public void AddToTarget() { if (DomainUtils.isValidDomainMayPort(this.host)) { domainResult.addToTargetAndSubDomain(this.host,true); if (this.port >=0 && this.port <= 65535) { - domainResult.addToTargetAndSubDomain(this.host+":"+this.port,true); + domainResult.addToTargetAndSubDomain(this.host+":"+this.port,true,trustLevel); } } if (StringUtils.isEmpty(this.rootDomain)) { - domainResult.addToTargetAndSubDomain(this.rootDomain,true); + domainResult.addToTargetAndSubDomain(this.rootDomain,true,trustLevel); } } diff --git a/src/InternetSearch/SearchResultEntryMenu.java b/src/InternetSearch/SearchResultEntryMenu.java index ebf0e5e7..4ea2a582 100644 --- a/src/InternetSearch/SearchResultEntryMenu.java +++ b/src/InternetSearch/SearchResultEntryMenu.java @@ -17,6 +17,7 @@ import burp.BurpExtender; import config.ConfigManager; import config.ConfigName; +import domain.target.AssetTrustLevel; import utils.PortScanUtils; public class SearchResultEntryMenu extends JPopupMenu { @@ -164,7 +165,29 @@ protected Object doInBackground() throws Exception { return null; } }.execute(); - + } + }); + + JMenuItem addToTargetConfirmItem = new JMenuItem(new AbstractAction("Add Host/Domain To Target (Confirm Level)") { + @Override + public void actionPerformed(ActionEvent actionEvent) { + new SwingWorker(){ + @Override + protected Object doInBackground() throws Exception { + try{ + List entries = searchTableModel.getEntries(modelRows); + for (SearchResultEntry entry:entries) { + entry.AddToTarget(AssetTrustLevel.Confirm); + } + guiMain.getDomainPanel().saveDomainDataToDB(); + } + catch (Exception e1) + { + e1.printStackTrace(stderr); + } + return null; + } + }.execute(); } }); @@ -174,6 +197,7 @@ protected Object doInBackground() throws Exception { //常用多选操作 this.add(addToTargetItem); + this.add(addToTargetConfirmItem); this.add(copyUrlItem); this.add(copyHostItem); this.add(copyIPItem); diff --git a/src/domain/DomainManager.java b/src/domain/DomainManager.java index 6ac5346d..5999250b 100644 --- a/src/domain/DomainManager.java +++ b/src/domain/DomainManager.java @@ -367,6 +367,18 @@ public boolean isTargetByCertInfo(Set certDomains) { } return false; } + /** + * 添加到目标,并且设置资产可信度级别 + * @param enteredRootDomain + * @param autoSub + * @param trustLevel + */ + public void addToTargetAndSubDomain(String enteredRootDomain, boolean autoSub,String trustLevel) { + if (enteredRootDomain == null) return; + if (guiMain.getDomainPanel().fetchTargetModel().addRowIfValid(new TargetEntry(enteredRootDomain, autoSub,trustLevel))) { + subDomainSet.add(enteredRootDomain); + }; + } public void addToTargetAndSubDomain(String enteredRootDomain, boolean autoSub) { if (enteredRootDomain == null) return; diff --git a/src/domain/target/TargetEntry.java b/src/domain/target/TargetEntry.java index c0430dbf..4a0bd5bb 100644 --- a/src/domain/target/TargetEntry.java +++ b/src/domain/target/TargetEntry.java @@ -52,6 +52,15 @@ public TargetEntry() { public TargetEntry(String input) { this(input,true); } + + public TargetEntry(String input,boolean autoSub,String trustLevel) { + this(input,autoSub); + if (AssetTrustLevel.getLevelList().contains(trustLevel)) { + this.setTrustLevel(trustLevel); + }else { + //已经有默认初始值了,无需再设置 + } + } public TargetEntry(String input,boolean autoSub) { diff --git a/src/domain/target/TargetTableModel.java b/src/domain/target/TargetTableModel.java index c0e8faea..54323287 100644 --- a/src/domain/target/TargetTableModel.java +++ b/src/domain/target/TargetTableModel.java @@ -250,7 +250,10 @@ private void addRow(String key, TargetEntry entry) { TargetEntry oldentry = targetEntries.get(key); if (oldentry != null) {//如果有旧的记录,就需要用旧的内容做修改 //entry.setBlack(oldentry.isBlack()); - entry.setTrustLevel(oldentry.getTrustLevel()); + if (entry.getTrustLevel().equals(AssetTrustLevel.Maybe)) { + //当新记录的类型是maybe,那么它是确信度最低的,使用旧值。否则使用新的值 + entry.setTrustLevel(oldentry.getTrustLevel()); + } entry.setComments(oldentry.getComments()); entry.setKeyword(oldentry.getKeyword()); }