Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Jun 1, 2024
1 parent 05a68cc commit 396882f
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 185 deletions.
81 changes: 63 additions & 18 deletions src/GUI/OptionsPanel.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package GUI;

import java.awt.Color;
import java.awt.Desktop;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import burp.BurpExtender;

public class OptionsPanel extends JPanel {

private static JTextField nucleiTemplatesPath;
Expand All @@ -25,30 +31,69 @@ public static void setNucleiTemplatesPath(JTextField nucleiTemplatesPath) {


OptionsPanel(){
GridBagLayout gbl_fourFourthPanel = new GridBagLayout();
gbl_fourFourthPanel.columnWidths = new int[]{215, 215, 0};
gbl_fourFourthPanel.rowHeights = new int[]{27, 0, 0, 0, 27, 0, 0, 0, 0, 0, 27, 27, 27, 27, 0, 0, 0, 0};
gbl_fourFourthPanel.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
gbl_fourFourthPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
setLayout(gbl_fourFourthPanel);

JLabel lblNewLabel = new JLabel("nuclei-templates directory:");
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
gbc_lblNewLabel.fill = GridBagConstraints.BOTH;
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
gbc_lblNewLabel.gridx = 0;
gbc_lblNewLabel.gridy = 0;
add(lblNewLabel, gbc_lblNewLabel);


nucleiTemplatesPath = new JTextField();
GridBagConstraints gbc_BrowserPath = new GridBagConstraints();
gbc_BrowserPath.fill = GridBagConstraints.BOTH;
gbc_BrowserPath.insets = new Insets(0, 0, 5, 0);
gbc_BrowserPath.gridx = 1;
gbc_BrowserPath.gridy = 0;
add(nucleiTemplatesPath, gbc_BrowserPath);
nucleiTemplatesPath.setColumns(50);
nucleiTemplatesPath.getDocument().addDocumentListener(new TextFieldListener());


JButton buttonCreateFolder = new JButton("Create Folder");
buttonCreateFolder.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String folderPath = nucleiTemplatesPath.getText();
File folder = new File(folderPath);
if (!folder.exists()) {
// 创建文件夹
if (folder.mkdirs()) {
saveToConfigFromGUI();
}
}
}
});

JButton btOpenFolder = new JButton("Open Folder");
btOpenFolder.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
String folderPath = nucleiTemplatesPath.getText();
Desktop.getDesktop().open(new File(folderPath));
} catch (Exception Exception) {
Exception.printStackTrace(BurpExtender.getStderr());
}
}
});


GridBagLayout layout = new GridBagLayout();
setLayout(layout);

//查找提取类
int rowIndex = 0;
int cloumnIndex = 0;

add(lblNewLabel, new bagLayout(++rowIndex, ++cloumnIndex));
add(nucleiTemplatesPath, new bagLayout(rowIndex, ++cloumnIndex));

add(buttonCreateFolder, new bagLayout(++rowIndex, ++cloumnIndex));
add(btOpenFolder, new bagLayout(++rowIndex, ++cloumnIndex));
}

class bagLayout extends GridBagConstraints {
/**
* 采用普通的行列计数,从1开始
*
* @param row
* @param column
*/
bagLayout(int row, int column) {
this.fill = GridBagConstraints.BOTH;
this.insets = new Insets(0, 0, 5, 5);
this.gridx = column - 1;
this.gridy = row - 1;
}
}


Expand Down
19 changes: 14 additions & 5 deletions src/PoC/LineEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class LineEntry {

//{"#", "filename", "VulnApp", "VulnVersion", "VulnURL","VulnParameter","VulnType","VulnDescription","Refrence","isPoCVerified", "22","33"};
private String pocFileFullPath = ""; //PoC文件完整路径,用于定位文件进行编辑。不显示。
private String pocfile = ""; //PoC文件名称,用于显示
private String pocFileName = ""; //PoC文件名称,用于显示
private String pocName = ""; //PoC内容中info部分的name字段
private String VulnApp = ""; //存在漏的目标应用程序名称
private String VulnVersion = "";//存在漏洞的版本
private String VulnURL = "";//存在漏洞的URL地址
Expand Down Expand Up @@ -57,12 +58,20 @@ public void setPocFileFullPath(String pocFileFullPath) {
this.pocFileFullPath = pocFileFullPath;
}

public String getPocfile() {
return pocfile;
public String getPocFileName() {
return pocFileName;
}

public void setPocfile(String pocfile) {
this.pocfile = pocfile;
public void setPocFileName(String pocFileName) {
this.pocFileName = pocFileName;
}

public String getPocName() {
return pocName;
}

public void setPocName(String pocName) {
this.pocName = pocName;
}

public String getVulnApp() {
Expand Down
48 changes: 26 additions & 22 deletions src/PoC/LineEntryMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,25 @@ public void actionPerformed(ActionEvent actionEvent) {
}
});



/**
* nuclei -u 127.0.0.1 -t CVE-2020-3580.yaml
*/
JMenuItem genSinglePoCCmd = new JMenuItem(new AbstractAction("Generate Command Of This PoC") {
JMenuItem genSinglePoCCmd = new JMenuItem(new AbstractAction("Generate Command Of Selected PoC") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
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);
List<String> paths = new ArrayList<String>();
List<String> workflowPaths = new ArrayList<String>();
for (int row:rows) {
LineEntry entry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(row);
String path = entry.getPocFileFullPath();
if (entry.isWorkflow()) {
workflowPaths.add(path);
}else {
paths.add(path);
}
}
List<String> targets = Commons.getLinesFromTextArea(PoCPanel.getTitleTable().getTextAreaTarget());
String Command = RunNucleiAction.genSeletedPoCCommand(targets, paths,workflowPaths);
Commons.writeToClipboard(Command.trim());

}
Expand All @@ -160,19 +161,22 @@ public void actionPerformed(ActionEvent actionEvent) {
/**
* nuclei -u 127.0.0.1 -t CVE-2020-3580.yaml
*/
JMenuItem runSinglePoC = new JMenuItem(new AbstractAction("Run This PoC") {
JMenuItem runSinglePoC = new JMenuItem(new AbstractAction("Run Selected PoC") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
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);
List<String> paths = new ArrayList<String>();
List<String> workflowPaths = new ArrayList<String>();
for (int row:rows) {
LineEntry entry = lineTable.getLineTabelModel().getLineEntries().getValueAtIndex(row);
String path = entry.getPocFileFullPath();
if (entry.isWorkflow()) {
workflowPaths.add(path);
}else {
paths.add(path);
}
}

List<String> targets = Commons.getLinesFromTextArea(PoCPanel.getTitleTable().getTextAreaTarget());
String Command = RunNucleiAction.genSeletedPoCCommand(targets, paths,workflowPaths);
RunNucleiAction.run(Command);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/PoC/LineTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public void addNewLineEntry(LineEntry lineEntry){
}
synchronized (lineEntries) {
int oldsize = lineEntries.size();
String key = lineEntry.getPocfile();
String key = lineEntry.getPocFileName();
lineEntries.put(key,lineEntry);
int newsize = lineEntries.size();
int index = lineEntries.IndexOfKey(key);
Expand Down
68 changes: 52 additions & 16 deletions src/PoC/PoCPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
import java.io.PrintWriter;
import java.util.Base64;
import java.util.Collection;
import java.util.Map;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.SwingWorker;
import javax.swing.border.EmptyBorder;

import org.apache.commons.io.FileUtils;
Expand All @@ -26,7 +28,6 @@
import GUI.MainGUI;
import PoC.search.SearchTextField;
import PoCParser.NucleiParser;
import PoCParser.PoctParser;
import burp.BurpExtender;
import burp.Commons;
import burp.GlobalConfig;
Expand All @@ -49,7 +50,8 @@ public class PoCPanel extends JPanel {
private static JTextField textFieldSearch;
public static JRadioButton rdbtnUseRobotInput;
public static JLabel lblStatus;
public static JButton buttonFresh;
public static JButton buttonUpdate;
public static JButton buttonReload;

public static JTextField getTextFieldSearch() {
return textFieldSearch;
Expand Down Expand Up @@ -99,7 +101,8 @@ public PoCPanel(String poctRootPath) {//构造函数
* @param dir
* @return
*/
public IndexedLinkedHashMap<String,LineEntry> scanPoCFiles(String dir) {
@Deprecated
public IndexedLinkedHashMap<String,LineEntry> scanPoctFiles(String dir) {
IndexedLinkedHashMap<String,LineEntry> lineEntries = new IndexedLinkedHashMap<String,LineEntry>();
if (null==dir || !new File(dir).exists()){
return lineEntries;
Expand All @@ -108,14 +111,14 @@ public IndexedLinkedHashMap<String,LineEntry> scanPoCFiles(String dir) {
for (File file:files) {
//System.out.println(file.toString());
if (file.exists() && file.isFile() && !file.getName().startsWith("__")) {
LineEntry entry = PoctParser.Parser(file.toString());
lineEntries.put(file.toString(), entry);
//LineEntry entry = PoctParser.Parser(file.toString());
//lineEntries.put(file.toString(), entry);
}
}
return lineEntries;
}

/**
* 默认路径 /Users/bit4woo
* @param dir
* @return
*/
Expand Down Expand Up @@ -191,7 +194,7 @@ public void actionPerformed(ActionEvent e) {
try {
if (null != destFile) {
FileUtils.copyFile(srcFile, destFile);
PoCPanel.buttonFresh.doClick();
PoCPanel.buttonReload.doClick();
Commons.editWithVSCode(destFile.getAbsolutePath());
}
}catch (FileNotFoundException e1) {
Expand All @@ -200,7 +203,7 @@ public void actionPerformed(ActionEvent e) {
try {
if (null != destFile) {
FileUtils.writeByteArrayToFile(destFile,Base64.getDecoder().decode(content));
PoCPanel.buttonFresh.doClick();
PoCPanel.buttonReload.doClick();
Commons.editWithVSCode(destFile.getAbsolutePath());
}
} catch (IOException e2) {
Expand Down Expand Up @@ -251,19 +254,52 @@ public void actionPerformed(ActionEvent e) {
}
});
buttonPanel.add(buttonSearch);

buttonUpdate = new JButton("Update PoCs");
buttonPanel.add(buttonUpdate);
buttonUpdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SwingWorker<Map, Map> worker = new SwingWorker<Map, Map>() {
@Override
protected Map doInBackground() throws Exception {
setEnabled(false);
updateTemplate();
return null;
}

buttonFresh = new JButton("Fresh");
buttonPanel.add(buttonFresh);
buttonFresh.addActionListener(new ActionListener() {
@Override
protected void done() {
setEnabled(true);
}
};
worker.execute();
}
});

buttonReload = new JButton("Reload PoCs");
buttonPanel.add(buttonReload);
buttonReload.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateTemplate();
LoadData(MainGUI.getGlobalConfig().getPoctRootPath());
lblStatus.setText(titleTableModel.getStatusSummary());
buttonSearch.doClick();
SwingWorker<Map, Map> worker = new SwingWorker<Map, Map>() {
@Override
protected Map doInBackground() throws Exception {
setEnabled(false);
LoadData(MainGUI.getGlobalConfig().getPoctRootPath());
lblStatus.setText(titleTableModel.getStatusSummary());
buttonSearch.doClick();
return null;
}

@Override
protected void done() {
setEnabled(true);
}
};
worker.execute();
}
});

JButton buttonProxy = new JButton("Proxy");
JButton buttonProxy = new JButton("Set Proxy");
buttonPanel.add(buttonProxy);
buttonProxy.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Expand Down
6 changes: 2 additions & 4 deletions src/PoCParser/NucleiParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static LineEntry Parser(String pocfile) {
if (poc.exists() && poc.isFile()) {
try {
result.setPocFileFullPath(pocfile);
result.setPocfile(poc.getName());
result.setPocFileName(poc.getName());

String content = FileUtils.readFileToString(poc);

Expand All @@ -44,7 +44,7 @@ public static LineEntry Parser(String pocfile) {
result.setCVE(bean.getId());

YamlInfo info = bean.getInfo();
result.setPocfile(info.getName());
result.setPocName(info.getName());
result.setAuthor(info.getAuthor());
result.setSeverity(info.getSeverity());
result.setVulnDescription(info.getDescription());
Expand Down Expand Up @@ -159,7 +159,5 @@ public static YamlBeanFromJson yamlToBeanWithFastJson(String yamlFile) throws Ex
public static void main (String[] args) throws Exception {
yamlToBeanWithGson("C:\\Users\\P52\\nuclei-templates\\cves\\2014\\CVE-2014-2321.yaml");
yamlToBeanWithFastJson("C:\\Users\\P52\\nuclei-templates\\cves\\2014\\CVE-2014-2321.yaml");
// YamlBeanFromJson bean = yamlToBean("/Users/liwenjun/nuclei-templates/cves/2007/CVE-2007-4556.yaml");
// int a=1;
}
}
Loading

0 comments on commit 396882f

Please sign in to comment.