Search in sources :

Example 11 with LightScrollPane

use of com.jsql.view.swing.scrollpane.LightScrollPane in project jsql-injection by ron190.

the class CreateShellTab method execute.

@Override
public void execute() {
    if (MediatorGui.frame() == null) {
        LOGGER.error("Unexpected unregistered MediatorGui.frame() in " + this.getClass());
    }
    try {
        UUID terminalID = UUID.randomUUID();
        ShellWeb terminal = new ShellWeb(terminalID, this.url);
        MediatorGui.frame().getConsoles().put(terminalID, terminal);
        LightScrollPane scroller = new LightScrollPaneShell(terminal);
        MediatorGui.tabResults().addTab("Web shell ", scroller);
        // Focus on the new tab
        MediatorGui.tabResults().setSelectedComponent(scroller);
        // Create a custom tab header with close button
        TabHeader header = new TabHeader("Web shell", HelperUi.ICON_SHELL_SERVER);
        MediatorGui.tabResults().setToolTipTextAt(MediatorGui.tabResults().indexOfComponent(scroller), "<html><b>URL</b><br>" + this.url + RessourceAccess.FILENAME_WEBSHELL + "<br><b>Path</b><br>" + this.path + RessourceAccess.FILENAME_WEBSHELL + "</html>");
        // Apply the custom header to the tab
        MediatorGui.tabResults().setTabComponentAt(MediatorGui.tabResults().indexOfComponent(scroller), header);
        terminal.requestFocusInWindow();
    } catch (MalformedURLException e) {
        LOGGER.warn("Incorrect shell Url", e);
    }
}
Also used : TabHeader(com.jsql.view.swing.tab.TabHeader) LightScrollPaneShell(com.jsql.view.swing.scrollpane.LightScrollPaneShell) MalformedURLException(java.net.MalformedURLException) ShellWeb(com.jsql.view.swing.shell.ShellWeb) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) UUID(java.util.UUID)

Example 12 with LightScrollPane

use of com.jsql.view.swing.scrollpane.LightScrollPane in project jsql-injection by ron190.

the class SqlEngine method initErrorTabs.

private void initErrorTabs() {
    SqlEngine.TAB_ERROR.removeAll();
    if (xmlModel.getStrategy().getError() != null) {
        for (Method methodError : xmlModel.getStrategy().getError().getMethod()) {
            JPanel panelError = new JPanel(new BorderLayout());
            final Method[] m = new Method[] { methodError };
            JTextPaneLexer textPane = new JTextPaneLexer(false) {

                @Override
                public void switchSetterToVendor() {
                    this.attributeSetter = new AttributeSetterForVendor(m[0], "setQuery");
                }
            };
            SqlEngine.resetLexer(textPane);
            textPane.switchSetterToVendor();
            textPane.setText(methodError.getQuery().trim());
            textPane.setBorder(SqlEngine.BORDER_RIGHT);
            panelError.add(new LightScrollPane(1, 0, 1, 0, textPane), BorderLayout.CENTER);
            JPanel panelLimit = new JPanel();
            panelLimit.setLayout(new BoxLayout(panelLimit, BoxLayout.LINE_AXIS));
            panelLimit.add(new JLabel(" Overflow limit: "));
            panelLimit.add(new JTextField(Integer.toString(methodError.getCapacity())));
            panelError.add(panelLimit, BorderLayout.SOUTH);
            SqlEngine.TAB_ERROR.addTab(methodError.getName(), panelError);
            SqlEngine.TAB_ERROR.setTitleAt(SqlEngine.TAB_ERROR.getTabCount() - 1, "<html><div style=\"text-align:left;width:150px;\">" + methodError.getName() + "</div></html>");
        }
    }
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) BoxLayout(javax.swing.BoxLayout) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) JLabel(javax.swing.JLabel) Method(com.jsql.model.injection.vendor.model.Model.Strategy.Error.Method) JTextField(javax.swing.JTextField)

Example 13 with LightScrollPane

use of com.jsql.view.swing.scrollpane.LightScrollPane in project jsql-injection by ron190.

the class TabResults method createSQLShellTab.

public void createSQLShellTab(String url, String user, String pass, String path) {
    try {
        var terminalID = UUID.randomUUID();
        var terminal = new ShellSql(terminalID, url, user, pass);
        MediatorHelper.frame().getConsoles().put(terminalID, terminal);
        LightScrollPane scroller = new LightScrollPaneShell(terminal);
        this.addTab("SQL shell ", scroller);
        // Focus on the new tab
        this.setSelectedComponent(scroller);
        // Create a custom tab header with close button
        var header = new TabHeader("SQL shell", UiUtil.ICON_SHELL_SERVER);
        this.setToolTipTextAt(this.indexOfComponent(scroller), String.format("<html><b>URL</b><br>%s%s<br><b>Path</b><br>%s%s</html>", url, MediatorHelper.model().getResourceAccess().filenameSqlshell, path, MediatorHelper.model().getResourceAccess().filenameSqlshell));
        // Apply the custom header to the tab
        this.setTabComponentAt(this.indexOfComponent(scroller), header);
        terminal.requestFocusInWindow();
    } catch (MalformedURLException e) {
        LOGGER.log(LogLevel.CONSOLE_ERROR, "Incorrect shell Url", e);
    }
}
Also used : LightScrollPaneShell(com.jsql.view.swing.scrollpane.LightScrollPaneShell) MalformedURLException(java.net.MalformedURLException) ShellSql(com.jsql.view.swing.shell.ShellSql) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane)

Example 14 with LightScrollPane

use of com.jsql.view.swing.scrollpane.LightScrollPane in project jsql-injection by ron190.

the class Menubar method initializeItemReportIssue.

private JMenuItem initializeItemReportIssue() {
    JMenuItem itemReportIssue = new JMenuItemWithMargin(I18nUtil.valueByKey("MENUBAR_COMMUNITY_REPORTISSUE"), 'R');
    I18nViewUtil.addComponentForKey("MENUBAR_COMMUNITY_REPORTISSUE", itemReportIssue);
    itemReportIssue.addActionListener(actionEvent -> {
        var panel = new JPanel(new BorderLayout());
        final JTextArea textarea = new JPopupTextArea(new JTextArea()).getProxy();
        textarea.setFont(new Font(UiUtil.FONT_NAME_MONOSPACED, Font.PLAIN, UIManager.getDefaults().getFont("TextField.font").getSize()));
        textarea.setText("## What's the expected behavior?\n\n" + "## What's the actual behavior?\n\n" + "## Any other detailed information on the Issue?\n\n" + "## Steps to reproduce the problem\n\n" + "  1. ...\n" + "  2. ...\n\n" + "## [Community] Request for new feature\n\n");
        panel.add(new JLabel("Describe your issue or the bug you encountered :"), BorderLayout.NORTH);
        panel.add(new LightScrollPane(1, 1, 1, 1, textarea));
        panel.setPreferredSize(new Dimension(400, 250));
        panel.setMinimumSize(new Dimension(400, 250));
        textarea.addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {
                super.mousePressed(e);
                textarea.requestFocusInWindow();
            }
        });
        int result = JOptionPane.showOptionDialog(MediatorHelper.frame(), panel, "Report an issue or a bug", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Report", I18nUtil.valueByKey("LIST_ADD_VALUE_CANCEL") }, I18nUtil.valueByKey("LIST_ADD_VALUE_CANCEL"));
        if (StringUtils.isNotEmpty(textarea.getText()) && result == JOptionPane.YES_OPTION) {
            MediatorHelper.model().getMediatorUtils().getGitUtil().sendReport(textarea.getText(), ShowOnConsole.YES, "Report");
        }
    });
    return itemReportIssue;
}
Also used : JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) Dimension(java.awt.Dimension) Font(java.awt.Font) BorderLayout(java.awt.BorderLayout) JPopupTextArea(com.jsql.view.swing.text.JPopupTextArea) JMenuItem(javax.swing.JMenuItem)

Example 15 with LightScrollPane

use of com.jsql.view.swing.scrollpane.LightScrollPane in project jsql-injection by ron190.

the class PanelConsoles method initializeTabsConsoles.

private void initializeTabsConsoles() {
    this.chunkTextArea = new JPopupTextArea(new JTextAreaPlaceholderConsole("Raw data extracted during injection")).getProxy();
    this.chunkTextArea.setEditable(false);
    this.binaryTextArea = new JPopupTextArea(new JTextAreaPlaceholderConsole("Characters extracted during blind or time injection")).getProxy();
    this.binaryTextArea.setEditable(false);
    this.chunkTextArea.setLineWrap(true);
    this.binaryTextArea.setLineWrap(true);
    var consoleTextPane = new SimpleConsoleAdapter("Console", "Event logging");
    // Object creation after customization
    consoleTextPane.getProxy().setEditable(false);
    JTextPaneAppender.register(consoleTextPane);
    this.tabConsoles.setUI(new CustomMetalTabbedPaneUI() {

        @Override
        protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
            return Math.max(80, super.calculateTabWidth(tabPlacement, tabIndex, metrics));
        }
    });
    this.tabConsoles.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0));
    this.buildI18nTab("CONSOLE_MAIN_LABEL", "CONSOLE_MAIN_TOOLTIP", UiUtil.ICON_CONSOLE, new LightScrollPane(1, 0, 0, 0, consoleTextPane.getProxy()), 0);
    // Order is important
    var preferences = Preferences.userRoot().node(InjectionModel.class.getName());
    if (preferences.getBoolean(UiUtil.JAVA_VISIBLE, false)) {
        this.insertJavaTab();
    }
    if (preferences.getBoolean(UiUtil.NETWORK_VISIBLE, true)) {
        this.insertNetworkTab();
    }
    if (preferences.getBoolean(UiUtil.CHUNK_VISIBLE, true)) {
        this.insertChunkTab();
    }
    if (preferences.getBoolean(UiUtil.BINARY_VISIBLE, true)) {
        this.insertBooleanTab();
    }
    // Reset Font when tab is selected
    this.tabConsoles.addChangeListener(changeEvent -> {
        JTabbedPane tabs = this.tabConsoles;
        if (tabs.getSelectedIndex() > -1) {
            var currentTabHeader = tabs.getTabComponentAt(tabs.getSelectedIndex());
            if (currentTabHeader != null) {
                currentTabHeader.setFont(currentTabHeader.getFont().deriveFont(Font.PLAIN));
                currentTabHeader.setForeground(Color.BLACK);
            }
        }
    });
}
Also used : InjectionModel(com.jsql.model.InjectionModel) JTextAreaPlaceholderConsole(com.jsql.view.swing.text.JTextAreaPlaceholderConsole) CustomMetalTabbedPaneUI(com.jsql.view.swing.ui.CustomMetalTabbedPaneUI) FontMetrics(java.awt.FontMetrics) JTabbedPane(javax.swing.JTabbedPane) JPopupTextArea(com.jsql.view.swing.text.JPopupTextArea) SimpleConsoleAdapter(com.jsql.view.swing.console.SimpleConsoleAdapter) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane)

Aggregations

LightScrollPane (com.jsql.view.swing.scrollpane.LightScrollPane)19 BorderLayout (java.awt.BorderLayout)10 JPanel (javax.swing.JPanel)10 JLabel (javax.swing.JLabel)9 JPopupTextArea (com.jsql.view.swing.text.JPopupTextArea)6 TabHeader (com.jsql.view.swing.tab.TabHeader)5 JTabbedPane (javax.swing.JTabbedPane)5 JTextArea (javax.swing.JTextArea)5 LightScrollPaneShell (com.jsql.view.swing.scrollpane.LightScrollPaneShell)4 TabbedPaneWheeled (com.jsql.view.swing.tab.TabbedPaneWheeled)4 Font (java.awt.Font)4 MouseAdapter (java.awt.event.MouseAdapter)4 MouseEvent (java.awt.event.MouseEvent)4 MalformedURLException (java.net.MalformedURLException)4 Dimension (java.awt.Dimension)3 SimpleEntry (java.util.AbstractMap.SimpleEntry)3 JMenuItem (javax.swing.JMenuItem)3 InjectionModel (com.jsql.model.InjectionModel)2 ShellSql (com.jsql.view.swing.shell.ShellSql)2 ShellWeb (com.jsql.view.swing.shell.ShellWeb)2