Skip to content

Commit

Permalink
fix bug #19
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Dec 22, 2023
1 parent 8f21a33 commit 91e5d8b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 41 deletions.
49 changes: 24 additions & 25 deletions src/PoC/LineEntryMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;

import GUI.MainGUI;
import burp.BurpExtender;
import burp.Commons;
import run.RunNucleiAction;
Expand Down Expand Up @@ -57,7 +56,7 @@ public void actionPerformed(ActionEvent actionEvent) {
if (rows.length >=50) {
return;
}
LineEntry selecteEntry = lineTable.getModel().getLineEntries().getValueAtIndex(rows[0]);
LineEntry selecteEntry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(rows[0]);
String path = selecteEntry.getPocFileFullPath();
Commons.editWithVSCode(path);
}
Expand All @@ -70,7 +69,7 @@ public void actionPerformed(ActionEvent e) {
try {
//JOptionPane.showMessageDialog(null,"Not found editor(code.exe idle.bat) in environment.");
if (rows != null && rows.length >=0){
LineEntry entry = lineTable.getModel().getLineEntries().getValueAtIndex(rows[0]);
LineEntry entry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(rows[0]);
String path = entry.getPocFileFullPath();
String dir = new File(path).getParent();
Commons.OpenFolder(dir);
Expand All @@ -90,7 +89,7 @@ public void actionPerformed(ActionEvent actionEvent) {
}
List<String> paths = new ArrayList<String>();
for (int row:rows) {
LineEntry entry = lineTable.getModel().getLineEntries().getValueAtIndex(row);
LineEntry entry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(row);
String path = entry.getPocFileFullPath();
paths.add(path);
}
Expand All @@ -101,21 +100,21 @@ public void actionPerformed(ActionEvent actionEvent) {

}
});


/**
* nuclei -u 127.0.0.1
*/
JMenuItem genAllPoCCmd = new JMenuItem(new AbstractAction("Generate Command For All PoC") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
LineEntry entry = lineTable.getModel().getLineEntries().getValueAtIndex(rows[0]);
LineEntry entry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(rows[0]);
String path = entry.getPocFileFullPath();
List<String> targets = Commons.getLinesFromTextArea(PoCPanel.getTitleTable().getTextAreaTarget());

String Command = RunNucleiAction.genCommandRunAll(targets);
Commons.writeToClipboard(Command.trim());

}
});

Expand All @@ -125,35 +124,35 @@ public void actionPerformed(ActionEvent actionEvent) {
JMenuItem runAllPoC = new JMenuItem(new AbstractAction("Run All PoC") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
LineEntry entry = lineTable.getModel().getLineEntries().getValueAtIndex(rows[0]);
LineEntry entry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(rows[0]);
String path = entry.getPocFileFullPath();
List<String> targets = Commons.getLinesFromTextArea(PoCPanel.getTitleTable().getTextAreaTarget());
String Command = RunNucleiAction.genCommandRunAll(targets);

RunNucleiAction.run(Command);
}
});





/**
* nuclei -u 127.0.0.1 -t CVE-2020-3580.yaml
*/
JMenuItem genSinglePoCCmd = new JMenuItem(new AbstractAction("Generate Command Of This PoC") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
LineEntry entry = lineTable.getModel().getLineEntries().getValueAtIndex(rows[0]);
LineEntry entry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(rows[0]);
String path = entry.getPocFileFullPath();
List<String> targets = Commons.getLinesFromTextArea(PoCPanel.getTitleTable().getTextAreaTarget());

String Command;
if (entry.isWorkflow()) {
Command = RunNucleiAction.genWorkflowCommand(targets, path);
}else {
Command = RunNucleiAction.genCommand(targets, path);
}
Commons.writeToClipboard(Command.trim());

}
});

Expand All @@ -163,7 +162,7 @@ public void actionPerformed(ActionEvent actionEvent) {
JMenuItem runSinglePoC = new JMenuItem(new AbstractAction("Run This PoC") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
LineEntry entry = lineTable.getModel().getLineEntries().getValueAtIndex(rows[0]);
LineEntry entry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(rows[0]);
String path = entry.getPocFileFullPath();
List<String> targets = Commons.getLinesFromTextArea(PoCPanel.getTitleTable().getTextAreaTarget());
String Command;
Expand All @@ -172,48 +171,48 @@ public void actionPerformed(ActionEvent actionEvent) {
}else {
Command = RunNucleiAction.genCommand(targets, path);
}

RunNucleiAction.run(Command);
}
});

/**
*
* nuclei -u 127.0.0.1 -tags cisco
*/
JMenuItem genCmdWithTags = new JMenuItem(new AbstractAction("Generate Command With Tags") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
LineEntry entry = lineTable.getModel().getLineEntries().getValueAtIndex(rows[0]);
LineEntry entry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(rows[0]);
String tags = entry.getTags();
tags = getTags(tags);
List<String> targets = Commons.getLinesFromTextArea(PoCPanel.getTitleTable().getTextAreaTarget());
String Command = RunNucleiAction.genTagsCommand(targets, tags);
Commons.writeToClipboard(Command.trim());
}

public String getTags(String tags) {
String resulttags = JOptionPane.showInputDialog("tags to use", tags).trim();
return resulttags;
}
});

/**
*
* nuclei -u 127.0.0.1 -tags cisco
*/
JMenuItem runMultipluePoC = new JMenuItem(new AbstractAction("Run PoCs With Tags") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
LineEntry entry = lineTable.getModel().getLineEntries().getValueAtIndex(rows[0]);
LineEntry entry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(rows[0]);
String tags = entry.getTags();
tags = getTags(tags);
List<String> targets = Commons.getLinesFromTextArea(PoCPanel.getTitleTable().getTextAreaTarget());
String Command = RunNucleiAction.genTagsCommand(targets, tags);

RunNucleiAction.run(Command);
}

public String getTags(String tags) {
String resulttags = JOptionPane.showInputDialog("tags to use", tags).trim();
return resulttags;
Expand Down
28 changes: 12 additions & 16 deletions src/PoC/LineTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class LineTable extends JTable
*
*/
private static final long serialVersionUID = 1L;
private LineTableModel lineTableModel;
private TableRowSorter<LineTableModel> rowSorter;//TableRowSorter vs. RowSorter

PrintWriter stdout;
Expand Down Expand Up @@ -90,7 +89,6 @@ public LineTable(LineTableModel lineTableModel)
stderr = new PrintWriter(System.out, true);
}

this.lineTableModel = lineTableModel;
this.setFillsViewportHeight(true);//在table的空白区域显示右键菜单
//https://stackoverflow.com/questions/8903040/right-click-mouselistener-on-whole-jtable-component
this.setModel(lineTableModel);
Expand All @@ -103,24 +101,22 @@ public LineTable(LineTableModel lineTableModel)
tableAndDetailSplitPane = tableAndDetailPanel();
}

public LineTableModel getLineTabelModel() {
return (LineTableModel)this.getModel();
}

@Override
public void changeSelection(int row, int col, boolean toggle, boolean extend)
{
// show the log entry for the selected row
LineEntry Entry = this.lineTableModel.getLineEntries().getValueAtIndex(super.convertRowIndexToModel(row));
LineEntry Entry = getLineTabelModel().getLineEntries().getValueAtIndex(super.convertRowIndexToModel(row));

this.lineTableModel.setCurrentlyDisplayedItem(Entry);
getLineTabelModel().setCurrentlyDisplayedItem(Entry);
String detail = Entry.getDetail();
textAreaPoCDetail.setText(detail);
super.changeSelection(row, col, toggle, extend);
}

@Override
public LineTableModel getModel(){
//return (LineTableModel) super.getModel();
return lineTableModel;
}


public JSplitPane tableAndDetailPanel(){
JSplitPane splitPane = new JSplitPane();//table area + detail area
Expand Down Expand Up @@ -151,7 +147,7 @@ public JSplitPane tableAndDetailPanel(){
if (config != null) {
textAreaTarget.getDocument().addDocumentListener(new textAreaDocumentListener(textAreaTarget,config));
}


JTabbedPane ResponsePanel = new JTabbedPane();
RequestDetailPanel.setRightComponent(ResponsePanel);
Expand Down Expand Up @@ -193,7 +189,7 @@ public void tableinit(){

public void addClickSort() {//双击header头进行排序

rowSorter = new TableRowSorter<LineTableModel>(lineTableModel);//排序和搜索
rowSorter = new TableRowSorter<LineTableModel>(getLineTabelModel());//排序和搜索
LineTable.this.setRowSorter(rowSorter);

JTableHeader header = this.getTableHeader();
Expand All @@ -213,14 +209,14 @@ public void mouseClicked(MouseEvent e) {
//搜索功能函数
public void search(String Input) {
History.getInstance().addRecord(Input);//记录搜索历史,单例模式

final RowFilter filter = new RowFilter() {
@Override
public boolean include(Entry entry) {
//entry --- a non-null object that wraps the underlying object from the model
int row = (int) entry.getIdentifier();
LineEntry line = rowSorter.getModel().getLineEntries().getValueAtIndex(row);

//目前只处理&&(and)逻辑的表达式
if (Input.contains("&&")) {
String[] searchConditions = Input.split("&&");
Expand Down Expand Up @@ -257,7 +253,7 @@ public void mouseClicked(MouseEvent e) {
//int row = ((LineTable) e.getSource()).rowAtPoint(e.getPoint()); // 获得行位置
int col = ((LineTable) e.getSource()).columnAtPoint(e.getPoint()); // 获得列位置

LineEntry selecteEntry = LineTable.this.lineTableModel.getLineEntries().getValueAtIndex(rows[0]);
LineEntry selecteEntry = LineTable.this.getLineTabelModel().getLineEntries().getValueAtIndex(rows[0]);
if (col==0) {//双击Index 搜索CVE字段
String cve = selecteEntry.getCVE();
String url= "https://www.google.com/search?q="+cve;
Expand All @@ -274,7 +270,7 @@ public void mouseClicked(MouseEvent e) {
String path = selecteEntry.getPocFileFullPath();
Commons.editWithVSCode(path);
}else{
String value = LineTable.this.lineTableModel.getValueAt(rows[0],col).toString();
String value = LineTable.this.getLineTabelModel().getValueAt(rows[0],col).toString();
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection selection = new StringSelection(value);
clipboard.setContents(selection, null);
Expand Down

0 comments on commit 91e5d8b

Please sign in to comment.