Skip to content

Commit

Permalink
搜索结果添加为“确信”资产
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Jul 12, 2024
1 parent c21747a commit 4cd4498
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/InternetSearch/SearchResultEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}

Expand Down
26 changes: 25 additions & 1 deletion src/InternetSearch/SearchResultEntryMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<SearchResultEntry> entries = searchTableModel.getEntries(modelRows);
for (SearchResultEntry entry:entries) {
entry.AddToTarget(AssetTrustLevel.Confirm);
}
guiMain.getDomainPanel().saveDomainDataToDB();
}
catch (Exception e1)
{
e1.printStackTrace(stderr);
}
return null;
}
}.execute();
}
});

Expand All @@ -174,6 +197,7 @@ protected Object doInBackground() throws Exception {

//常用多选操作
this.add(addToTargetItem);
this.add(addToTargetConfirmItem);
this.add(copyUrlItem);
this.add(copyHostItem);
this.add(copyIPItem);
Expand Down
12 changes: 12 additions & 0 deletions src/domain/DomainManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ public boolean isTargetByCertInfo(Set<String> 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;
Expand Down
9 changes: 9 additions & 0 deletions src/domain/target/TargetEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
5 changes: 4 additions & 1 deletion src/domain/target/TargetTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 4cd4498

Please sign in to comment.