Skip to content

Commit

Permalink
项目菜单显示db文件名
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Jul 25, 2024
1 parent 710f1a2 commit e47c042
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 49 deletions.
3 changes: 2 additions & 1 deletion src/Tools/ToolPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import GUI.GUIMain;
import base.BackGroundButton;
import burp.BurpExtender;
import burp.ProjectMenu;
import config.ConfigManager;
import config.ConfigName;
import domain.CertInfo;
Expand Down Expand Up @@ -1432,7 +1433,7 @@ protected void action() {
@Override
protected void action() {
try {
outputTextArea.setText(WebIcon.getHash(inputTextArea.getText(), null));
outputTextArea.setText(ProjectMenu.listLoadedExtensions());
} catch (Exception e1) {
outputTextArea.setText(e1.getMessage());
e1.printStackTrace(stderr);
Expand Down
4 changes: 1 addition & 3 deletions src/burp/LineEntryMenuForBurp.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ public List<JMenuItem> createMenuItemsForBurp(IContextMenuInvocation invocation)

JMenuItem sendToToolPanel = new JMenuItem("^_^ Send To Tool Panel");
sendToToolPanel.addActionListener(new sendToToolPanel(invocation));





JMenuItemList.add(setAsChecked);
JMenuItemList.add(setLevelAs2);
Expand Down
76 changes: 35 additions & 41 deletions src/burp/ProjectMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;

import org.apache.commons.lang3.StringUtils;

import GUI.GUIMain;
import base.DictFileReader;
import base.dbFileChooser;
Expand Down Expand Up @@ -225,6 +227,7 @@ public void openDb() {
if (null != file) {
BurpExtender.getDataLoadManager().loadDbfileToHunter(file.toString());
}

}


Expand Down Expand Up @@ -259,19 +262,49 @@ public void Add() {
}
}


public void remove(){
JMenuBar menuBar = getBurpFrame().getJMenuBar();
if (menuBar != null){
menuBar.remove(this);
menuBar.repaint();
}
}


@Deprecated
public static String listLoadedExtensions() {
// 获取已加载的扩展列表。这个函数无法导出用户配置
String configJson = BurpExtender.getCallbacks().saveConfigAsJson("user_options.extender.extensions");

System.out.println(configJson);
return configJson;
}


/**
* 当换了db数据库时,重新加载
* @param newName
*/
public void displayDBNameAtProjectMenu(String name){
remove();
String barName = "DomainHunter";
if (StringUtils.isNotBlank(name)) {
if (name.length() <=8) {
barName = barName+"("+name+")";
}else {
barName = barName+"("+name.substring(0,5)+"...)";
}
}
this.setText(barName);
Add();
}

/**
* 最上面的项目菜单中显示项目名称
* @param name
*/
public void AddDBNameMenuItem(String name){
public void displayDBNameAtProjectMenuItem(String name){
if (null==name) return;
String firstName = this.getItem(0).getName();
if (firstName != null && firstName.equals("JustDisplayDBFileName")){
Expand All @@ -287,52 +320,13 @@ public void AddDBNameMenuItem(String name){
* Domain Panel显示项目名称
* @param name
*/
public void AddDBNameTab(String name){
public void displayDBNameAtDomainTab(String name){
if (null == name) return;
JTabbedPane panel = ((JTabbedPane)gui.getContentPane());
String newName = String.format("domain [%s]",name);
panel.setTitleAt(0,newName);
}

//修改之后不刷新,弃用
@Deprecated
public void changeTabName(String dbFileName){
Container ccc = getBurpFrame().getContentPane();
JTabbedPane ParentOfDomainHunter = (JTabbedPane) ccc.getComponent(0);//burpTabBar
int n = ParentOfDomainHunter.getComponentCount();

//find index of current DomainHunter
for (int i=n-1;i>=0;i--){
Component tmp = ParentOfDomainHunter.getComponent(i);
if (tmp.getName().equals("DomainHunterPro")){
ParentOfDomainHunter.setTitleAt(i,"xxxxx");//似乎burp不会刷新这个title的显示。

String tmpDbFile = BurpExtender.getDataLoadManager().getCurrentDBFile().getName();
if (tmpDbFile.equals(dbFileName)){
ParentOfDomainHunter.setTitleAt(i,tmpDbFile);
}
}//domain.DomainPanel
}
}

public int indexOfDomainHunter(String dbFileName){
Container ccc = getBurpFrame().getContentPane();
JTabbedPane ParentOfDomainHunter = (JTabbedPane) ccc.getComponent(0);//burpTabBar
int n = ParentOfDomainHunter.getComponentCount();

//find index of current DomainHunter
for (int i=n-1;i>=0;i--){//倒序查找更快
Component tmp = ParentOfDomainHunter.getComponent(i);
if (tmp.getName().equals("DomainHunterPro")){
String tmpDbFile = BurpExtender.getDataLoadManager().getCurrentDBFile().getName();
if (tmpDbFile.equals(dbFileName)){
return i;
}
}
}
return -1;
}

/**
* DomainHunter*表示locked
* DomainHunter表示unlocked
Expand Down
8 changes: 4 additions & 4 deletions src/config/DataLoadManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ public void displayProjectName() {
String newName = String.format(BurpExtender.getExtenderName()+" [%s]",name);

BurpExtender.getCallbacks().setExtensionName(newName); //新插件名称
gui.getProjectMenu().AddDBNameMenuItem(name);
gui.getProjectMenu().AddDBNameTab(name);
//gui.repaint();//NO need


gui.getProjectMenu().displayDBNameAtProjectMenu(name);
gui.getProjectMenu().displayDBNameAtProjectMenuItem(name);
gui.getProjectMenu().displayDBNameAtDomainTab(name);
}
}

Expand Down

0 comments on commit e47c042

Please sign in to comment.