Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Aug 9, 2024
1 parent 2aa8855 commit 2644739
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 68 deletions.
20 changes: 15 additions & 5 deletions src/InternetSearch/SearchResultEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import burp.BurpExtender;
import domain.DomainManager;
import domain.target.TargetTableModel;

public class SearchResultEntry {
private int port = -1;
Expand Down Expand Up @@ -220,7 +221,7 @@ public String getTitle() {
public void setTitle(String title) {
this.title = title;
}

public void AddToTarget(String trustLevel,String commentToAdd) {
DomainManager domainResult = BurpExtender.getGui().getDomainPanel().getDomainResult();
if (IPAddressUtils.isValidIPv4NoPort(this.host)) {
Expand All @@ -231,14 +232,23 @@ public void AddToTarget(String trustLevel,String commentToAdd) {
}

if (DomainUtils.isValidDomainMayPort(this.host)) {
domainResult.addToTargetAndSubDomain(this.host,true,commentToAdd);
domainResult.addToTargetAndSubDomain(this.host,true,trustLevel,commentToAdd);
}
}

public void RemoveFromTarget() {
if (IPAddressUtils.isValidIPv4NoPort(this.host)) {
DomainManager domainResult = BurpExtender.getGui().getDomainPanel().getDomainResult();

domainResult.getSpecialPortTargets().remove(this.host);
if (this.port >=0 && this.port <= 65535) {
domainResult.addToTargetAndSubDomain(this.host+":"+this.port,true,trustLevel,commentToAdd);
domainResult.getSpecialPortTargets().remove(this.host+":"+this.port);
}
}

if (StringUtils.isEmpty(this.rootDomain)) {
domainResult.addToTargetAndSubDomain(this.rootDomain,true,trustLevel,commentToAdd);
if (DomainUtils.isValidDomainMayPort(this.rootDomain)) {
TargetTableModel targetModel = BurpExtender.getGui().getDomainPanel().fetchTargetModel();
targetModel.removeRow(this.host);
}
}

Expand Down
151 changes: 89 additions & 62 deletions src/InternetSearch/SearchResultEntryMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ public class SearchResultEntryMenu extends JPopupMenu {

/**
* 这处理传入的行index数据是经过转换的 model中的index,不是原始的JTable中的index。
*
* @param lineTable
* @param modelRows
* @param columnIndex
*/
SearchResultEntryMenu(final GUIMain guiMain, SearchTable searchTable,final int[] modelRows,final int columnIndex){
SearchResultEntryMenu(final GUIMain guiMain, SearchTable searchTable, final int[] modelRows, final int columnIndex) {
this.guiMain = guiMain;
this.searchTable = searchTable;
this.searchTableModel = searchTable.getSearchTableModel();

JMenuItem itemNumber = new JMenuItem(new AbstractAction(modelRows.length+" Items Selected") {
JMenuItem itemNumber = new JMenuItem(new AbstractAction(modelRows.length + " Items Selected") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
}
Expand All @@ -55,13 +56,11 @@ public void actionPerformed(ActionEvent actionEvent) {
JMenuItem copyUrlItem = new JMenuItem(new AbstractAction("Copy URL") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
try{
java.util.List<String> urls = searchTableModel.getMultipleValue(modelRows,"URL");
try {
java.util.List<String> urls = searchTableModel.getMultipleValue(modelRows, "URL");
String textUrls = String.join(System.lineSeparator(), urls);
SystemUtils.writeToClipboard(textUrls);
}
catch (Exception e1)
{
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
}
Expand All @@ -70,13 +69,11 @@ public void actionPerformed(ActionEvent actionEvent) {
JMenuItem copyHostItem = new JMenuItem(new AbstractAction("Copy Host") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
try{
java.util.List<String> urls = searchTableModel.getMultipleValue(modelRows,"Host");
try {
java.util.List<String> urls = searchTableModel.getMultipleValue(modelRows, "Host");
String textUrls = String.join(System.lineSeparator(), urls);
SystemUtils.writeToClipboard(textUrls);
}
catch (Exception e1)
{
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
}
Expand All @@ -85,13 +82,11 @@ public void actionPerformed(ActionEvent actionEvent) {
JMenuItem copyIPItem = new JMenuItem(new AbstractAction("Copy IP") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
try{
java.util.List<String> ip_list = searchTableModel.getMultipleValue(modelRows,"IP");
try {
java.util.List<String> ip_list = searchTableModel.getMultipleValue(modelRows, "IP");
String textUrls = String.join(System.lineSeparator(), ip_list);
SystemUtils.writeToClipboard(textUrls);
}
catch (Exception e1)
{
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
}
Expand All @@ -100,14 +95,12 @@ public void actionPerformed(ActionEvent actionEvent) {
JMenuItem copyRootDomainItem = new JMenuItem(new AbstractAction("Copy Root Domain") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
try{
java.util.List<String> rootDomains = searchTableModel.getMultipleValue(modelRows,SearchTableHead.RootDomain);
try {
java.util.List<String> rootDomains = searchTableModel.getMultipleValue(modelRows, SearchTableHead.RootDomain);
rootDomains = TextUtils.deduplicate(rootDomains);
String textUrls = String.join(System.lineSeparator(), rootDomains);
SystemUtils.writeToClipboard(textUrls);
}
catch (Exception e1)
{
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
}
Expand All @@ -117,13 +110,11 @@ public void actionPerformed(ActionEvent actionEvent) {

@Override
public void actionPerformed(ActionEvent e) {
try{
java.util.List<String> ip_list = searchTableModel.getMultipleValue(modelRows,"IP");
try {
java.util.List<String> ip_list = searchTableModel.getMultipleValue(modelRows, "IP");
String nmapPath = ConfigManager.getStringConfigByKey(ConfigName.PortScanCmd);
PortScanUtils.genCmdAndCopy(nmapPath, new HashSet<>(ip_list));
}
catch (Exception e1)
{
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
}
Expand All @@ -133,17 +124,15 @@ public void actionPerformed(ActionEvent e) {
JMenuItem openURLwithBrowserItem = new JMenuItem(new AbstractAction("Open With Browser(double click url)") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
try{
java.util.List<String> urls = searchTableModel.getMultipleValue(modelRows,"URL");
if (urls.size() >= 50){//避免一次开太多网页导致系统卡死
try {
java.util.List<String> urls = searchTableModel.getMultipleValue(modelRows, "URL");
if (urls.size() >= 50) {//避免一次开太多网页导致系统卡死
return;
}
for (String url:urls){
SystemUtils.browserOpen(url,ConfigManager.getStringConfigByKey(ConfigName.BrowserPath));
for (String url : urls) {
SystemUtils.browserOpen(url, ConfigManager.getStringConfigByKey(ConfigName.BrowserPath));
}
}
catch (Exception e1)
{
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
}
Expand All @@ -152,18 +141,16 @@ public void actionPerformed(ActionEvent actionEvent) {
JMenuItem addToTargetItem = new JMenuItem(new AbstractAction("Add Host/Domain To Target") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
new SwingWorker(){
new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
try{
try {
List<SearchResultEntry> entries = searchTableModel.getEntries(modelRows);
for (SearchResultEntry entry:entries) {
entry.AddToTarget(null,null);
for (SearchResultEntry entry : entries) {
entry.AddToTarget(null, null);
}
guiMain.getDomainPanel().saveDomainDataToDB();
}
catch (Exception e1)
{
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
return null;
Expand All @@ -175,18 +162,16 @@ protected Object doInBackground() throws Exception {
JMenuItem addToTargetConfirmItem = new JMenuItem(new AbstractAction("Add Host/Domain To Target (Confirm Level)") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
new SwingWorker(){
new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
try{
try {
List<SearchResultEntry> entries = searchTableModel.getEntries(modelRows);
for (SearchResultEntry entry:entries) {
entry.AddToTarget(AssetTrustLevel.Confirm,null);
for (SearchResultEntry entry : entries) {
entry.AddToTarget(AssetTrustLevel.Confirm, null);
}
guiMain.getDomainPanel().saveDomainDataToDB();
}
catch (Exception e1)
{
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
return null;
Expand All @@ -198,22 +183,62 @@ protected Object doInBackground() throws Exception {
JMenuItem addToTargetWithCommentItem = new JMenuItem(new AbstractAction("Add Host/Domain To Target With Comment") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
new SwingWorker(){
new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
try{
try {
String comment = JOptionPane.showInputDialog("Comment", "");
if (StringUtils.isBlank(comment)) {
return null;
}
List<SearchResultEntry> entries = searchTableModel.getEntries(modelRows);
for (SearchResultEntry entry:entries) {
entry.AddToTarget(null,comment);
for (SearchResultEntry entry : entries) {
entry.AddToTarget(null, comment);
}
guiMain.getDomainPanel().saveDomainDataToDB();
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
return null;
}
}.execute();
}
});

JMenuItem addToTargetnotTargetItem = new JMenuItem(new AbstractAction("Add Host/Domain To Target (Not Target)") {
@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.NonTarget, null);
}
guiMain.getDomainPanel().saveDomainDataToDB();
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
catch (Exception e1)
{
return null;
}
}.execute();
}
});

JMenuItem deleteFromTarget = new JMenuItem(new AbstractAction("Delete From Target") {
@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.RemoveFromTarget();
}
guiMain.getDomainPanel().saveDomainDataToDB();
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
return null;
Expand All @@ -226,20 +251,18 @@ protected Object doInBackground() throws Exception {
JMenuItem addIPToBlackListItem = new JMenuItem(new AbstractAction("Add IP To Black List") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
new SwingWorker(){
new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
try{
try {
List<SearchResultEntry> entries = searchTableModel.getEntries(modelRows);
Set<String> blackIPSet = new HashSet<String>();
for (SearchResultEntry entry:entries) {
for (SearchResultEntry entry : entries) {
blackIPSet.addAll(entry.getIPSet());
}
guiMain.getDomainPanel().getDomainResult().getNotTargetIPSet().addAll(blackIPSet);
guiMain.getDomainPanel().saveDomainDataToDB();
}
catch (Exception e1)
{
} catch (Exception e1) {
e1.printStackTrace(stderr);
}
return null;
Expand All @@ -256,6 +279,10 @@ protected Object doInBackground() throws Exception {
this.add(addToTargetItem);
this.add(addToTargetConfirmItem);
this.add(addToTargetWithCommentItem);

this.addSeparator();
this.add(addToTargetnotTargetItem);
this.add(deleteFromTarget);
this.add(addIPToBlackListItem);

this.addSeparator();
Expand All @@ -269,7 +296,7 @@ protected Object doInBackground() throws Exception {


this.addSeparator();
SearchEngine.AddSearchMenuItems(this,searchTableModel,modelRows,columnIndex);
SearchEngine.AddSearchMenuItems(this, searchTableModel, modelRows, columnIndex);
this.addSeparator();

}
Expand Down
2 changes: 1 addition & 1 deletion src/domain/target/TargetEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public TargetEntry(String input) {

public TargetEntry(String input,boolean autoSub,String trustLevel,String comment) {
this(input,autoSub);
if (AssetTrustLevel.getLevelList().contains(trustLevel)) {
if (AssetTrustLevel.getLevelList().contains(trustLevel) && !this.trustLevel.equals(AssetTrustLevel.Cloud)) {
this.setTrustLevel(trustLevel);
}else {
//已经有默认初始值了,无需再设置
Expand Down

0 comments on commit 2644739

Please sign in to comment.