| 39 | private static JFrame frame; // 使frame成为类的成员变量,以便可以在任意地方访问 |
| 40 | |
| 41 | public void fofaPlugin() { |
| 42 | // 创建基础的窗口框架 |
| 43 | frame = new JFrame("Fofa Hack"); |
| 44 | frame.setSize(800, 600); |
| 45 | frame.setLocationRelativeTo(null); // 居中 |
| 46 | frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // 插件关闭主程序不关闭 |
| 47 | frame.setLayout(new BorderLayout()); |
| 48 | |
| 49 | // 输入面板 |
| 50 | JPanel panel = new JPanel(); |
| 51 | JTextField commandField = new JTextField(50); |
| 52 | JTextField endcountField = new JTextField(10); |
| 53 | JButton executeButton = new JButton("搜索"); |
| 54 | JButton chooseFileButton = new JButton("选择程序"); |
| 55 | |
| 56 | chooseFileButton.setFocusPainted(false); |
| 57 | chooseFileButton.setFocusable(false); |
| 58 | executeButton.setFocusPainted(false); // 添加这一行来取消焦点边框的绘制 |
| 59 | executeButton.setFocusable(false); // 禁止了按钮获取焦点,因此按钮不会在被点击后显示为"激活"或"选中"的状态 |
| 60 | |
| 61 | JTextArea resultArea = new JTextArea(10, 50); |
| 62 | |
| 63 | // 设置断行不断字 |
| 64 | resultArea.setWrapStyleWord(false); |
| 65 | |
| 66 | panel.add(new JLabel("查询语法:")); |
| 67 | panel.add(commandField); |
| 68 | panel.add(new JLabel("查询数量:")); |
| 69 | panel.add(endcountField); |
| 70 | panel.add(executeButton); |
| 71 | //panel.add(chooseFileButton); |
| 72 | |
| 73 | // 结果滚动面板 |
| 74 | JScrollPane scrollPane = new JScrollPane(resultArea); |
| 75 | resultArea.setEditable(false); |
| 76 | |
| 77 | // 添加面板和滚动面板到窗口框架 |
| 78 | frame.add(panel, BorderLayout.NORTH); |
| 79 | frame.add(scrollPane, BorderLayout.CENTER); |
| 80 | |
| 81 | // 执行按钮点击事件 |
| 82 | executeButton.addActionListener(new ActionListener() { |
| 83 | @Override |
| 84 | public void actionPerformed(ActionEvent e) { |
| 85 | // 清空文本区域 |
| 86 | resultArea.setText(""); |
| 87 | String command = commandField.getText().trim(); |
| 88 | String endcount = endcountField.getText().trim(); |
| 89 | executeCommand(command, endcount, resultArea); |
| 90 | } |
| 91 | }); |
| 92 | |
| 93 | // 选择文件按钮事件 |
| 94 | chooseFileButton.addActionListener(new ActionListener() { |
| 95 | @Override |
| 96 | public void actionPerformed(ActionEvent e) { |
| 97 | JFileChooser fileChooser = new JFileChooser(); |
| 98 | fileChooser.setCurrentDirectory(new File(".\\plugins")); // 设置默认目录 |